r46092 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46091‎ | r46092 | r46093 >
Date:19:25, 23 January 2009
Author:ialex
Status:ok
Tags:
Comment:
* Tweak for r46027: fix E_ERROR
* Whitespaces fixes
Modified paths:
  • /trunk/extensions/OpenID/SpecialOpenID.body.php (modified) (history)
  • /trunk/extensions/OpenID/SpecialOpenIDFinish.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenID/SpecialOpenID.body.php
@@ -90,27 +90,29 @@
9191 static function getUserUrl($user) {
9292 $openid_url = null;
9393
94 - if (isset($user) && $user->getId() != 0) {
 94+ if ( isset( $user ) && $user->getId() != 0 ) {
9595 global $wgSharedDB, $wgDBprefix;
96 - if (isset($wgSharedDB)) {
 96+ if ( isset( $wgSharedDB ) ) {
9797 $tableName = "`${wgSharedDB}`.${wgDBprefix}user_openid";
9898 } else {
9999 $tableName = 'user_openid';
100100 }
101101
102 - $dbr =& wfGetDB( DB_SLAVE );
103 - $res = $dbr->select(array($tableName),
104 - array('uoi_openid'),
105 - array('uoi_user' => $user->getId()),
106 - 'OpenIDGetUserUrl');
 102+ $dbr = wfGetDB( DB_SLAVE );
 103+ $res = $dbr->select(
 104+ array( $tableName ),
 105+ array( 'uoi_openid' ),
 106+ array( 'uoi_user' => $user->getId() ),
 107+ __METHOD__
 108+ );
107109
108110 # This should return 0 or 1 result, since user is unique
109111 # in the table.
110112
111 - while ($res && $row = $dbr->fetchObject($res)) {
 113+ while ( $row = $res->fetchObject() ) {
112114 $openid_url = $row->uoi_openid;
113115 }
114 - $dbr->freeResult($res);
 116+ $res->free();
115117 }
116118 return $openid_url;
117119 }
Index: trunk/extensions/OpenID/SpecialOpenIDFinish.body.php
@@ -35,7 +35,7 @@
3636 SpecialPage::SpecialPage("OpenIDFinish", '', false);
3737 }
3838
39 - function execute($par) {
 39+ function execute( $par) {
4040
4141 global $wgUser, $wgOut, $wgRequest;
4242
@@ -45,58 +45,59 @@
4646
4747 # Shouldn't work if you're already logged in.
4848
49 - if ($wgUser->getID() != 0) {
 49+ if ( $wgUser->getID() != 0 ) {
5050 $this->alreadyLoggedIn();
5151 return;
5252 }
5353
5454 $consumer = $this->getConsumer();
5555
56 - switch ($par) {
 56+ switch ( $par ) {
5757 case 'ChooseName':
58 - list($openid, $sreg) = $this->fetchValues();
59 - if (!isset($openid)) {
60 - wfDebug("OpenID: aborting in ChooseName because identity_url is missing\n");
 58+ list( $openid, $sreg) = $this->fetchValues();
 59+ if ( !isset( $openid ) ) {
 60+ wfDebug( "OpenID: aborting in ChooseName because identity_url is missing\n" );
6161 $this->clearValues();
6262 # No messing around, here
63 - $wgOut->showErrorPage('openiderror', 'openiderrortext');
 63+ $wgOut->showErrorPage( 'openiderror', 'openiderrortext' );
6464 return;
6565 }
6666
67 - if ($wgRequest->getCheck('wpCancel')) {
 67+ if ( $wgRequest->getCheck( 'wpCancel' ) ) {
6868 $this->clearValues();
69 - $wgOut->showErrorPage('openidcancel', 'openidcanceltext');
 69+ $wgOut->showErrorPage( 'openidcancel', 'openidcanceltext' );
7070 return;
7171 }
7272
73 - $choice = $wgRequest->getText('wpNameChoice');
74 - $nameValue = $wgRequest->getText('wpNameValue');
 73+ $choice = $wgRequest->getText( 'wpNameChoice' );
 74+ $nameValue = $wgRequest->getText( 'wpNameValue' );
7575
7676 if ($choice == 'existing') {
77 - $user = $this->attachUser($openid, $sreg,
78 - $wgRequest->getText('wpExistingName'),
79 - $wgRequest->getText('wpExistingPassword'));
 77+ $user = $this->attachUser( $openid, $sreg,
 78+ $wgRequest->getText( 'wpExistingName' ),
 79+ $wgRequest->getText( 'wpExistingPassword' )
 80+ );
8081
81 - if (!$user) {
82 - $this->chooseNameForm($openid, $sreg, 'wrongpassword');
 82+ if ( !$user ) {
 83+ $this->chooseNameForm( $openid, $sreg, 'wrongpassword' );
8384 return;
8485 }
8586 } else {
86 - $name = $this->getUserName($openid, $sreg, $choice, $nameValue);
 87+ $name = $this->getUserName( $openid, $sreg, $choice, $nameValue);
8788
88 - if (!$name || !$this->userNameOK($name)) {
89 - wfDebug("OpenID: Name not OK: '$name'\n");
90 - $this->chooseNameForm($openid, $sreg);
 89+ if ( !$name || !$this->userNameOK( $name ) ) {
 90+ wfDebug( "OpenID: Name not OK: '$name'\n" );
 91+ $this->chooseNameForm( $openid, $sreg );
9192 return;
9293 }
9394
94 - $user = $this->createUser($openid, $sreg, $name);
 95+ $user = $this->createUser( $openid, $sreg, $name );
9596 }
9697
97 - if (!isset($user)) {
98 - wfDebug("OpenID: aborting in ChooseName because we could not create user object\n");
 98+ if ( !isset( $user ) ) {
 99+ wfDebug( "OpenID: aborting in ChooseName because we could not create user object\n" );
99100 $this->clearValues();
100 - $wgOut->showErrorPage('openiderror', 'openiderrortext');
 101+ $wgOut->showErrorPage( 'openiderror', 'openiderrortext' );
101102 return;
102103 }
103104
@@ -104,71 +105,70 @@
105106
106107 $this->clearValues();
107108
108 - $this->finishLogin($response->identity_url);
 109+ $this->finishLogin( $response->identity_url );
109110 break;
110111
111112 default: # No parameter, returning from a server
112113
113 - $response = $consumer->complete($this->scriptUrl('OpenIDFinish'));
 114+ $response = $consumer->complete( $this->scriptUrl( 'OpenIDFinish' ) );
114115
115 - if (!isset($response)) {
116 - wfDebug("OpenID: aborting in auth because no response was recieved\n");
117 - $wgOut->showErrorPage('openiderror', 'openiderrortext');
 116+ if ( !isset( $response ) ) {
 117+ wfDebug( "OpenID: aborting in auth because no response was recieved\n" );
 118+ $wgOut->showErrorPage( 'openiderror', 'openiderrortext' );
118119 return;
119120 }
120121
121 - switch ($response->status) {
 122+ switch ( $response->status ) {
122123 case Auth_OpenID_CANCEL:
123124 // This means the authentication was cancelled.
124 - $wgOut->showErrorPage('openidcancel', 'openidcanceltext');
 125+ $wgOut->showErrorPage( 'openidcancel', 'openidcanceltext' );
125126 break;
126127 case Auth_OpenID_FAILURE:
127 - wfDebug("OpenID: error message '" . $response->message . "'\n");
128 - $wgOut->showErrorPage('openidfailure', 'openidfailuretext',
129 - array(($response->message) ? $response->message : ''));
 128+ wfDebug( "OpenID: error message '" . $response->message . "'\n" );
 129+ $wgOut->showErrorPage( 'openidfailure', 'openidfailuretext',
 130+ array( ( $response->message ) ? $response->message : '' ) );
130131 break;
131132 case Auth_OpenID_SUCCESS:
132133 // This means the authentication succeeded.
133134 $openid = $response->getDisplayIdentifier();
134 - $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
 135+ $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse( $response );
135136 $sreg = $sreg_resp->contents();
136137
137138 if (!isset($openid)) {
138 - wfDebug("OpenID: aborting in auth success because display identifier is missing\n");
139 - $wgOut->showErrorPage('openiderror', 'openiderrortext');
 139+ wfDebug( "OpenID: aborting in auth success because display identifier is missing\n" );
 140+ $wgOut->showErrorPage( 'openiderror', 'openiderrortext' );
140141 return;
141142 }
142143
143 - $user = $this->getUser($openid);
 144+ $user = $this->getUser( $openid );
144145
145 - if (isset($user)) {
146 - $this->updateUser($user, $sreg); # update from server
 146+ if ( isset( $user ) ) {
 147+ $this->updateUser( $user, $sreg ); # update from server
147148 } else {
148149 # For easy names
149 - $name = $this->createName($openid, $sreg);
150 - if ($name) {
151 - $user = $this->createUser($openid, $sreg, $name);
 150+ $name = $this->createName( $openid, $sreg );
 151+ if ( $name ) {
 152+ $user = $this->createUser( $openid, $sreg, $name );
152153 } else {
153154 # For hard names
154 - $this->saveValues($openid, $sreg);
155 - $this->chooseNameForm($openid, $sreg);
 155+ $this->saveValues( $openid, $sreg );
 156+ $this->chooseNameForm( $openid, $sreg );
156157 return;
157158 }
158159 }
159160
160 - if (!isset($user)) {
161 - wfDebug("OpenID: aborting in auth success because we could not create user object\n");
162 - $wgOut->showErrorPage('openiderror', 'openiderrortext');
 161+ if ( !isset( $user ) ) {
 162+ wfDebug( "OpenID: aborting in auth success because we could not create user object\n" );
 163+ $wgOut->showErrorPage( 'openiderror', 'openiderrortext' );
163164 } else {
164165 $wgUser = $user;
165 - $this->finishLogin($openid);
 166+ $this->finishLogin( $openid );
166167 }
167168 }
168169 }
169170 }
170171
171 - function finishLogin($openid) {
172 -
 172+ function finishLogin( $openid ) {
173173 global $wgUser, $wgOut;
174174
175175 $wgUser->SetupSession();
@@ -187,37 +187,37 @@
188188 $wgOut->setArticleRelated( false );
189189 $wgOut->addWikiText( wfMsg( 'openidsuccess', $wgUser->getName(), $openid ) );
190190 $wgOut->addHtml( $inject_html );
191 - $wgOut->returnToMain(false, $this->returnTo());
 191+ $wgOut->returnToMain( false, $this->returnTo() );
192192 }
193193
194 - function loginSetCookie($openid) {
 194+ function loginSetCookie( $openid ) {
195195 global $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookiePrefix;
196196 global $wgOpenIDCookieExpiration;
197197
198198 $exp = time() + $wgOpenIDCookieExpiration;
199199
200 - setcookie($wgCookiePrefix.'OpenID', $openid, $exp, $wgCookiePath, $wgCookieDomain, $wgCookieSecure);
 200+ setcookie( $wgCookiePrefix.'OpenID', $openid, $exp, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
201201 }
202202
203 - function chooseNameForm($openid, $sreg, $messagekey = NULL) {
 203+ function chooseNameForm( $openid, $sreg, $messagekey = NULL ) {
204204
205205 global $wgOut, $wgUser, $wgOpenIDOnly;
206206
207207 $sk = $wgUser->getSkin();
208208 if ($messagekey) {
209 - $message = wfMsg($messagekey);
210 - } else if (array_key_exists('nickname', $sreg)) {
211 - $message = wfMsg('openidnotavailable', $sreg['nickname']);
 209+ $message = wfMsg( $messagekey );
 210+ } else if ( array_key_exists( 'nickname', $sreg ) ) {
 211+ $message = wfMsg( 'openidnotavailable', $sreg['nickname'] );
212212 } else {
213 - $message = wfMsg('openidnotprovided');
 213+ $message = wfMsg( 'openidnotprovided' );
214214 }
215 - $instructions = wfMsg('openidchooseinstructions');
216 - $wgOut->addHTML("<p>{$message}</p>" .
217 - "<p>{$instructions}</p>" .
218 - '<form action="' . $sk->makeSpecialUrl('OpenIDFinish/ChooseName') . '" method="POST">');
 215+ $instructions = wfMsg( 'openidchooseinstructions' );
 216+ $wgOut->addHTML( "<p>{$message}</p>" .
 217+ "<p>{$instructions}</p>" .
 218+ '<form action="' . $sk->makeSpecialUrl( 'OpenIDFinish/ChooseName' ) . '" method="POST">' );
219219 $def = false;
220220
221 - if (!$wgOpenIDOnly) {
 221+ if ( !$wgOpenIDOnly ) {
222222 # Let them attach it to an existing user
223223
224224 # Grab the UserName in the cookie if it exists
@@ -229,67 +229,66 @@
230230 }
231231
232232 $wgOut->addHTML("<input type='radio' name='wpNameChoice' id='wpNameChoiceExisting' value='existing' /> " .
233 - "<label for='wpNameChoiceExisting'>" . wfMsg("openidchooseexisting") . "</label> " .
 233+ "<label for='wpNameChoiceExisting'>" . wfMsg( "openidchooseexisting" ) . "</label> " .
234234 "<input type='text' name='wpExistingName' id='wpExistingName' size='16' value='{$name}'> " .
235 - "<label for='wpExistingPassword'>" . wfMsg("openidchoosepassword") . "</label> " .
236 - "<input type='password' name='wpExistingPassword' size='8' /><br />");
 235+ "<label for='wpExistingPassword'>" . wfMsg( "openidchoosepassword" ) . "</label> " .
 236+ "<input type='password' name='wpExistingPassword' size='8' /><br />" );
237237 }
238238
239239 # These options won't exist if we can't get them.
240240
241 - if (array_key_exists('fullname', $sreg) && $this->userNameOK($sreg['fullname'])) {
242 - $wgOut->addHTML("<input type='radio' name='wpNameChoice' id='wpNameChoiceFull' value='full' " .
243 - ((!$def) ? "checked = 'checked'" : "") . " />" .
244 - "<label for='wpNameChoiceFull'>" . wfMsg("openidchoosefull", $sreg['fullname']) . "</label><br />");
 241+ if ( array_key_exists( 'fullname', $sreg ) && $this->userNameOK( $sreg['fullname'] ) ) {
 242+ $wgOut->addHTML( "<input type='radio' name='wpNameChoice' id='wpNameChoiceFull' value='full' " .
 243+ ( ( !$def ) ? "checked = 'checked'" : "" ) . " />" .
 244+ "<label for='wpNameChoiceFull'>" . wfMsg( "openidchoosefull", $sreg['fullname'] ) . "</label><br />" );
245245 $def = true;
246246 }
247247
248 - $idname = $this->toUserName($openid);
 248+ $idname = $this->toUserName( $openid );
249249
250 - if ($idname && $this->userNameOK($idname)) {
251 - $wgOut->addHTML("<input type='radio' name='wpNameChoice' id='wpNameChoiceUrl' value='url' " .
252 - ((!$def) ? "checked = 'checked'" : "") . " />" .
253 - "<label for='wpNameChoiceUrl'>" . wfMsg("openidchooseurl", $idname) . "</label><br />");
 250+ if ( $idname && $this->userNameOK( $idname ) ) {
 251+ $wgOut->addHTML( "<input type='radio' name='wpNameChoice' id='wpNameChoiceUrl' value='url' " .
 252+ ( ( !$def ) ? "checked = 'checked'" : "" ) . " />" .
 253+ "<label for='wpNameChoiceUrl'>" . wfMsg( "openidchooseurl", $idname ) . "</label><br />" );
254254 $def = true;
255255 }
256256
257257 # These are always available
258258
259 - $wgOut->addHTML("<input type='radio' name='wpNameChoice' id='wpNameChoiceAuto' value='auto' " .
260 - ((!$def) ? "checked = 'checked'" : "") . " />" .
261 - "<label for='wpNameChoiceAuto'>" . wfMsg("openidchooseauto", $this->automaticName($sreg)) . "</label><br />");
 259+ $wgOut->addHTML( "<input type='radio' name='wpNameChoice' id='wpNameChoiceAuto' value='auto' " .
 260+ ( ( !$def ) ? "checked = 'checked'" : "" ) . " />" .
 261+ "<label for='wpNameChoiceAuto'>" . wfMsg( "openidchooseauto", $this->automaticName( $sreg ) ) . "</label><br />");
262262
263263 $def = true;
264264
265265 $wgOut->addHTML("<input type='radio' name='wpNameChoice' id='wpNameChoiceManual' value='manual' " .
266266 " checked='off' />" .
267 - "<label for='wpNameChoiceManual'>" . wfMsg("openidchoosemanual") . "</label> " .
 267+ "<label for='wpNameChoiceManual'>" . wfMsg( "openidchoosemanual" ) . "</label> " .
268268 "<input type='text' name='wpNameValue' id='wpNameValue' size='16' /><br />");
269269
270 - $ok = wfMsg('login');
271 - $cancel = wfMsg('cancel');
 270+ $ok = wfMsg( 'login' );
 271+ $cancel = wfMsg( 'cancel' );
272272
273 - $wgOut->addHTML("<input type='submit' name='wpOK' value='{$ok}' /> <input type='submit' name='wpCancel' value='{$cancel}' />");
274 - $wgOut->addHTML("</form>");
 273+ $wgOut->addHTML( "<input type='submit' name='wpOK' value='{$ok}' /> <input type='submit' name='wpCancel' value='{$cancel}' />" );
 274+ $wgOut->addHTML( "</form>" );
275275 }
276276
277 - function canLogin($openid_url) {
278 -
 277+ function canLogin( $openid_url ) {
279278 global $wgOpenIDConsumerDenyByDefault, $wgOpenIDConsumerAllow, $wgOpenIDConsumerDeny;
280279
281 - if ($this->isLocalUrl($openid_url)) {
 280+ if ( $this->isLocalUrl( $openid_url ) ) {
282281 return false;
283282 }
284283
285 - if ($wgOpenIDConsumerDenyByDefault) {
 284+ if ( $wgOpenIDConsumerDenyByDefault ) {
286285 $canLogin = false;
287 - foreach ($wgOpenIDConsumerAllow as $allow) {
288 - if (preg_match($allow, $openid_url)) {
289 - wfDebug("OpenID: $openid_url matched allow pattern $allow.\n");
 286+ foreach ( $wgOpenIDConsumerAllow as $allow ) {
 287+ if ( preg_match( $allow, $openid_url ) ) {
 288+ wfDebug( "OpenID: $openid_url matched allow pattern $allow.\n" );
290289 $canLogin = true;
291 - foreach ($wgOpenIDConsumerDeny as $deny) {
292 - if (preg_match($deny, $openid_url)) {
293 - wfDebug("OpenID: $openid_url matched deny pattern $deny.\n");
 290+ foreach ( $wgOpenIDConsumerDeny as $deny ) {
 291+ if ( preg_match( $deny, $openid_url ) ) {
 292+ wfDebug( "OpenID: $openid_url matched deny pattern $deny.\n" );
294293 $canLogin = false;
295294 break;
296295 }
@@ -299,13 +298,13 @@
300299 }
301300 } else {
302301 $canLogin = true;
303 - foreach ($wgOpenIDConsumerDeny as $deny) {
304 - if (preg_match($deny, $openid_url)) {
305 - wfDebug("OpenID: $openid_url matched deny pattern $deny.\n");
 302+ foreach ( $wgOpenIDConsumerDeny as $deny ) {
 303+ if ( preg_match( $deny, $openid_url ) ) {
 304+ wfDebug( "OpenID: $openid_url matched deny pattern $deny.\n" );
306305 $canLogin = false;
307 - foreach ($wgOpenIDConsumerAllow as $allow) {
308 - if (preg_match($allow, $openid_url)) {
309 - wfDebug("OpenID: $openid_url matched allow pattern $allow.\n");
 306+ foreach ( $wgOpenIDConsumerAllow as $allow ) {
 307+ if ( preg_match( $allow, $openid_url ) ) {
 308+ wfDebug( "OpenID: $openid_url matched allow pattern $allow.\n" );
310309 $canLogin = true;
311310 break;
312311 }
@@ -317,40 +316,43 @@
318317 return $canLogin;
319318 }
320319
321 - function isLocalUrl($url) {
322 -
 320+ function isLocalUrl( $url ) {
323321 global $wgServer, $wgArticlePath;
324322
325323 $pattern = $wgServer . $wgArticlePath;
326 - $pattern = str_replace('$1', '(.*)', $pattern);
327 - $pattern = str_replace('?', '\?', $pattern);
 324+ $pattern = str_replace( '$1', '(.*)', $pattern );
 325+ $pattern = str_replace( '?', '\?', $pattern );
328326
329 - return preg_match('|^' . $pattern . '$|', $url);
 327+ return preg_match( '|^' . $pattern . '$|', $url );
330328 }
331329
332330 # Find the user with the given openid, if any
333331
334 - function getUser($openid) {
 332+ function getUser( $openid ) {
335333 global $wgSharedDB, $wgDBprefix;
336334
337 - if (isset($wgSharedDB)) {
 335+ if ( isset( $wgSharedDB ) ) {
338336 $tableName = "`$wgSharedDB`.${wgDBprefix}user_openid";
339337 } else {
340338 $tableName = 'user_openid';
341339 }
342340
343 - $dbr =& wfGetDB( DB_SLAVE );
344 - $id = $dbr->selectField($tableName, 'uoi_user',
345 - array('uoi_openid' => $openid));
346 - if ($id) {
347 - $name = User::whoIs($id);
348 - return User::newFromName($name);
 341+ $dbr = wfGetDB( DB_SLAVE );
 342+ $id = $dbr->selectField(
 343+ $tableName,
 344+ 'uoi_user',
 345+ array( 'uoi_openid' => $openid ),
 346+ __METHOD__
 347+ );
 348+ if ( $id ) {
 349+ $name = User::whoIs( $id );
 350+ return User::newFromName( $name );
349351 } else {
350352 return NULL;
351353 }
352354 }
353355
354 - function updateUser($user, $sreg) {
 356+ function updateUser( $user, $sreg ) {
355357 global $wgAllowRealName;
356358
357359 # FIXME: only update if there's been a change
@@ -541,33 +543,35 @@
542544 $wgOut->setRobotPolicy( 'noindex,nofollow' );
543545 $wgOut->setArticleRelated( false );
544546 $wgOut->addWikiText( wfMsg( 'openidalreadyloggedin', $wgUser->getName() ) );
545 - $wgOut->returnToMain(false, $this->returnTo() );
 547+ $wgOut->returnToMain( false, $this->returnTo() );
546548 }
547549
548 - function getUserUrl($user) {
 550+ static function getUserUrl( $user ) {
549551 $openid_url = null;
550552
551 - if (isset($user) && $user->getId() != 0) {
 553+ if ( isset( $user ) && $user->getId() != 0 ) {
552554 global $wgSharedDB, $wgDBprefix;
553 - if (isset($wgSharedDB)) {
 555+ if ( isset( $wgSharedDB ) ) {
554556 $tableName = "`${wgSharedDB}`.${wgDBprefix}user_openid";
555557 } else {
556558 $tableName = 'user_openid';
557559 }
558560
559 - $dbr =& wfGetDB( DB_SLAVE );
560 - $res = $dbr->select(array($tableName),
561 - array('uoi_openid'),
562 - array('uoi_user' => $user->getId()),
563 - 'SpecialOpenIDFinish::getUserUrl');
 561+ $dbr = wfGetDB( DB_SLAVE );
 562+ $res = $dbr->select(
 563+ array( $tableName ),
 564+ array( 'uoi_openid' ),
 565+ array( 'uoi_user' => $user->getId() ),
 566+ __METHOD__
 567+ );
564568
565569 # This should return 0 or 1 result, since user is unique
566570 # in the table.
567571
568 - while ($res && $row = $dbr->fetchObject($res)) {
 572+ while ( $row = $res->fetchObject() ) {
569573 $openid_url = $row->uoi_openid;
570574 }
571 - $dbr->freeResult($res);
 575+ $res->free();
572576 }
573577 return $openid_url;
574578 }
@@ -586,13 +590,13 @@
587591 }
588592
589593 function clearValues() {
590 - unset($_SESSION['openid_consumer_identity']);
591 - unset($_SESSION['openid_consumer_sreg']);
 594+ unset( $_SESSION['openid_consumer_identity'] );
 595+ unset( $_SESSION['openid_consumer_sreg'] );
592596 return true;
593597 }
594598
595599 function fetchValues() {
596 - return array($_SESSION['openid_consumer_identity'], $_SESSION['openid_consumer_sreg']);
 600+ return array( $_SESSION['openid_consumer_identity'], $_SESSION['openid_consumer_sreg'] );
597601 }
598602
599603 function returnTo() {
@@ -604,15 +608,15 @@
605609 }
606610
607611 function getUserName($openid, $sreg, $choice, $nameValue) {
608 - switch ($choice) {
 612+ switch ( $choice ) {
609613 case 'full':
610 - return ((array_key_exists('fullname', $sreg)) ? $sreg['fullname'] : null);
 614+ return ( ( array_key_exists( 'fullname', $sreg ) ) ? $sreg['fullname'] : null );
611615 break;
612616 case 'url':
613 - return $this->toUserName($openid);
 617+ return $this->toUserName( $openid );
614618 break;
615619 case 'auto':
616 - return $this->automaticName($sreg);
 620+ return $this->automaticName( $sreg );
617621 break;
618622 case 'manual':
619623 return $nameValue;
@@ -621,29 +625,29 @@
622626 }
623627 }
624628
625 - function automaticName($sreg) {
626 - if (array_key_exists('nickname', $sreg) && # try auto-generated from nickname
627 - strlen($sreg['nickname']) > 0) {
628 - return $this->firstAvailable($sreg['nickname']);
 629+ function automaticName( $sreg ) {
 630+ if ( array_key_exists( 'nickname', $sreg ) && # try auto-generated from nickname
 631+ strlen( $sreg['nickname']) > 0 ) {
 632+ return $this->firstAvailable( $sreg['nickname'] );
629633 } else { # try auto-generated
630 - return $this->firstAvailable(wfMsg('openidusernameprefix'));
 634+ return $this->firstAvailable( wfMsg( 'openidusernameprefix' ) );
631635 }
632636 }
633637
634 - function attachUser($openid, $sreg, $name, $password) {
 638+ function attachUser( $openid, $sreg, $name, $password ) {
635639
636 - $user = User::newFromName($name);
 640+ $user = User::newFromName( $name );
637641
638 - if (!$user) {
 642+ if ( !$user ) {
639643 return NULL;
640644 }
641645
642 - if (!$user->checkPassword($password)) {
 646+ if ( !$user->checkPassword( $password ) ) {
643647 return NULL;
644648 }
645649
646 - $this->setUserUrl($user, $openid);
647 - $this->updateUser($user, $sreg);
 650+ $this->setUserUrl( $user, $openid );
 651+ $this->updateUser( $user, $sreg );
648652
649653 return $user;
650654 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r46027E_STRICTialex16:48, 22 January 2009

Status & tagging log