Index: trunk/extensions/OpenID/OpenID.i18n.php |
— | — | @@ -63,15 +63,16 @@ |
64 | 64 | 'openidemail' => 'E-mail address', |
65 | 65 | 'openidlanguage' => 'Language', |
66 | 66 | 'openidtimezone' => 'Time zone', |
67 | | - 'openidnotavailable' => 'Your preferred nickname ($1) is already in use by another user.', |
68 | | - 'openidnotprovided' => 'Your OpenID server did not provide a nickname (either because it cannot, or because you told it not to).', |
| 67 | + 'openidchooselegend' => 'Username choice', |
69 | 68 | 'openidchooseinstructions' => 'All users need a nickname; |
70 | 69 | you can choose one from the options below.', |
| 70 | + 'openidchoosenick' => 'Your nickname ($1)', |
71 | 71 | 'openidchoosefull' => 'Your full name ($1)', |
72 | 72 | 'openidchooseurl' => 'A name picked from your OpenID ($1)', |
73 | 73 | 'openidchooseauto' => 'An auto-generated name ($1)', |
74 | 74 | 'openidchoosemanual' => 'A name of your choice:', |
75 | | - 'openidchooseexisting' => 'An existing account on this wiki:', |
| 75 | + 'openidchooseexisting' => 'An existing account on this wiki', |
| 76 | + 'openidchooseusername' => 'username:', |
76 | 77 | 'openidchoosepassword' => 'password:', |
77 | 78 | 'openidconvertinstructions' => 'This form lets you change your user account to use an OpenID URL or add more OpenID URLs', |
78 | 79 | 'openidconvertoraddmoreids' => 'Convert to OpenID or add another OpenID URL', |
— | — | @@ -96,7 +97,7 @@ |
97 | 98 | To use OpenID in the future, you can [[Special:OpenIDConvert|convert your account to OpenID]] after you have logged in normally. |
98 | 99 | |
99 | 100 | There are many [http://openid.net/get/ OpenID providers], and you may already have an OpenID-enabled account on another service.', |
100 | | - 'openidupdateuserinfo' => 'Update my personal information', |
| 101 | + 'openidupdateuserinfo' => 'Update my personal information:', |
101 | 102 | |
102 | 103 | 'openiddelete' => 'Delete OpenID', |
103 | 104 | 'openiddelete-text' => 'By clicking the "{{int:openiddelete-button}}" button, you will remove the OpenID $1 from your account. |
Index: trunk/extensions/OpenID/SpecialOpenIDLogin.body.php |
— | — | @@ -172,16 +172,14 @@ |
173 | 173 | |
174 | 174 | if ( $messagekey ) { |
175 | 175 | $wgOut->addWikiMsg( $messagekey ); |
176 | | - } else if ( array_key_exists( 'nickname', $sreg ) ) { |
177 | | - $wgOut->addWikiMsg( 'openidnotavailable', $sreg['nickname'] ); |
178 | | - } else { |
179 | | - $wgOut->addWikiMsg( 'openidnotprovided' ); |
180 | 176 | } |
181 | 177 | $wgOut->addWikiMsg( 'openidchooseinstructions' ); |
182 | 178 | |
183 | 179 | $wgOut->addHTML( |
184 | 180 | Xml::openElement( 'form', |
185 | | - array( 'action' => $this->getTitle( 'ChooseName' )->getLocalUrl(), 'method' => 'POST' ) ) . "\n" |
| 181 | + array( 'action' => $this->getTitle( 'ChooseName' )->getLocalUrl(), 'method' => 'POST' ) ) . "\n" . |
| 182 | + Xml::fieldset( wfMsg( 'openidchooselegend' ), false, array( 'id' => 'mw-openid-choosename' ) ) . "\n" . |
| 183 | + Xml::openElement( 'table' ) |
186 | 184 | ); |
187 | 185 | $def = false; |
188 | 186 | |
— | — | @@ -206,37 +204,67 @@ |
207 | 205 | } |
208 | 206 | |
209 | 207 | if ( array_key_exists( $oidAttr, $sreg ) ) { |
210 | | - $oidAttributes[] = Xml::tags( 'div', array(), wfMsgHtml( "openid$oidAttr" ) . ': ' . Xml::tags( 'i', array(), $sreg[$oidAttr] ) ); |
| 208 | + $checkName = 'wpUpdateUserInfo' . $oidAttr; |
| 209 | + $oidAttributes[] = Xml::tags( 'li', array(), |
| 210 | + Xml::check( $checkName, false, array( 'id' => $checkName ) ) . |
| 211 | + Xml::tags( 'label', array( 'for' => $checkName ), |
| 212 | + wfMsgHtml( "openid$oidAttr" ) . wfMsgExt( 'colon-separator', array( 'escapenoentities' ) ) . |
| 213 | + Xml::tags( 'i', array(), $sreg[$oidAttr] ) |
| 214 | + ) |
| 215 | + ); |
211 | 216 | } |
212 | 217 | } |
213 | 218 | |
214 | 219 | $oidAttributesUpdate = ''; |
215 | 220 | if ( count( $oidAttributes ) > 0 ) { |
216 | | - $oidAttributesUpdate = Xml::openElement( 'div', array( 'style' => 'margin-left: 25px' ) ) . "\n" . |
217 | | - Xml::check( 'wpUpdateUserInfo', false, array( 'id' => 'wpUpdateUserInfo' ) ) . "\n" . |
218 | | - Xml::openElement( 'label', array( 'for' => 'wpUpdateUserInfo' ) ) . |
219 | | - wfMsgHtml( 'openidupdateuserinfo' ) . |
220 | | - Xml::tags( 'div', array( 'style' => 'margin-left: 25px' ), implode( "\n", $oidAttributes ) ) . |
221 | | - Xml::closeElement( 'label' ) . Xml::closeElement( 'div' ); |
| 221 | + $oidAttributesUpdate = "<br />\n" . |
| 222 | + wfMsgHtml( 'openidupdateuserinfo' ) . "\n" . |
| 223 | + Xml::tags( 'ul', array(), implode( "\n", $oidAttributes ) ); |
222 | 224 | } |
223 | 225 | |
224 | 226 | $wgOut->addHTML( |
225 | | - Xml::openElement( 'div' ) . |
226 | | - Xml::radioLabel( wfMsg( 'openidchooseexisting' ), 'wpNameChoice', 'existing', 'wpNameChoiceExisting' ) . "\n" . |
227 | | - Xml::input( 'wpExistingName', 16, $name, array( 'id' => 'wpExistingName' ) ) . "\n" . |
228 | | - wfMsgHtml( 'openidchoosepassword' ) . "\n" . |
229 | | - Xml::password( 'wpExistingPassword' ) . "\n" . |
230 | | - $oidAttributesUpdate . "\n" . |
231 | | - Xml::closeElement( 'div' ) |
| 227 | + Xml::openElement( 'tr' ) . |
| 228 | + Xml::tags( 'td', array( 'class' => 'mw-label' ), |
| 229 | + Xml::radio( 'wpNameChoice', 'existing', false, array( 'id' => 'wpNameChoiceExisting' ) ) |
| 230 | + ) . "\n" . |
| 231 | + Xml::tags( 'td', array( 'class' => 'mw-input' ), |
| 232 | + Xml::label( wfMsg( 'openidchooseexisting' ), 'wpNameChoiceExisting' ) . "<br />\n" . |
| 233 | + wfMsgHtml( 'openidchooseusername' ) . "\n" . |
| 234 | + Xml::input( 'wpExistingName', 16, $name, array( 'id' => 'wpExistingName' ) ) . "\n" . |
| 235 | + wfMsgHtml( 'openidchoosepassword' ) . "\n" . |
| 236 | + Xml::password( 'wpExistingPassword' ) . "\n" . |
| 237 | + $oidAttributesUpdate . "\n" |
| 238 | + ) . "\n" . |
| 239 | + Xml::closeElement( 'tr' ) . "\n" |
232 | 240 | ); |
233 | 241 | } |
234 | 242 | |
235 | 243 | # These options won't exist if we can't get them. |
| 244 | + if ( array_key_exists( 'nickname', $sreg ) && $this->userNameOK( $sreg['nickname'] ) ) { |
| 245 | + $wgOut->addHTML( |
| 246 | + Xml::openElement( 'tr' ) . |
| 247 | + Xml::tags( 'td', array( 'class' => 'mw-label' ), |
| 248 | + Xml::radio( 'wpNameChoice', 'nick', !$def, array( 'id' => 'wpNameChoiceNick' ) ) |
| 249 | + ) . |
| 250 | + Xml::tags( 'td', array( 'class' => 'mw-input' ), |
| 251 | + Xml::label( wfMsg( 'openidchoosenick', $sreg['nickname'] ), 'wpNameChoiceNick' ) |
| 252 | + ) . |
| 253 | + Xml::closeElement( 'tr' ) . "\n" |
| 254 | + ); |
| 255 | + $def = true; |
| 256 | + } |
| 257 | + |
| 258 | + # These options won't exist if we can't get them. |
236 | 259 | if ( array_key_exists( 'fullname', $sreg ) && $this->userNameOK( $sreg['fullname'] ) ) { |
237 | 260 | $wgOut->addHTML( |
238 | | - Xml::openElement( 'div' ) . |
239 | | - Xml::radioLabel( wfMsg( 'openidchoosefull', $sreg['fullname'] ), 'wpNameChoice', 'full', 'wpNameChoiceFull', !$def ) . |
240 | | - Xml::closeElement( 'div' ) |
| 261 | + Xml::openElement( 'tr' ) . |
| 262 | + Xml::tags( 'td', array( 'class' => 'mw-label' ), |
| 263 | + Xml::radio( 'wpNameChoice', 'full', !$def, array( 'id' => 'wpNameChoiceFull' ) ) |
| 264 | + ) . |
| 265 | + Xml::tags( 'td', array( 'class' => 'mw-input' ), |
| 266 | + Xml::label( wfMsg( 'openidchoosefull', $sreg['fullname'] ), 'wpNameChoiceFull' ) |
| 267 | + ) . |
| 268 | + Xml::closeElement( 'tr' ) . "\n" |
241 | 269 | ); |
242 | 270 | $def = true; |
243 | 271 | } |
— | — | @@ -244,23 +272,49 @@ |
245 | 273 | $idname = $this->toUserName( $openid ); |
246 | 274 | if ( $idname && $this->userNameOK( $idname ) ) { |
247 | 275 | $wgOut->addHTML( |
248 | | - Xml::openElement( 'div' ) . |
249 | | - Xml::radioLabel( wfMsg( 'openidchooseurl', $idname ), 'wpNameChoice', 'url', 'wpNameChoiceUrl', !$def ) . |
250 | | - Xml::closeElement( 'div' ) |
| 276 | + Xml::openElement( 'tr' ) . |
| 277 | + Xml::tags( 'td', array( 'class' => 'mw-label' ), |
| 278 | + Xml::radio( 'wpNameChoice', 'url', !$def, array( 'id' => 'wpNameChoiceUrl' ) ) |
| 279 | + ) . |
| 280 | + Xml::tags( 'td', array( 'class' => 'mw-input' ), |
| 281 | + Xml::label( wfMsg( 'openidchooseurl', $idname ), 'wpNameChoiceUrl' ) |
| 282 | + ) . |
| 283 | + Xml::closeElement( 'tr' ) . "\n" |
251 | 284 | ); |
252 | 285 | $def = true; |
253 | 286 | } |
254 | 287 | |
255 | 288 | # These are always available |
256 | 289 | $wgOut->addHTML( |
257 | | - Xml::openElement( 'div' ) . "\n" . |
258 | | - Xml::radioLabel( wfMsg( 'openidchooseauto', $this->automaticName( $sreg ) ), 'wpNameChoice', 'auto', 'wpNameChoiceAuto', !$def ) . "\n" . |
259 | | - Xml::closeElement( 'div' ) . "\n" . |
260 | | - Xml::openElement( 'div' ) . "\n" . |
261 | | - Xml::radioLabel( wfMsg( 'openidchoosemanual' ), 'wpNameChoice', 'manual', 'wpNameChoiceManual' ) . "\n" . |
262 | | - Xml::input( 'wpNameValue', 16, false, array( 'id' => 'wpNameValue' ) ) . "\n" . |
263 | | - Xml::closeElement( 'div' ) . "\n" . |
264 | | - Xml::submitButton( wfMsg( 'login' ), array( 'name' => 'wpOK' ) ) . Xml::submitButton( wfMsg( 'cancel' ), array( 'name' => 'wpCancel' ) ) . "\n" . |
| 290 | + Xml::openElement( 'tr' ) . |
| 291 | + Xml::tags( 'td', array( 'class' => 'mw-label' ), |
| 292 | + Xml::radio( 'wpNameChoice', 'auto', !$def, array( 'id' => 'wpNameChoiceAuto' ) ) |
| 293 | + ) . |
| 294 | + Xml::tags( 'td', array( 'class' => 'mw-input' ), |
| 295 | + Xml::label( wfMsg( 'openidchooseauto', $this->automaticName( $sreg ) ), 'wpNameChoiceAuto' ) |
| 296 | + ) . |
| 297 | + Xml::closeElement( 'tr' ) . "\n" . |
| 298 | + |
| 299 | + Xml::openElement( 'tr' ) . |
| 300 | + Xml::tags( 'td', array( 'class' => 'mw-label' ), |
| 301 | + Xml::radio( 'wpNameChoice', 'manual', !$def, array( 'id' => 'wpNameChoiceManual' ) ) |
| 302 | + ) . |
| 303 | + Xml::tags( 'td', array( 'class' => 'mw-input' ), |
| 304 | + Xml::label( wfMsg( 'openidchoosemanual' ), 'wpNameChoiceManual' ) . ' ' . |
| 305 | + Xml::input( 'wpNameValue', 16, false, array( 'id' => 'wpNameValue' ) ) |
| 306 | + ) . |
| 307 | + Xml::closeElement( 'tr' ) . "\n" . |
| 308 | + |
| 309 | + Xml::openElement( 'tr' ) . "\n" . |
| 310 | + Xml::element( 'td', array(), '' ) . "\n" . |
| 311 | + Xml::tags( 'td', array( 'class' => 'mw-submit' ), |
| 312 | + Xml::submitButton( wfMsg( 'login' ), array( 'name' => 'wpOK' ) ) . |
| 313 | + Xml::submitButton( wfMsg( 'cancel' ), array( 'name' => 'wpCancel' ) ) |
| 314 | + ) . "\n" . |
| 315 | + Xml::closeElement( 'tr' ) . "\n" . |
| 316 | + |
| 317 | + Xml::closeElement( 'table' ) . |
| 318 | + Xml::closeElement( 'fieldset' ) . |
265 | 319 | Xml::closeElement( 'form' ) |
266 | 320 | ); |
267 | 321 | } |
— | — | @@ -300,9 +354,12 @@ |
301 | 355 | return; |
302 | 356 | } |
303 | 357 | |
304 | | - if ( $wgRequest->getText( 'wpUpdateUserInfo' ) ) { |
305 | | - $this->updateUser( $user, $sreg ); |
| 358 | + $force = array(); |
| 359 | + foreach( array( 'fullname', 'nickname', 'email', 'language' ) as $option ) { |
| 360 | + if ( $wgRequest->getCheck( 'wpUpdateUserInfo' . $option ) ) |
| 361 | + $force[] = $option; |
306 | 362 | } |
| 363 | + $this->updateUser( $user, $sreg ); |
307 | 364 | } else { |
308 | 365 | $name = $this->getUserName( $openid, $sreg, $choice, $nameValue ); |
309 | 366 | |
— | — | @@ -376,25 +433,12 @@ |
377 | 434 | |
378 | 435 | if ( $user instanceof User ) { |
379 | 436 | $this->updateUser( $user, $sreg ); # update from server |
380 | | - } else { |
381 | | - # For easy names |
382 | | - $name = $this->createName( $openid, $sreg ); |
383 | | - if ( $name ) { |
384 | | - $user = $this->createUser( $openid, $sreg, $name ); |
385 | | - } else { |
386 | | - # For hard names |
387 | | - $this->saveValues( $openid, $sreg ); |
388 | | - $this->chooseNameForm( $openid, $sreg ); |
389 | | - return; |
390 | | - } |
391 | | - } |
392 | | - |
393 | | - if ( !$user instanceof User ) { |
394 | | - wfDebug( "OpenID: aborting in auth success because we could not create user object\n" ); |
395 | | - $wgOut->showErrorPage( 'openiderror', 'openiderrortext' ); |
396 | | - } else { |
397 | 437 | $wgUser = $user; |
398 | 438 | $this->displaySuccessLogin( $openid ); |
| 439 | + } else { |
| 440 | + $this->saveValues( $openid, $sreg ); |
| 441 | + $this->chooseNameForm( $openid, $sreg ); |
| 442 | + return; |
399 | 443 | } |
400 | 444 | } |
401 | 445 | } |
— | — | @@ -409,18 +453,15 @@ |
410 | 454 | function updateUser( $user, $sreg, $force = false ) { |
411 | 455 | global $wgAllowRealName, $wgEmailAuthentication; |
412 | 456 | |
413 | | - // Back compat with old option |
414 | | - $updateAll = $force || $user->getOption( 'openid-update-userinfo-on-login' ); |
415 | | - |
416 | 457 | // Nick name |
417 | | - if ( $updateAll || $user->getOption( 'openid-update-userinfo-on-login-nickname' ) ) { |
| 458 | + if ( $this->updateOption( 'nickname', $user, $force ) ) { |
418 | 459 | // FIXME: only update if there's been a change |
419 | 460 | if ( array_key_exists( 'nickname', $sreg ) ) |
420 | 461 | $user->setOption( 'nickname', $sreg['nickname'] ); |
421 | 462 | } |
422 | 463 | |
423 | 464 | // E-mail |
424 | | - if ( $updateAll || $user->getOption( 'openid-update-userinfo-on-login-email' ) ) { |
| 465 | + if ( $this->updateOption( 'email', $user, $force ) ) { |
425 | 466 | if ( array_key_exists( 'email', $sreg ) ) { |
426 | 467 | $email = $sreg['email']; |
427 | 468 | // If email changed, then email a confirmation mail |
— | — | @@ -438,20 +479,20 @@ |
439 | 480 | } |
440 | 481 | |
441 | 482 | // Full name |
442 | | - if ( $wgAllowRealName && ( $updateAll || $user->getOption( 'openid-update-userinfo-on-login-fullname' ) ) ) { |
| 483 | + if ( $wgAllowRealName && ( $this->updateOption( 'fullname', $user, $force ) ) ) { |
443 | 484 | if ( array_key_exists( 'fullname', $sreg ) ) |
444 | 485 | $user->setRealName( $sreg['fullname'] ); |
445 | 486 | } |
446 | 487 | |
447 | 488 | // Language |
448 | | - if ( $updateAll || $user->getOption( 'openid-update-userinfo-on-login-language' ) ) { |
| 489 | + if ( $this->updateOption( 'language', $user, $force ) ) { |
449 | 490 | if ( array_key_exists( 'language', $sreg ) ) { |
450 | 491 | # FIXME: check and make sure the language exists |
451 | 492 | $user->setOption( 'language', $sreg['language'] ); |
452 | 493 | } |
453 | 494 | } |
454 | 495 | |
455 | | - if ( $updateAll || $user->getOption( 'openid-update-userinfo-on-login-timezone' ) ) { |
| 496 | + if ( $this->updateOption( 'timezone', $user, $force ) ) { |
456 | 497 | if ( array_key_exists( 'timezone', $sreg ) ) { |
457 | 498 | # FIXME: do something with it. |
458 | 499 | # $offset = OpenIDTimezoneToTzoffset($sreg['timezone']); |
— | — | @@ -463,6 +504,15 @@ |
464 | 505 | } |
465 | 506 | |
466 | 507 | /** |
| 508 | + * Helper function for updateUser() |
| 509 | + */ |
| 510 | + private function updateOption( $option, User $user, $force ) { |
| 511 | + return $force === true || ( is_array( $force ) && in_array( $option, $force ) ) || |
| 512 | + $user->getOption( 'openid-update-userinfo-on-login-' . $option ) || |
| 513 | + $user->getOption( 'openid-update-userinfo-on-login' ); // Back compat with old option |
| 514 | + } |
| 515 | + |
| 516 | + /** |
467 | 517 | * Display the final "Successful login" |
468 | 518 | * |
469 | 519 | * @param $openid String: OpenID url |
— | — | @@ -539,19 +589,11 @@ |
540 | 590 | # Methods to get the user name |
541 | 591 | # ---------------------------- |
542 | 592 | |
543 | | - function createName( $openid, $sreg ) { |
544 | | - # try nickname |
545 | | - if ( array_key_exists( 'nickname', $sreg ) && |
546 | | - $this->userNameOK( $sreg['nickname'] ) ) { |
547 | | - return $sreg['nickname']; |
548 | | - } else { |
549 | | - return null; |
550 | | - } |
551 | | - } |
552 | | - |
553 | | - |
554 | 593 | function getUserName( $openid, $sreg, $choice, $nameValue ) { |
555 | 594 | switch ( $choice ) { |
| 595 | + case 'nick': |
| 596 | + return ( ( array_key_exists( 'nickname', $sreg ) ) ? $sreg['nickname'] : null ); |
| 597 | + break; |
556 | 598 | case 'full': |
557 | 599 | return ( ( array_key_exists( 'fullname', $sreg ) ) ? $sreg['fullname'] : null ); |
558 | 600 | break; |
— | — | @@ -690,7 +732,9 @@ |
691 | 733 | } |
692 | 734 | |
693 | 735 | function fetchValues() { |
694 | | - return array( $_SESSION['openid_consumer_response'], $_SESSION['openid_consumer_sreg'] ); |
| 736 | + $response = isset( $_SESSION['openid_consumer_response'] ) ? $_SESSION['openid_consumer_response'] : null; |
| 737 | + $sreg = isset( $_SESSION['openid_consumer_sreg'] ) ? $_SESSION['openid_consumer_sreg'] : null; |
| 738 | + return array( $response, $sreg ); |
695 | 739 | } |
696 | 740 | |
697 | 741 | function returnTo() { |