Index: trunk/extensions/SemanticSignup/SemanticSignup.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Initialization file for the Semantic Signup extension. |
6 | | - * |
| 6 | + * |
7 | 7 | * Documentation: http://www.mediawiki.org/wiki/Extension:SemanticSignup |
8 | 8 | * Support http://www.mediawiki.org/wiki/Extension_talk:SemanticSignup |
9 | 9 | * Source code: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SemanticSignup |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | $wgAutoloadClasses['SemanticSignupSettings'] = dirname( __FILE__ ) . '/SemanticSignup.settings.php'; |
63 | 63 | $wgAutoloadClasses['SemanticSignupHooks'] = dirname( __FILE__ ) . '/SemanticSignup.hooks.php'; |
64 | 64 | $wgAutoloadClasses['SemanticSignup'] = dirname( __FILE__ ) . '/includes/SES_Special.php'; |
65 | | -$wgAutoloadClasses['SES_UserAccountDataChecker'] = dirname( __FILE__ ) . '/includes/SES_Special.php'; |
| 65 | +$wgAutoloadClasses['SES_UserAccountDataChecker'] = dirname( __FILE__ ) . '/includes/SES_Special.php'; |
66 | 66 | $wgAutoloadClasses['SES_DataChecker'] = dirname( __FILE__ ) . '/includes/SES_DataChecker.php'; |
67 | 67 | $wgAutoloadClasses['SES_UserAccountDataChecker'] = dirname( __FILE__ ) . '/includes/SES_UserAccountDataChecker.php'; |
68 | 68 | $wgAutoloadClasses['SES_SignupFields'] = dirname( __FILE__ ) . '/includes/SES_SignupFields.php'; |
Index: trunk/extensions/SemanticSignup/SemanticSignup.hooks.php |
— | — | @@ -2,12 +2,12 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Static class for hooks handled by the SemanticSignup extension. |
6 | | - * |
| 6 | + * |
7 | 7 | * @since 0.3 |
8 | | - * |
| 8 | + * |
9 | 9 | * @file SemanticSignup.hooks.php |
10 | 10 | * @ingroup SemanticSignup |
11 | | - * |
| 11 | + * |
12 | 12 | * @licence GNU GPL v3+ |
13 | 13 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
14 | 14 | */ |
— | — | @@ -17,30 +17,30 @@ |
18 | 18 | * @since 0.3 |
19 | 19 | * |
20 | 20 | * @param $template |
21 | | - * |
| 21 | + * |
22 | 22 | * @return false |
23 | 23 | */ |
24 | 24 | public static function onUserCreateForm( $template ) { |
25 | 25 | if ( is_null( Title::newFromText( SemanticSignupSettings::get( 'formName' ), SF_NS_FORM ) ) ) { |
26 | 26 | return true; |
27 | 27 | } |
28 | | - |
| 28 | + |
29 | 29 | $url = SemanticSignup::getTitleFor( 'SemanticSignup' )->escapeFullURL(); |
30 | 30 | global $wgOut; |
31 | 31 | $wgOut->redirect( $url ); |
32 | | - |
| 32 | + |
33 | 33 | return false; |
34 | 34 | } |
35 | | - |
| 35 | + |
36 | 36 | /** |
37 | 37 | * @since 0.3 |
38 | | - * |
| 38 | + * |
39 | 39 | * @return true |
40 | 40 | */ |
41 | 41 | public static function onParserFirstCallInit() { |
42 | 42 | global $wgParser; |
43 | 43 | $wgParser->setFunctionHook( 'signupfields', 'SES_SignupFields::render' ); |
44 | | - return true; |
| 44 | + return true; |
45 | 45 | } |
46 | 46 | |
47 | 47 | } |
Index: trunk/extensions/SemanticSignup/INSTALL |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | These is the install file for the SemanticSignup extension. |
3 | | - |
| 3 | + |
4 | 4 | Extension page on mediawiki.org: http://www.mediawiki.org/wiki/Extension:SemanticSignup |
5 | 5 | Latest version of the install file: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SemanticSignup/INSTALL?view=co |
6 | 6 | |
Index: trunk/extensions/SemanticSignup/includes/SES_Special.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * a Semantic Forms form page that allows for signup with |
7 | 7 | * adittional (structured) data that immediately gets entered |
8 | 8 | * onto the user page of the new user. |
9 | | - * |
| 9 | + * |
10 | 10 | * @file SES_Special.php |
11 | 11 | * @ingroup SemanticSignup |
12 | 12 | * |
— | — | @@ -13,34 +13,34 @@ |
14 | 14 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | 15 | */ |
16 | 16 | class SemanticSignup extends SpecialPage { |
17 | | - |
| 17 | + |
18 | 18 | private $mUserDataChecker = null; |
19 | 19 | private $mUserPageUrl = ''; |
20 | | - |
| 20 | + |
21 | 21 | public function __construct() { |
22 | 22 | parent::__construct( 'SemanticSignup' ); |
23 | 23 | $this->mIncludable = false; |
24 | 24 | |
25 | 25 | $this->mUserDataChecker = new SES_UserAccountDataChecker(); |
26 | 26 | } |
27 | | - |
| 27 | + |
28 | 28 | private function userSignup() { |
29 | | - //Get user input and check the environment |
| 29 | + // Get user input and check the environment |
30 | 30 | $this->mUserDataChecker->run(); |
31 | | - |
32 | | - //Throw if data getting or environment checks have failed which indicates that account creation is impossible |
| 31 | + |
| 32 | + // Throw if data getting or environment checks have failed which indicates that account creation is impossible |
33 | 33 | $checker_error = $this->mUserDataChecker->getError(); |
34 | 34 | if ( $checker_error ) { |
35 | 35 | throw new Exception( $checker_error ); |
36 | 36 | } |
37 | | - |
38 | | - $user = $this->mUserDataChecker->mUser; |
39 | | - |
| 37 | + |
| 38 | + $user = $this->mUserDataChecker->mUser; |
| 39 | + |
40 | 40 | $user->setEmail( $this->mUserDataChecker->mEmail ); |
41 | 41 | $user->setRealName( $this->mUserDataChecker->mRealname ); |
42 | | - |
| 42 | + |
43 | 43 | $abortError = ''; |
44 | | - if( !wfRunHooks( 'AbortNewAccount', array( $user, &$abortError ) ) ) { |
| 44 | + if ( !wfRunHooks( 'AbortNewAccount', array( $user, &$abortError ) ) ) { |
45 | 45 | // Hook point to add extra creation throttles and blocks |
46 | 46 | wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" ); |
47 | 47 | throw new Exception( $abortError ); |
— | — | @@ -48,36 +48,36 @@ |
49 | 49 | |
50 | 50 | global $wgAccountCreationThrottle; |
51 | 51 | global $wgUser; |
52 | | - |
| 52 | + |
53 | 53 | if ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) { |
54 | 54 | $key = wfMemcKey( 'acctcreate', 'ip', wfGetIP() ); |
55 | 55 | $value = $wgMemc->incr( $key ); |
56 | | - |
| 56 | + |
57 | 57 | if ( !$value ) { |
58 | 58 | $wgMemc->set( $key, 1, 86400 ); |
59 | 59 | } |
60 | | - |
| 60 | + |
61 | 61 | if ( $value > $wgAccountCreationThrottle ) { |
62 | | - throw new Exception(wfMsg('ses-throttlehit')); |
| 62 | + throw new Exception( wfMsg( 'ses-throttlehit' ) ); |
63 | 63 | } |
64 | 64 | } |
65 | | - |
| 65 | + |
66 | 66 | global $wgAuth; |
67 | | - |
| 67 | + |
68 | 68 | $addedUser = $wgAuth->addUser( |
69 | 69 | $user, |
70 | | - $this->mUserDataChecker->mPassword, |
| 70 | + $this->mUserDataChecker->mPassword, |
71 | 71 | $this->mUserDataChecker->mEmail, |
72 | 72 | $this->mUserDataChecker->mRealname |
73 | 73 | ); |
74 | | - |
75 | | - if( !$addedUser ) { |
| 74 | + |
| 75 | + if ( !$addedUser ) { |
76 | 76 | throw new Exception( 'externaldberror' ); |
77 | | - } |
78 | | - |
79 | | - |
| 77 | + } |
| 78 | + |
| 79 | + |
80 | 80 | $user->addToDatabase(); |
81 | | - |
| 81 | + |
82 | 82 | if ( $wgAuth->allowPasswordChange() ) { |
83 | 83 | $user->setPassword( $this->mUserDataChecker->mPassword ); |
84 | 84 | } |
— | — | @@ -95,39 +95,39 @@ |
96 | 96 | |
97 | 97 | global $wgLoginLanguageSelector; |
98 | 98 | $language = $this->mUserDataChecker->mLanguage; |
99 | | - |
100 | | - if( $wgLoginLanguageSelector && $language ) { |
| 99 | + |
| 100 | + if ( $wgLoginLanguageSelector && $language ) { |
101 | 101 | $user->setOption( 'language', $language ); |
102 | 102 | } |
103 | | - |
| 103 | + |
104 | 104 | global $wgEmailAuthentication; |
105 | | - |
106 | | - if( $wgEmailAuthentication && User::isValidEmailAddr( $user->getEmail() ) ) { |
| 105 | + |
| 106 | + if ( $wgEmailAuthentication && User::isValidEmailAddr( $user->getEmail() ) ) { |
107 | 107 | $status = $user->sendConfirmationMail(); |
108 | | - |
| 108 | + |
109 | 109 | if ( !$status->isGood() ) { |
110 | 110 | throw new Exception( wfMsg( 'ses-emailfailed' ) . "\n" . $status->getMessage() ); |
111 | 111 | } |
112 | 112 | } |
113 | | - |
| 113 | + |
114 | 114 | $user->saveSettings(); |
115 | 115 | wfRunHooks( 'AddNewAccount', array( $user ) ); |
116 | 116 | } |
117 | | - |
| 117 | + |
118 | 118 | private function createUserPage() { |
119 | 119 | $form_title = Title::newFromText( SemanticSignupSettings::get( 'formName' ), SF_NS_FORM ); |
120 | 120 | $form = new Article( $form_title ); |
121 | 121 | $form_definition = $form->getContent(); |
122 | | - |
| 122 | + |
123 | 123 | $page_title = Title::newFromText( $this->mUserDataChecker->mUser->getName(), NS_USER ); |
124 | 124 | $this->mUserPageUrl = $page_title->escapeFullUrl(); |
125 | 125 | |
126 | 126 | global $sfgFormPrinter; |
127 | | - list ($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) = |
128 | | - $sfgFormPrinter->formHTML($form_definition, true, false); |
| 127 | + list ( $form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name ) = |
| 128 | + $sfgFormPrinter->formHTML( $form_definition, true, false ); |
129 | 129 | |
130 | 130 | $user_page = new Article( $page_title ); |
131 | | - |
| 131 | + |
132 | 132 | global $wgUser; |
133 | 133 | $wgUser = $this->mUserDataChecker->mUser; |
134 | 134 | // TODO: doEdit removed; use internal API call |
— | — | @@ -138,30 +138,30 @@ |
139 | 139 | global $wgUser; |
140 | 140 | |
141 | 141 | /* |
142 | | - * SemanticForms disable the form automatically if current user hasn't got edit rights |
143 | | - * so we have to use a bot account for the form request. Current user is being saved in |
| 142 | + * SemanticForms disable the form automatically if current user hasn't got edit rights |
| 143 | + * so we have to use a bot account for the form request. Current user is being saved in |
144 | 144 | * the $old_user variable to be restored afterwards |
145 | 145 | */ |
146 | 146 | $old_user = null; |
147 | | - if ( $wgUser->isAnon() ) { |
| 147 | + if ( $wgUser->isAnon() ) { |
148 | 148 | $old_user = $wgUser; |
149 | 149 | $wgUser = User::newFromName( SemanticSignupSettings::get( 'botName' ) ); |
150 | 150 | } |
151 | | - |
| 151 | + |
152 | 152 | $form_title = Title::newFromText( SemanticSignupSettings::get( 'formName' ), SF_NS_FORM ); |
153 | 153 | $form = new Article( $form_title ); |
154 | 154 | $form_definition = $form->getContent(); |
155 | | - |
| 155 | + |
156 | 156 | global $sfgFormPrinter; |
157 | | - |
158 | | - list ($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) = |
159 | | - $sfgFormPrinter->formHTML($form_definition, false, false); |
160 | | - |
161 | | - $text =<<<END |
| 157 | + |
| 158 | + list ( $form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name ) = |
| 159 | + $sfgFormPrinter->formHTML( $form_definition, false, false ); |
| 160 | + |
| 161 | + $text = <<<END |
162 | 162 | <form name="createbox" onsubmit="return validate_all()" action="" method="post" class="createbox"> |
163 | 163 | END; |
164 | | - $text .= $form_text.'</form>'; |
165 | | - |
| 164 | + $text .= $form_text . '</form>'; |
| 165 | + |
166 | 166 | global $sfgScriptPath, $sfgYUIBase, $wgOut; |
167 | 167 | $mainCssUrl = $sfgScriptPath . '/skins/SF_main.css'; |
168 | 168 | $wgOut->addLink( array( |
— | — | @@ -169,85 +169,85 @@ |
170 | 170 | 'type' => 'text/css', |
171 | 171 | 'media' => "screen, projection", |
172 | 172 | 'href' => $mainCssUrl |
173 | | - )); |
| 173 | + ) ); |
174 | 174 | $wgOut->addLink( array( |
175 | 175 | 'rel' => 'stylesheet', |
176 | 176 | 'type' => 'text/css', |
177 | 177 | 'media' => "screen, projection", |
178 | 178 | 'href' => $sfgYUIBase . "autocomplete/assets/skins/sam/autocomplete.css" |
179 | | - )); |
| 179 | + ) ); |
180 | 180 | $wgOut->addLink( array( |
181 | 181 | 'rel' => 'stylesheet', |
182 | 182 | 'type' => 'text/css', |
183 | 183 | 'media' => "screen, projection", |
184 | 184 | 'href' => $sfgScriptPath . '/skins/SF_yui_autocompletion.css' |
185 | | - )); |
| 185 | + ) ); |
186 | 186 | $wgOut->addLink( array( |
187 | 187 | 'rel' => 'stylesheet', |
188 | 188 | 'type' => 'text/css', |
189 | 189 | 'media' => "screen, projection", |
190 | 190 | 'href' => $sfgScriptPath . '/skins/floatbox.css' |
191 | | - )); |
192 | | - |
| 191 | + ) ); |
| 192 | + |
193 | 193 | // FIXME: wtf? |
194 | | - $wgOut->addScript('<script type="text/javascript" src="' . $sfgYUIBase . 'yahoo/yahoo-min.js"></script>' . "\n"); |
195 | | - $wgOut->addScript('<script type="text/javascript" src="' . $sfgYUIBase . 'dom/dom-min.js"></script>' . "\n"); |
196 | | - $wgOut->addScript('<script type="text/javascript" src="' . $sfgYUIBase . 'event/event-min.js"></script>' . "\n"); |
197 | | - $wgOut->addScript('<script type="text/javascript" src="' . $sfgYUIBase . 'get/get-min.js"></script>' . "\n"); |
198 | | - $wgOut->addScript('<script type="text/javascript" src="' . $sfgYUIBase . 'connection/connection-min.js"></script>' . "\n"); |
199 | | - $wgOut->addScript('<script type="text/javascript" src="' . $sfgYUIBase . 'json/json-min.js"></script>' . "\n"); |
200 | | - $wgOut->addScript('<script type="text/javascript" src="' . $sfgYUIBase . 'datasource/datasource-min.js"></script>' . "\n"); |
201 | | - $wgOut->addScript('<script type="text/javascript" src="' . $sfgYUIBase . 'autocomplete/autocomplete-min.js"></script>' . "\n"); |
202 | | - $wgOut->addScript('<script type="text/javascript" src="' . $sfgScriptPath . '/libs/SF_yui_autocompletion.js"></script>' . "\n"); |
203 | | - $wgOut->addScript('<script type="text/javascript" src="' . $sfgScriptPath . '/libs/floatbox.js"></script>' . "\n"); |
204 | | - |
| 194 | + $wgOut->addScript( '<script type="text/javascript" src="' . $sfgYUIBase . 'yahoo/yahoo-min.js"></script>' . "\n" ); |
| 195 | + $wgOut->addScript( '<script type="text/javascript" src="' . $sfgYUIBase . 'dom/dom-min.js"></script>' . "\n" ); |
| 196 | + $wgOut->addScript( '<script type="text/javascript" src="' . $sfgYUIBase . 'event/event-min.js"></script>' . "\n" ); |
| 197 | + $wgOut->addScript( '<script type="text/javascript" src="' . $sfgYUIBase . 'get/get-min.js"></script>' . "\n" ); |
| 198 | + $wgOut->addScript( '<script type="text/javascript" src="' . $sfgYUIBase . 'connection/connection-min.js"></script>' . "\n" ); |
| 199 | + $wgOut->addScript( '<script type="text/javascript" src="' . $sfgYUIBase . 'json/json-min.js"></script>' . "\n" ); |
| 200 | + $wgOut->addScript( '<script type="text/javascript" src="' . $sfgYUIBase . 'datasource/datasource-min.js"></script>' . "\n" ); |
| 201 | + $wgOut->addScript( '<script type="text/javascript" src="' . $sfgYUIBase . 'autocomplete/autocomplete-min.js"></script>' . "\n" ); |
| 202 | + $wgOut->addScript( '<script type="text/javascript" src="' . $sfgScriptPath . '/libs/SF_yui_autocompletion.js"></script>' . "\n" ); |
| 203 | + $wgOut->addScript( '<script type="text/javascript" src="' . $sfgScriptPath . '/libs/floatbox.js"></script>' . "\n" ); |
| 204 | + |
205 | 205 | global $wgFCKEditorDir; |
206 | 206 | if ( $wgFCKEditorDir ) { |
207 | | - $wgOut->addScript('<script type="text/javascript" src="' . "$wgScriptPath/$wgFCKEditorDir" . '/fckeditor.js"></script>' . "\n"); |
| 207 | + $wgOut->addScript( '<script type="text/javascript" src="' . "$wgScriptPath/$wgFCKEditorDir" . '/fckeditor.js"></script>' . "\n" ); |
208 | 208 | } |
209 | | - |
| 209 | + |
210 | 210 | if ( !empty( $javascript_text ) ) { |
211 | | - $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n"); |
| 211 | + $wgOut->addScript( ' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n" ); |
212 | 212 | } |
213 | | - |
| 213 | + |
214 | 214 | $wgOut->addMeta( 'robots', 'noindex,nofollow' ); |
215 | 215 | $wgOut->addHTML( $text ); |
216 | | - |
| 216 | + |
217 | 217 | // Restore the current user. |
218 | 218 | if ( $old_user ) { |
219 | 219 | $wgUser = $old_user; |
220 | 220 | } |
221 | 221 | } |
222 | | - |
| 222 | + |
223 | 223 | private function executeOnSubmit() { |
224 | 224 | global $wgOut; |
225 | | - |
| 225 | + |
226 | 226 | try { |
227 | 227 | $this->userSignup(); |
228 | 228 | $this->createUserPage(); |
229 | | - |
| 229 | + |
230 | 230 | $wgOut->redirect( $this->mUserPageUrl ); |
231 | | - } |
| 231 | + } |
232 | 232 | catch ( Exception $e ) { |
233 | 233 | $wgOut->addHTML( '<div class="error">' . $e->getMessage() . '</div>' ); |
234 | 234 | $this->printForm(); |
235 | 235 | } |
236 | | - |
| 236 | + |
237 | 237 | return true; |
238 | | - } |
239 | | - |
| 238 | + } |
| 239 | + |
240 | 240 | public function execute( $par ) { |
241 | 241 | global $wgRequest, $wgOut; |
242 | | - |
| 242 | + |
243 | 243 | $this->setHeaders(); |
244 | | - |
| 244 | + |
245 | 245 | if ( $wgRequest->getCheck( 'wpSave' ) ) { |
246 | 246 | return $this->executeOnSubmit(); |
247 | 247 | } else { |
248 | 248 | $this->printForm(); |
249 | 249 | return true; |
250 | | - } |
| 250 | + } |
251 | 251 | } |
252 | | - |
| 252 | + |
253 | 253 | } |
254 | 254 | |
\ No newline at end of file |
Index: trunk/extensions/SemanticSignup/includes/SES_UserAccountDataChecker.php |
— | — | @@ -1,10 +1,10 @@ |
2 | | -<?php |
| 2 | +<?php |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Created on 7 Jan 2008 by Serhii Kutnii |
6 | 6 | */ |
7 | 7 | class SES_UserAccountDataChecker extends SES_DataChecker { |
8 | | - |
| 8 | + |
9 | 9 | public $mUsername = ''; |
10 | 10 | public $mPassword = ''; |
11 | 11 | public $mEmail = ''; |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | public $mLanguage = ''; |
15 | 15 | public $mRemember = false; |
16 | 16 | public $mUser = null; |
17 | | - |
| 17 | + |
18 | 18 | protected function populateData() { |
19 | 19 | $this->mUsername = $this->getUserDataValue( 'wpName', 'nousername' ); |
20 | 20 | $name = trim( $this->mUsername ); |
— | — | @@ -21,53 +21,53 @@ |
22 | 22 | if ( !$this->mUser ) { |
23 | 23 | $this->error( wfMsg( 'ses-noname' ) ); |
24 | 24 | } |
25 | | - |
| 25 | + |
26 | 26 | global $sesRealNameRequired; |
27 | | - $this->mRealname = $this->getUserDataValue('wpRealName', $sesRealNameRequired ? 'norealname' : null); |
28 | | - |
29 | | - $this->mPassword = $this->getUserDataValue('wpPassword'); |
30 | | - $retype = $this->getUserDataValue('wpRetype'); |
31 | | - if (strcmp($this->mPassword, $retype)) |
32 | | - $this->error(wfMsg('ses-nopwdmatch')); |
33 | | - |
34 | | - $this->mDomain = $this->getUserDataValue('wpDomain'); |
35 | | - |
| 27 | + $this->mRealname = $this->getUserDataValue( 'wpRealName', $sesRealNameRequired ? 'norealname' : null ); |
| 28 | + |
| 29 | + $this->mPassword = $this->getUserDataValue( 'wpPassword' ); |
| 30 | + $retype = $this->getUserDataValue( 'wpRetype' ); |
| 31 | + if ( strcmp( $this->mPassword, $retype ) ) |
| 32 | + $this->error( wfMsg( 'ses-nopwdmatch' ) ); |
| 33 | + |
| 34 | + $this->mDomain = $this->getUserDataValue( 'wpDomain' ); |
| 35 | + |
36 | 36 | global $wgEmailConfirmToEdit; |
37 | | - $this->mEmail = $this->getUserDataValue('wpEmail', $wgEmailConfirmToEdit ? 'noemailtitle' : null ); |
38 | | - |
39 | | - $this->mLanguage = $this->getUserDataValue('uselang'); |
40 | | - |
| 37 | + $this->mEmail = $this->getUserDataValue( 'wpEmail', $wgEmailConfirmToEdit ? 'noemailtitle' : null ); |
| 38 | + |
| 39 | + $this->mLanguage = $this->getUserDataValue( 'uselang' ); |
| 40 | + |
41 | 41 | global $wgRequest; |
42 | | - $this->mRemember = $wgRequest->getCheck('wpRemember'); |
| 42 | + $this->mRemember = $wgRequest->getCheck( 'wpRemember' ); |
43 | 43 | } |
44 | | - |
45 | | - //Checks |
46 | | - |
| 44 | + |
| 45 | + // Checks |
| 46 | + |
47 | 47 | public function checkDomainValidity() |
48 | 48 | { |
49 | 49 | global $wgAuth; |
50 | | - |
51 | | - if( !$wgAuth->validDomain( $this->mDomain ) ) |
52 | | - $this->error(wfMsg('wrongpassword')); |
| 50 | + |
| 51 | + if ( !$wgAuth->validDomain( $this->mDomain ) ) |
| 52 | + $this->error( wfMsg( 'wrongpassword' ) ); |
53 | 53 | } |
54 | | - |
| 54 | + |
55 | 55 | public function checkDomainUser() |
56 | 56 | { |
57 | 57 | global $wgAuth; |
58 | 58 | |
59 | | - if( ('local' != $this->mDomain) && ('' != $this->mDomain) |
60 | | - && !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists($this->mName) || !$wgAuth->authenticate($this->mName, $this->mPassword) ) ) |
61 | | - $this->error(wfMsg('wrongpassword')); |
| 59 | + if ( ( 'local' != $this->mDomain ) && ( '' != $this->mDomain ) |
| 60 | + && !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName ) || !$wgAuth->authenticate( $this->mName, $this->mPassword ) ) ) |
| 61 | + $this->error( wfMsg( 'wrongpassword' ) ); |
62 | 62 | } |
63 | | - |
| 63 | + |
64 | 64 | public function checkCreatePermissions() |
65 | 65 | { |
66 | 66 | global $wgUser; |
67 | | - |
68 | | - if (!$wgUser->isAllowed( 'createaccount' ) || $wgUser->isBlockedFromCreateAccount() ) |
69 | | - $this->error(wfMsg('ses-createforbidden')); |
| 67 | + |
| 68 | + if ( !$wgUser->isAllowed( 'createaccount' ) || $wgUser->isBlockedFromCreateAccount() ) |
| 69 | + $this->error( wfMsg( 'ses-createforbidden' ) ); |
70 | 70 | } |
71 | | - |
| 71 | + |
72 | 72 | public function checkSorbs() |
73 | 73 | { |
74 | 74 | global $wgProxyWhitelist; |
— | — | @@ -75,39 +75,39 @@ |
76 | 76 | $ip = wfGetIP(); |
77 | 77 | if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) && |
78 | 78 | $wgUser->inSorbsBlacklist( $ip ) ) |
79 | | - $this->error(wfMsg('sorbs_create_account_reason')); |
| 79 | + $this->error( wfMsg( 'sorbs_create_account_reason' ) ); |
80 | 80 | } |
81 | | - |
| 81 | + |
82 | 82 | public function checkUserExists() |
83 | 83 | { |
84 | | - if ($this->mUser->idForName()) |
85 | | - $this->error(wfMsg('ses-userexists')); |
| 84 | + if ( $this->mUser->idForName() ) |
| 85 | + $this->error( wfMsg( 'ses-userexists' ) ); |
86 | 86 | } |
87 | | - |
| 87 | + |
88 | 88 | public function checkPasswordLength() |
89 | 89 | { |
90 | | - if (!$this->mUser->isValidPassword($this->mPassword)) |
| 90 | + if ( !$this->mUser->isValidPassword( $this->mPassword ) ) |
91 | 91 | { |
92 | 92 | global $wgMinimalPasswordLength; |
93 | | - $this->error(wfMsgExt('passwordtooshort', array( 'parsemag' ), $wgMinimalPasswordLength)); |
| 93 | + $this->error( wfMsgExt( 'passwordtooshort', array( 'parsemag' ), $wgMinimalPasswordLength ) ); |
94 | 94 | } |
95 | 95 | } |
96 | | - |
| 96 | + |
97 | 97 | public function checkEmailValidity() |
98 | 98 | { |
99 | 99 | global $wgEnableEmail; |
100 | | - if ($wgEnableEmail && !User::isValidEmailAddr($this->mEmail)) |
101 | | - $this->error(wfMsg('invalidemailaddress')); |
| 100 | + if ( $wgEnableEmail && !User::isValidEmailAddr( $this->mEmail ) ) |
| 101 | + $this->error( wfMsg( 'invalidemailaddress' ) ); |
102 | 102 | } |
103 | | - |
| 103 | + |
104 | 104 | public function __construct() |
105 | 105 | { |
106 | | - $this->addCheck(array(&$this, 'checkDomainValidity'), array()); |
107 | | - $this->addCheck(array(&$this, 'checkDomainUser'), array()); |
108 | | - $this->addCheck(array(&$this, 'checkCreatePermissions'), array()); |
109 | | - $this->addCheck(array(&$this, 'checkSorbs'), array()); |
110 | | - $this->addCheck(array(&$this, 'checkUserExists'), array()); |
111 | | - $this->addCheck(array(&$this, 'checkPasswordLength'), array()); |
112 | | - $this->addCheck(array(&$this, 'checkEmailValidity'), array()); |
| 106 | + $this->addCheck( array( &$this, 'checkDomainValidity' ), array() ); |
| 107 | + $this->addCheck( array( &$this, 'checkDomainUser' ), array() ); |
| 108 | + $this->addCheck( array( &$this, 'checkCreatePermissions' ), array() ); |
| 109 | + $this->addCheck( array( &$this, 'checkSorbs' ), array() ); |
| 110 | + $this->addCheck( array( &$this, 'checkUserExists' ), array() ); |
| 111 | + $this->addCheck( array( &$this, 'checkPasswordLength' ), array() ); |
| 112 | + $this->addCheck( array( &$this, 'checkEmailValidity' ), array() ); |
113 | 113 | } |
114 | 114 | } |
Index: trunk/extensions/SemanticSignup/includes/SES_SignupFields.php |
— | — | @@ -2,12 +2,12 @@ |
3 | 3 | /* |
4 | 4 | * Created on 6 Jan 2009 by Serhii Kutnii |
5 | 5 | */ |
6 | | - |
| 6 | + |
7 | 7 | /* |
8 | 8 | * Borrowed from standard UsercreateTemplate. Some minor changes have been made |
9 | 9 | */ |
10 | | - |
11 | | -class CreateUserFieldsTemplate extends QuickTemplate |
| 10 | + |
| 11 | +class CreateUserFieldsTemplate extends QuickTemplate |
12 | 12 | { |
13 | 13 | function addInputItem( $name, $value, $type, $msg ) { |
14 | 14 | $this->data['extraInput'][] = array( |
— | — | @@ -17,19 +17,19 @@ |
18 | 18 | 'msg' => $msg, |
19 | 19 | ); |
20 | 20 | } |
21 | | - |
| 21 | + |
22 | 22 | function execute() { |
23 | | - |
| 23 | + |
24 | 24 | ?> |
25 | 25 | <div id="userlogin"> |
26 | 26 | |
27 | | - <h2><?php $this->msg('createaccount') ?></h2> |
28 | | - <p id="userloginlink"><?php $this->html('link') ?></p> |
29 | | - <?php $this->html('header'); /* pre-table point for form plugins... */ ?> |
30 | | - <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?> |
| 27 | + <h2><?php $this->msg( 'createaccount' ) ?></h2> |
| 28 | + <p id="userloginlink"><?php $this->html( 'link' ) ?></p> |
| 29 | + <?php $this->html( 'header' ); /* pre-table point for form plugins... */ ?> |
| 30 | + <?php if ( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?> |
31 | 31 | <table> |
32 | 32 | <tr> |
33 | | - <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td> |
| 33 | + <td class="mw-label"><label for='wpName2'><?php $this->msg( 'yourname' ) ?></label></td> |
34 | 34 | <td class="mw-input"> |
35 | 35 | <input type='text' class='loginText' name="wpName" id="wpName2" |
36 | 36 | tabindex="1" |
— | — | @@ -37,16 +37,16 @@ |
38 | 38 | </td> |
39 | 39 | </tr> |
40 | 40 | <tr> |
41 | | - <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td> |
| 41 | + <td class="mw-label"><label for='wpPassword2'><?php $this->msg( 'yourpassword' ) ?></label></td> |
42 | 42 | <td class="mw-input"> |
43 | 43 | <input type='password' class='loginPassword' name="wpPassword" id="wpPassword2" |
44 | 44 | tabindex="2" |
45 | 45 | value="" size='20' /> |
46 | 46 | </td> |
47 | 47 | </tr> |
48 | | - <?php if( $this->data['usedomain'] ) { |
| 48 | + <?php if ( $this->data['usedomain'] ) { |
49 | 49 | $doms = ""; |
50 | | - foreach( $this->data['domainnames'] as $dom ) { |
| 50 | + foreach ( $this->data['domainnames'] as $dom ) { |
51 | 51 | $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>"; |
52 | 52 | } |
53 | 53 | ?> |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | </tr> |
63 | 63 | <?php } ?> |
64 | 64 | <tr> |
65 | | - <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td> |
| 65 | + <td class="mw-label"><label for='wpRetype'><?php $this->msg( 'yourpasswordagain' ) ?></label></td> |
66 | 66 | <td class="mw-input"> |
67 | 67 | <input type='password' class='loginPassword' name="wpRetype" id="wpRetype" |
68 | 68 | tabindex="4" |
— | — | @@ -70,25 +70,25 @@ |
71 | 71 | </td> |
72 | 72 | </tr> |
73 | 73 | <tr> |
74 | | - <?php if( $this->data['useemail'] ) { ?> |
75 | | - <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td> |
| 74 | + <?php if ( $this->data['useemail'] ) { ?> |
| 75 | + <td class="mw-label"><label for='wpEmail'><?php $this->msg( 'youremail' ) ?></label></td> |
76 | 76 | <td class="mw-input"> |
77 | 77 | <input type='text' class='loginText' name="wpEmail" id="wpEmail" |
78 | 78 | tabindex="5" |
79 | | - value="<?php $this->text('email') ?>" size='20' /> |
| 79 | + value="<?php $this->text( 'email' ) ?>" size='20' /> |
80 | 80 | <div class="prefsectiontip"> |
81 | | - <?php if( $this->data['emailrequired'] ) { |
82 | | - $this->msgWiki('prefs-help-email-required'); |
| 81 | + <?php if ( $this->data['emailrequired'] ) { |
| 82 | + $this->msgWiki( 'prefs-help-email-required' ); |
83 | 83 | } else { |
84 | | - $this->msgWiki('prefs-help-email'); |
| 84 | + $this->msgWiki( 'prefs-help-email' ); |
85 | 85 | } ?> |
86 | 86 | </div> |
87 | 87 | </td> |
88 | 88 | <?php } ?> |
89 | | - <?php if( $this->data['userealname'] ) { ?> |
| 89 | + <?php if ( $this->data['userealname'] ) { ?> |
90 | 90 | </tr> |
91 | 91 | <tr> |
92 | | - <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td> |
| 92 | + <td class="mw-label"><label for='wpRealName'><?php $this->msg( 'yourrealname' ) ?></label></td> |
93 | 93 | <td class="mw-input"> |
94 | 94 | <input type='text' class='loginText' name="wpRealName" id="wpRealName" |
95 | 95 | tabindex="6" |
— | — | @@ -104,9 +104,9 @@ |
105 | 105 | if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) { |
106 | 106 | foreach ( $this->data['extraInput'] as $inputItem ) { ?> |
107 | 107 | <tr> |
108 | | - <?php |
| 108 | + <?php |
109 | 109 | if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) { |
110 | | - ?><td class="mw-label"><label for="<?php |
| 110 | + ?><td class="mw-label"><label for="<?php |
111 | 111 | echo htmlspecialchars( $inputItem['name'] ); ?>"><?php |
112 | 112 | $this->msgWiki( $inputItem['msg'] ) ?></label><?php |
113 | 113 | } else { |
— | — | @@ -117,17 +117,17 @@ |
118 | 118 | <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php |
119 | 119 | echo htmlspecialchars( $inputItem['name'] ); ?>" |
120 | 120 | tabindex="<?php echo $tabIndex++; ?>" |
121 | | - value="<?php |
| 121 | + value="<?php |
122 | 122 | if ( $inputItem['type'] != 'checkbox' ) { |
123 | 123 | echo htmlspecialchars( $inputItem['value'] ); |
124 | 124 | } else { |
125 | 125 | echo '1'; |
126 | | - } |
| 126 | + } |
127 | 127 | ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>" |
128 | | - <?php |
| 128 | + <?php |
129 | 129 | if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) ) |
130 | | - echo 'checked="checked"'; |
131 | | - ?> /> <?php |
| 130 | + echo 'checked="checked"'; |
| 131 | + ?> /> <?php |
132 | 132 | if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) { |
133 | 133 | ?> |
134 | 134 | <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php |
— | — | @@ -136,8 +136,8 @@ |
137 | 137 | ?> |
138 | 138 | </td> |
139 | 139 | </tr> |
140 | | -<?php |
141 | | - |
| 140 | +<?php |
| 141 | + |
142 | 142 | } |
143 | 143 | } |
144 | 144 | ?> |
— | — | @@ -145,7 +145,7 @@ |
146 | 146 | <td></td> |
147 | 147 | </tr> |
148 | 148 | </table> |
149 | | -<?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?> |
| 149 | +<?php if ( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?> |
150 | 150 | </div> |
151 | 151 | <div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div> |
152 | 152 | <?php |
— | — | @@ -154,18 +154,18 @@ |
155 | 155 | } |
156 | 156 | |
157 | 157 | class SES_SignupFields { |
158 | | - |
| 158 | + |
159 | 159 | public static function render( $args, $parser ) { |
160 | 160 | $args = func_get_args(); |
161 | 161 | |
162 | 162 | $parser = array_shift( $args ); |
163 | | - |
| 163 | + |
164 | 164 | $template = new CreateUserFieldsTemplate(); |
165 | 165 | |
166 | 166 | $template->set( 'header', '' ); |
167 | | - |
| 167 | + |
168 | 168 | global $wgEnableEmail, $wgAllowRealName, $wgEmailConfirmToEdit, $wgAuth, $wgUser; |
169 | | - |
| 169 | + |
170 | 170 | $template->set( 'link', '' ); // TODO |
171 | 171 | $template->set( 'email', '' ); // TODO |
172 | 172 | $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() ); |
— | — | @@ -173,27 +173,27 @@ |
174 | 174 | $template->set( 'useemail', $wgEnableEmail ); |
175 | 175 | $template->set( 'emailrequired', $wgEmailConfirmToEdit ); |
176 | 176 | $template->set( 'canreset', $wgAuth->allowPasswordChange() ); |
177 | | - //$template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) ); |
| 177 | + // $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) ); |
178 | 178 | |
179 | 179 | global $wgLoginLanguageSelector; |
180 | 180 | # Prepare language selection links as needed |
181 | | - if( $wgLoginLanguageSelector ) { |
| 181 | + if ( $wgLoginLanguageSelector ) { |
182 | 182 | $template->set( 'languages', $this->makeLanguageSelector() ); |
183 | 183 | } |
184 | 184 | |
185 | 185 | // Give authentication and captcha plugins a chance to modify the form |
186 | 186 | $type = 'signup'; |
187 | 187 | $wgAuth->modifyUITemplate( $template, $type ); |
188 | | - |
| 188 | + |
189 | 189 | ob_start(); |
190 | 190 | $template->execute(); |
191 | 191 | $text = ob_get_clean(); |
192 | | - |
| 192 | + |
193 | 193 | return array( |
194 | 194 | $text, |
195 | 195 | 'noparse' => true, |
196 | 196 | 'isHTML' => true |
197 | 197 | ); |
198 | 198 | } |
199 | | - |
| 199 | + |
200 | 200 | } |
Index: trunk/extensions/SemanticSignup/includes/SES_DataChecker.php |
— | — | @@ -5,58 +5,58 @@ |
6 | 6 | |
7 | 7 | /* |
8 | 8 | * An abstract data getter and checker class. |
9 | | - * Its concrete subclasses should incapsulate all the necessary data getting |
10 | | - * and environment checks. |
| 9 | + * Its concrete subclasses should incapsulate all the necessary data getting |
| 10 | + * and environment checks. |
11 | 11 | */ |
12 | 12 | abstract class SES_DataChecker |
13 | 13 | { |
14 | 14 | private $mError = null; |
15 | | - |
| 15 | + |
16 | 16 | public function getError() |
17 | 17 | { |
18 | 18 | return $this->mError; |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | /* |
22 | | - * Get a value from the request. |
| 22 | + * Get a value from the request. |
23 | 23 | * $err_message_id specifies an error that should be thrown |
24 | | - * if the value is empty |
| 24 | + * if the value is empty |
25 | 25 | */ |
26 | | - protected function getUserDataValue($id, $err_message_id = null) |
| 26 | + protected function getUserDataValue( $id, $err_message_id = null ) |
27 | 27 | { |
28 | 28 | global $wgRequest; |
29 | | - $value = $wgRequest->getText($id); |
30 | | - |
31 | | - if ($err_message_id && !$value) |
32 | | - $this->error(wfMsg($err_message_id)); |
33 | | - |
| 29 | + $value = $wgRequest->getText( $id ); |
| 30 | + |
| 31 | + if ( $err_message_id && !$value ) |
| 32 | + $this->error( wfMsg( $err_message_id ) ); |
| 33 | + |
34 | 34 | return $value; |
35 | 35 | } |
36 | | - |
37 | | - //Checks |
| 36 | + |
| 37 | + // Checks |
38 | 38 | private $mEnvCheckCalls = array(); |
39 | | - |
40 | | - protected function addCheck($method_callback, array $args) |
| 39 | + |
| 40 | + protected function addCheck( $method_callback, array $args ) |
41 | 41 | { |
42 | | - $this->mEnvCheckCalls[] = array($method_callback, $args); |
| 42 | + $this->mEnvCheckCalls[] = array( $method_callback, $args ); |
43 | 43 | } |
44 | | - |
| 44 | + |
45 | 45 | protected function runChecks() |
46 | 46 | { |
47 | | - foreach ($this->mEnvCheckCalls as $call_array) |
| 47 | + foreach ( $this->mEnvCheckCalls as $call_array ) |
48 | 48 | { |
49 | | - call_user_func_array($call_array[0], $call_array[1]); |
| 49 | + call_user_func_array( $call_array[0], $call_array[1] ); |
50 | 50 | } |
51 | 51 | } |
52 | | - |
53 | | - //Abstracting error calls in order to make this functionality changeable in subclasses |
54 | | - protected function error($message) |
| 52 | + |
| 53 | + // Abstracting error calls in order to make this functionality changeable in subclasses |
| 54 | + protected function error( $message ) |
55 | 55 | { |
56 | | - throw new Exception($message); |
| 56 | + throw new Exception( $message ); |
57 | 57 | } |
58 | | - |
| 58 | + |
59 | 59 | abstract protected function populateData(); |
60 | | - |
| 60 | + |
61 | 61 | public function run() |
62 | 62 | { |
63 | 63 | try |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | $this->populateData(); |
66 | 66 | $this->runChecks(); |
67 | 67 | } |
68 | | - catch (Exception $e) |
| 68 | + catch ( Exception $e ) |
69 | 69 | { |
70 | 70 | $this->mError = $e->getMessage(); |
71 | 71 | } |
Index: trunk/extensions/SemanticSignup/SemanticSignup.i18n.aliases.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | */ |
14 | 14 | |
15 | 15 | $aliases = array(); |
16 | | - |
| 16 | + |
17 | 17 | $aliases['en'] = array( |
18 | 18 | 'SemanticSignup' => array( 'SemanticSignup', 'Semantic Signup' ) |
19 | 19 | ); |
Index: trunk/extensions/SemanticSignup/SemanticSignup.i18n.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | */ |
15 | 15 | |
16 | 16 | $messages = array(); |
17 | | - |
| 17 | + |
18 | 18 | $messages['en'] = array( |
19 | 19 | 'semanticsignup' => 'Semantic Signup', |
20 | 20 | 'ses-desc' => 'A MediaWiki extension built on top of Semantic Forms allowing to populate a user page with semantic data at signup time', |
Index: trunk/extensions/SemanticSignup/SemanticSignup.settings.php |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
18 | 18 | */ |
19 | 19 | class SemanticSignupSettings { |
20 | | - |
| 20 | + |
21 | 21 | protected static function getDefaultSettings() { |
22 | 22 | return array( |
23 | 23 | 'requireName' => false, |
— | — | @@ -24,23 +24,23 @@ |
25 | 25 | 'botName' => '', |
26 | 26 | ); |
27 | 27 | } |
28 | | - |
| 28 | + |
29 | 29 | public static function getSettings() { |
30 | 30 | static $settings = false; |
31 | | - |
| 31 | + |
32 | 32 | if ( $settings === false ) { |
33 | 33 | $settings = array_merge( |
34 | 34 | self::getDefaultSettings(), |
35 | 35 | $GLOBALS['egSemanticSignupSettings'] |
36 | 36 | ); |
37 | 37 | } |
38 | | - |
| 38 | + |
39 | 39 | return $settings; |
40 | 40 | } |
41 | | - |
| 41 | + |
42 | 42 | public static function get( $settingName ) { |
43 | 43 | $settings = self::getSettings(); |
44 | | - return array_key_exists( $settingName, $settings ) ? $settings[$settingName] : null; |
| 44 | + return array_key_exists( $settingName, $settings ) ? $settings[$settingName] : null; |
45 | 45 | } |
46 | | - |
| 46 | + |
47 | 47 | } |