Index: trunk/extensions/Auth_remoteuser/Auth_remoteuser.php |
— | — | @@ -60,21 +60,21 @@ |
61 | 61 | // You probably want to edit the initUser function to set the users real name |
62 | 62 | // and email address properly for your configuration. |
63 | 63 | |
64 | | -//Extension credits that show up on Special:Version |
| 64 | +// Extension credits that show up on Special:Version |
65 | 65 | $wgExtensionCredits['other'][] = array( |
66 | 66 | 'name' => 'AutomaticREMOTE USER', |
67 | 67 | 'version' => '1.1.3', |
68 | | - 'author' => array('Otheus Shelling', 'Rusty Burchfield', 'James Kinsman', 'Daniel Thomas', 'Ian Ward Comfort'), |
| 68 | + 'author' => array( 'Otheus Shelling', 'Rusty Burchfield', 'James Kinsman', 'Daniel Thomas', 'Ian Ward Comfort' ), |
69 | 69 | 'url' => 'http://www.mediawiki.org/wiki/Extension:AutomaticREMOTE_USER', |
70 | 70 | 'description' => 'Automatically logs users using the REMOTE_USER environment variable.', |
71 | 71 | ); |
72 | 72 | |
73 | | -//We must allow zero length passwords. This extension does not work in MW 1.16 without this. |
| 73 | +// We must allow zero length passwords. This extension does not work in MW 1.16 without this. |
74 | 74 | $wgMinimalPasswordLength = 0; |
75 | 75 | |
76 | 76 | // The Auth_remoteuser class is an AuthPlugin so make sure we have this |
77 | 77 | // included. |
78 | | -require_once('AuthPlugin.php'); |
| 78 | +require_once( 'AuthPlugin.php' ); |
79 | 79 | |
80 | 80 | /** |
81 | 81 | * This hook is registered by the Auth_remoteuser constructor. It will be |
— | — | @@ -101,29 +101,29 @@ |
102 | 102 | global $wgAuthRemoteuserDomain; |
103 | 103 | |
104 | 104 | // For a few special pages, don't do anything. |
105 | | - $title = $wgRequest->getVal('title'); |
106 | | - if (($title == Title::makeName(NS_SPECIAL, 'UserLogout')) || |
107 | | - ($title == Title::makeName(NS_SPECIAL, 'UserLogin'))) { |
| 105 | + $title = $wgRequest->getVal( 'title' ); |
| 106 | + if ( ( $title == Title::makeName( NS_SPECIAL, 'UserLogout' ) ) || |
| 107 | + ( $title == Title::makeName( NS_SPECIAL, 'UserLogin' ) ) ) { |
108 | 108 | return; |
109 | 109 | } |
110 | 110 | |
111 | | - //Process the username if required |
112 | | - if (!isset($_SERVER['REMOTE_USER'])) |
| 111 | + // Process the username if required |
| 112 | + if ( !isset( $_SERVER['REMOTE_USER'] ) ) |
113 | 113 | { |
114 | 114 | return; |
115 | 115 | } |
116 | | - if (isset($wgAuthRemoteuserDomain) && strlen($wgAuthRemoteuserDomain)) |
| 116 | + if ( isset( $wgAuthRemoteuserDomain ) && strlen( $wgAuthRemoteuserDomain ) ) |
117 | 117 | { |
118 | | - $username = str_replace("$wgAuthRemoteuserDomain\\","",$_SERVER['REMOTE_USER']); |
119 | | - $username = str_replace("@$wgAuthRemoteuserDomain","",$username); |
| 118 | + $username = str_replace( "$wgAuthRemoteuserDomain\\", "", $_SERVER['REMOTE_USER'] ); |
| 119 | + $username = str_replace( "@$wgAuthRemoteuserDomain", "", $username ); |
120 | 120 | } else { |
121 | 121 | $username = $_SERVER['REMOTE_USER']; |
122 | 122 | } |
123 | 123 | |
124 | 124 | // Check for valid session |
125 | 125 | $user = User::newFromSession(); |
126 | | - if (!$user->isAnon()) { |
127 | | - if ($user->getName() == Auth_remoteuser::getCanonicalName($username)) { |
| 126 | + if ( !$user->isAnon() ) { |
| 127 | + if ( $user->getName() == Auth_remoteuser::getCanonicalName( $username ) ) { |
128 | 128 | return; // Correct user is already logged in. |
129 | 129 | } else { |
130 | 130 | $user->doLogout(); // Logout mismatched user. |
— | — | @@ -131,37 +131,37 @@ |
132 | 132 | } |
133 | 133 | |
134 | 134 | // Copied from includes/SpecialUserlogin.php |
135 | | - if(!isset($wgCommandLineMode) && !isset($_COOKIE[session_name()])) { |
| 135 | + if ( !isset( $wgCommandLineMode ) && !isset( $_COOKIE[session_name()] ) ) { |
136 | 136 | wfSetupSession(); |
137 | 137 | } |
138 | 138 | |
139 | 139 | // If the login form returns NEED_TOKEN try once more with the right token |
140 | | - $tryagain=false; |
141 | | - $trycount=0; |
| 140 | + $tryagain = false; |
| 141 | + $trycount = 0; |
142 | 142 | $token = ''; |
143 | 143 | do |
144 | 144 | { |
145 | | - $tryagain=false; |
| 145 | + $tryagain = false; |
146 | 146 | // Submit a fake login form to authenticate the user. |
147 | | - $params = new FauxRequest(array( |
| 147 | + $params = new FauxRequest( array( |
148 | 148 | 'wpName' => $username, |
149 | 149 | 'wpPassword' => '', |
150 | 150 | 'wpDomain' => '', |
151 | 151 | 'wpLoginToken' => $token, |
152 | 152 | 'wpRemember' => '' |
153 | | - )); |
| 153 | + ) ); |
154 | 154 | |
155 | 155 | // Authenticate user data will automatically create new users. |
156 | | - $loginForm = new LoginForm($params); |
| 156 | + $loginForm = new LoginForm( $params ); |
157 | 157 | $result = $loginForm->authenticateUserData(); |
158 | | - switch ($result) { |
| 158 | + switch ( $result ) { |
159 | 159 | case LoginForm :: SUCCESS : |
160 | | - $wgUser->setOption('rememberpassword', 1); |
| 160 | + $wgUser->setOption( 'rememberpassword', 1 ); |
161 | 161 | $wgUser->setCookies(); |
162 | 162 | break; |
163 | 163 | case LoginForm :: NEED_TOKEN: |
164 | 164 | $token = $loginForm->getLoginToken(); |
165 | | - $tryagain=($trycount==0); |
| 165 | + $tryagain = ( $trycount == 0 ); |
166 | 166 | break; |
167 | 167 | case LoginForm :: WRONG_TOKEN: |
168 | 168 | $errormessage = 'WrongToken'; |
— | — | @@ -189,12 +189,12 @@ |
190 | 190 | break; |
191 | 191 | } |
192 | 192 | |
193 | | - if ($result != LoginForm::SUCCESS && $result != LoginForm::NEED_TOKEN ) { |
194 | | - error_log('Unexpected REMOTE_USER authentication failure. Login Error was:'.$errormessage); |
| 193 | + if ( $result != LoginForm::SUCCESS && $result != LoginForm::NEED_TOKEN ) { |
| 194 | + error_log( 'Unexpected REMOTE_USER authentication failure. Login Error was:' . $errormessage ); |
195 | 195 | } |
196 | 196 | $trycount++; |
197 | 197 | } |
198 | | - while ($tryagain); |
| 198 | + while ( $tryagain ); |
199 | 199 | |
200 | 200 | return; |
201 | 201 | } |
— | — | @@ -204,15 +204,15 @@ |
205 | 205 | function Auth_remoteuser() { |
206 | 206 | // Register our hook function. This hook will be executed on every page |
207 | 207 | // load. Its purpose is to automatically log the user in, if necessary. |
208 | | - if (isset($_SERVER['REMOTE_USER']) && strlen($_SERVER['REMOTE_USER'])) { |
| 208 | + if ( isset( $_SERVER['REMOTE_USER'] ) && strlen( $_SERVER['REMOTE_USER'] ) ) { |
209 | 209 | global $wgExtensionFunctions; |
210 | | - if (!isset($wgExtensionFunctions)) { |
| 210 | + if ( !isset( $wgExtensionFunctions ) ) { |
211 | 211 | $wgExtensionFunctions = array(); |
212 | 212 | } |
213 | | - else if (!is_array($wgExtensionFunctions)) { |
| 213 | + else if ( !is_array( $wgExtensionFunctions ) ) { |
214 | 214 | $wgExtensionFunctions = array( $wgExtensionFunctions ); |
215 | 215 | } |
216 | | - array_push($wgExtensionFunctions, 'Auth_remote_user_hook'); |
| 216 | + array_push( $wgExtensionFunctions, 'Auth_remote_user_hook' ); |
217 | 217 | } |
218 | 218 | return; |
219 | 219 | } |
— | — | @@ -235,7 +235,7 @@ |
236 | 236 | * @return bool |
237 | 237 | * @public |
238 | 238 | */ |
239 | | - function setPassword($user, $password) { |
| 239 | + function setPassword( $user, $password ) { |
240 | 240 | return false; |
241 | 241 | } |
242 | 242 | |
— | — | @@ -246,7 +246,7 @@ |
247 | 247 | * @return bool |
248 | 248 | * @public |
249 | 249 | */ |
250 | | - function updateExternalDB($user) { |
| 250 | + function updateExternalDB( $user ) { |
251 | 251 | return true; |
252 | 252 | } |
253 | 253 | |
— | — | @@ -269,7 +269,7 @@ |
270 | 270 | * @return bool |
271 | 271 | * @public |
272 | 272 | */ |
273 | | - function addUser($user, $password) { |
| 273 | + function addUser( $user, $password ) { |
274 | 274 | return false; |
275 | 275 | } |
276 | 276 | |
— | — | @@ -282,7 +282,7 @@ |
283 | 283 | * @return bool |
284 | 284 | * @public |
285 | 285 | */ |
286 | | - function userExists($username) { |
| 286 | + function userExists( $username ) { |
287 | 287 | return true; |
288 | 288 | } |
289 | 289 | |
— | — | @@ -296,30 +296,30 @@ |
297 | 297 | * @return bool |
298 | 298 | * @public |
299 | 299 | */ |
300 | | - function authenticate($username, $password) { |
| 300 | + function authenticate( $username, $password ) { |
301 | 301 | global $_SERVER; |
302 | 302 | global $wgAuthRemoteuserAuthz; |
303 | 303 | global $wgAuthRemoteuserDomain; |
304 | 304 | |
305 | | - if (isset($wgAuthRemoteuserAuthz) && $wgAuthRemoteuserAuthz != true) |
| 305 | + if ( isset( $wgAuthRemoteuserAuthz ) && $wgAuthRemoteuserAuthz != true ) |
306 | 306 | return false; |
307 | 307 | |
308 | | - if (isset($_SERVER['REMOTE_USER']) == false) |
| 308 | + if ( isset( $_SERVER['REMOTE_USER'] ) == false ) |
309 | 309 | { |
310 | 310 | $_SERVER['REMOTE_USER'] = ""; |
311 | 311 | } |
312 | | - if (!isset($_SERVER['REMOTE_USER'])) |
| 312 | + if ( !isset( $_SERVER['REMOTE_USER'] ) ) |
313 | 313 | { |
314 | 314 | return false; |
315 | 315 | } |
316 | | - if (isset($wgAuthRemoteuserDomain) && strlen($wgAuthRemoteuserDomain)>0) { |
317 | | - $usertest = str_replace("$wgAuthRemoteuserDomain\\","",$_SERVER['REMOTE_USER']); |
318 | | - $usertest = str_replace("@$wgAuthRemoteuserDomain","",$usertest); |
| 316 | + if ( isset( $wgAuthRemoteuserDomain ) && strlen( $wgAuthRemoteuserDomain ) > 0 ) { |
| 317 | + $usertest = str_replace( "$wgAuthRemoteuserDomain\\", "", $_SERVER['REMOTE_USER'] ); |
| 318 | + $usertest = str_replace( "@$wgAuthRemoteuserDomain", "", $usertest ); |
319 | 319 | } else { |
320 | 320 | $usertest = $_SERVER['REMOTE_USER']; |
321 | 321 | } |
322 | 322 | |
323 | | - return (strtolower($username) == strtolower($usertest)); |
| 323 | + return ( strtolower( $username ) == strtolower( $usertest ) ); |
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
— | — | @@ -329,7 +329,7 @@ |
330 | 330 | * @return bool |
331 | 331 | * @public |
332 | 332 | */ |
333 | | - function validDomain($domain) { |
| 333 | + function validDomain( $domain ) { |
334 | 334 | return true; |
335 | 335 | } |
336 | 336 | |
— | — | @@ -344,7 +344,7 @@ |
345 | 345 | * @param User $user |
346 | 346 | * @public |
347 | 347 | */ |
348 | | - function updateUser(&$user) { |
| 348 | + function updateUser( &$user ) { |
349 | 349 | // We only set this stuff when accounts are created. |
350 | 350 | return true; |
351 | 351 | } |
— | — | @@ -380,7 +380,7 @@ |
381 | 381 | * @param $user User object. |
382 | 382 | * @public |
383 | 383 | */ |
384 | | - function initUser(&$user) { |
| 384 | + function initUser( &$user ) { |
385 | 385 | global $_SERVER; |
386 | 386 | global $wgAuthRemoteuserName; |
387 | 387 | global $wgAuthRemoteuserMail; |
— | — | @@ -388,35 +388,35 @@ |
389 | 389 | global $wgAuthRemoteuserNotify; |
390 | 390 | global $wgAuthRemoteuserDomain; |
391 | 391 | |
392 | | - if (isset($wgAuthRemoteuserDomain) && strlen($wgAuthRemoteuserDomain)) |
| 392 | + if ( isset( $wgAuthRemoteuserDomain ) && strlen( $wgAuthRemoteuserDomain ) ) |
393 | 393 | { |
394 | | - $username = str_replace("$wgAuthRemoteuserDomain\\","",$_SERVER['REMOTE_USER']); |
395 | | - $username = str_replace("@$wgAuthRemoteuserDomain","",$username); |
| 394 | + $username = str_replace( "$wgAuthRemoteuserDomain\\", "", $_SERVER['REMOTE_USER'] ); |
| 395 | + $username = str_replace( "@$wgAuthRemoteuserDomain", "", $username ); |
396 | 396 | } else { |
397 | 397 | $username = $_SERVER['REMOTE_USER']; |
398 | 398 | } |
399 | 399 | |
400 | | - if (isset($wgAuthRemoteuserName)) |
401 | | - $user->setRealName($wgAuthRemoteuserName); |
| 400 | + if ( isset( $wgAuthRemoteuserName ) ) |
| 401 | + $user->setRealName( $wgAuthRemoteuserName ); |
402 | 402 | else |
403 | | - $user->setRealName(''); |
| 403 | + $user->setRealName( '' ); |
404 | 404 | |
405 | | - if (isset($wgAuthRemoteuserMail)) |
406 | | - $user->setEmail($wgAuthRemoteuserMail); |
407 | | - elseif (isset($wgAuthRemoteuserMailDomain)) |
408 | | - $user->setEmail($username . '@' . $wgAuthRemoteuserMailDomain); |
| 405 | + if ( isset( $wgAuthRemoteuserMail ) ) |
| 406 | + $user->setEmail( $wgAuthRemoteuserMail ); |
| 407 | + elseif ( isset( $wgAuthRemoteuserMailDomain ) ) |
| 408 | + $user->setEmail( $username . '@' . $wgAuthRemoteuserMailDomain ); |
409 | 409 | else |
410 | | - $user->setEmail($username . "@example.com"); |
| 410 | + $user->setEmail( $username . "@example.com" ); |
411 | 411 | |
412 | 412 | $user->mEmailAuthenticated = wfTimestampNow(); |
413 | 413 | $user->setToken(); |
414 | 414 | |
415 | | - //turn on e-mail notifications |
416 | | - if (isset($wgAuthRemoteuserNotify) && $wgAuthRemoteuserNotify) { |
417 | | - $user->setOption('enotifwatchlistpages', 1); |
418 | | - $user->setOption('enotifusertalkpages', 1); |
419 | | - $user->setOption('enotifminoredits', 1); |
420 | | - $user->setOption('enotifrevealaddr', 1); |
| 415 | + // turn on e-mail notifications |
| 416 | + if ( isset( $wgAuthRemoteuserNotify ) && $wgAuthRemoteuserNotify ) { |
| 417 | + $user->setOption( 'enotifwatchlistpages', 1 ); |
| 418 | + $user->setOption( 'enotifusertalkpages', 1 ); |
| 419 | + $user->setOption( 'enotifminoredits', 1 ); |
| 420 | + $user->setOption( 'enotifrevealaddr', 1 ); |
421 | 421 | } |
422 | 422 | |
423 | 423 | $user->saveSettings(); |
— | — | @@ -429,14 +429,14 @@ |
430 | 430 | * @param $template UserLoginTemplate object. |
431 | 431 | * @public |
432 | 432 | */ |
433 | | - function modifyUITemplate(&$template) { |
434 | | - //disable the mail new password box |
435 | | - $template->set('useemail', false); |
436 | | - //disable 'remember me' box |
437 | | - $template->set('remember', false); |
438 | | - $template->set('create', false); |
439 | | - $template->set('domain', false); |
440 | | - $template->set('usedomain', false); |
| 433 | + function modifyUITemplate( &$template ) { |
| 434 | + // disable the mail new password box |
| 435 | + $template->set( 'useemail', false ); |
| 436 | + // disable 'remember me' box |
| 437 | + $template->set( 'remember', false ); |
| 438 | + $template->set( 'create', false ); |
| 439 | + $template->set( 'domain', false ); |
| 440 | + $template->set( 'usedomain', false ); |
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
— | — | @@ -447,11 +447,11 @@ |
448 | 448 | * @return string |
449 | 449 | * @public |
450 | 450 | */ |
451 | | - function getCanonicalName($username) { |
| 451 | + function getCanonicalName( $username ) { |
452 | 452 | // lowercase the username |
453 | | - $username = strtolower($username); |
| 453 | + $username = strtolower( $username ); |
454 | 454 | // uppercase first letter to make MediaWiki happy |
455 | | - $username = ucfirst($username); |
| 455 | + $username = ucfirst( $username ); |
456 | 456 | return $username; |
457 | 457 | } |
458 | 458 | } |