Glaisher has uploaded a new change for review. https://gerrit.wikimedia.org/r/204081
Change subject: Simplify CentralAuthHooks::onGetPreferences ...................................................................... Simplify CentralAuthHooks::onGetPreferences *If the user has a fully unified account, only a link to Special:CentralAuth is now shown. (All in order! removed) *If the user has unattached accounts and 'centralauth-merge', also add a link to Special:MergeAccount. *Show a status message if the account is not fully unified. Bug: T18690 Change-Id: I6ac6271798104289dad03c90a737cb7e96ad1b33 --- M i18n/en.json M i18n/qqq.json M includes/CentralAuthHooks.php 3 files changed, 28 insertions(+), 52 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth refs/changes/81/204081/1 diff --git a/i18n/en.json b/i18n/en.json index ef00851..e02366f 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -204,8 +204,6 @@ "centralauth-prefs-status": "Global account status:", "centralauth-prefs-not-managed": "Not using unified account", "centralauth-prefs-unattached": "Unconfirmed", - "centralauth-prefs-complete": "All in order!", - "centralauth-prefs-migration": "In migration", "centralauth-prefs-count-attached": "Your account is active on $1 project {{PLURAL:$1|site|sites}}.", "centralauth-prefs-count-unattached": "Unconfirmed accounts with your name remain on $1 {{PLURAL:$1|project|projects}}.", "centralauth-prefs-detail-unattached": "This project site has not been confirmed as belonging to the global account.", diff --git a/i18n/qqq.json b/i18n/qqq.json index f728a6c..ca7680c 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -217,11 +217,9 @@ "centralauth-days-ago": "Parameters:\n* $1 - number of days\n{{Related|Centralauth-ago}}", "centralauth-months-ago": "Parameters:\n* $1 - number of months\n{{Related|Centralauth-ago}}", "centralauth-years-ago": "Parameters:\n* $1 - number of years\n{{Related|Centralauth-ago}}", - "centralauth-prefs-status": "Used as label in [[Special:Preferences]].\n\nFollowed by any one of the following messages:\n* {{msg-mw|Centralauth-prefs-not-managed}}\n* {{msg-mw|Centralauth-prefs-unattached}}\n* {{msg-mw|Centralauth-prefs-complete}}\n* {{msg-mw|Centralauth-prefs-migration}}\n\nSee example: [[mw:Special:Preferences]].", + "centralauth-prefs-status": "Used as label in [[Special:Preferences]].\n\nFollowed by any one of the following messages:\n* {{msg-mw|Centralauth-prefs-not-managed}}\n* {{msg-mw|Centralauth-prefs-unattached}}\n\nSee example: [[mw:Special:Preferences]].", "centralauth-prefs-not-managed": "This message is displayed as the global account status at [[Special:Preferences|{{int:Preferences}}]] page, when the account is not merged at all.\n\nPreceded by the label {{msg-mw|Centralauth-prefs-status}}.\n\nSee example: [[mw:Special:Preferences]].\n{{Related|Centralauth-prefs}}", "centralauth-prefs-unattached": "This message is displayed as the global account status at [[Special:Preferences|{{int:Preferences}}]] page, when the account is in migration, but the local account is not attached.\n\nPreceded by the label {{msg-mw|Centralauth-prefs-status}}.\n\nFollowed by {{msg-mw|Centralauth-prefs-detail-unattached}}.\n\nSee example: [[mw:Special:Preferences]].\n{{Related|Centralauth-prefs}}", - "centralauth-prefs-complete": "This message is displayed as the global account status at [[Special:Preferences|{{int:Preferences}}]] page, when everything is alright with the user's unified account.\n\nPreceded by the label {{msg-mw|Centralauth-prefs-status}}.\n\nSee example: [[mw:Special:Preferences]].\n{{Related|Centralauth-prefs}}", - "centralauth-prefs-migration": "This message is displayed as the global account status at [[Special:Preferences|{{int:Preferences}}]] page, when the account unification is not yet compelte. Preceded by the label {{msg-mw|Centralauth-prefs-status}}. See example: [[mw:Special:Preferences]].\n{{Related|Centralauth-prefs}}", "centralauth-prefs-count-attached": "Used in [[Special:Preferences|{{int:Preferences}}]] special page. Parameters:\n* $1 - number of attached sites\nSee also:\n* {{msg-mw|Centralauth-prefs-count-unattached}}", "centralauth-prefs-count-unattached": "Used in [[Special:Preferences|{{int:Preferences}}]] special page.\n\nShown when the migration is incomplete.\n\nParameters:\n* $1 - number of unattached projects\nSee also:\n* {{msg-mw|Centralauth-prefs-count-attached}}", "centralauth-prefs-detail-unattached": "This message is displayed as the global account status at [[Special:Preferences|{{int:Preferences}}]] page, when the account is in migration, but the local account is not attached.\n\nPreceded by {{msg-mw|Centralauth-prefs-unattached}}.\n\nSee example: [[mw:Special:Preferences]].", diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php index f82ed19..83cbec9 100644 --- a/includes/CentralAuthHooks.php +++ b/includes/CentralAuthHooks.php @@ -303,71 +303,51 @@ static function onGetPreferences( $user, &$preferences ) { global $wgLang; - if ( !$user->isAllowed( 'centralauth-merge' ) ) { - // Not allowed to merge, don't display merge information - return true; - } - // Possible states: // - account not merged at all // - global accounts exists, but this local account is unattached // - this local account is attached, but migration incomplete - // - all local accounts are attached + // - all local accounts are attached (no $message shown) $global = CentralAuthUser::getInstance( $user ); + $unattached = count( $global->listUnattached() ); if ( $global->exists() ) { - if ( $global->isAttached() ) { - // Local is attached... + if ( $global->isAttached() && $unattached ) { + // Migration incomplete - unattached accounts at other wikis $attached = count( $global->listAttached() ); - $unattached = count( $global->listUnattached() ); - if ( $unattached ) { - // Migration incomplete - $message = '<strong>' . wfMessage( 'centralauth-prefs-migration' )->parse() . '</strong>' . - '<br />' . - wfMessage( 'centralauth-prefs-count-attached' )->numParams( $attached )->parse() . - '<br />' . - wfMessage( 'centralauth-prefs-count-unattached' )->numParams( $unattached )->parse(); - } else { - // Migration complete - $message = '<strong>' . wfMessage( 'centralauth-prefs-complete' )->parse() . '</strong>' . - '<br />' . - wfMessage( 'centralauth-prefs-count-attached' )->numParams( $attached )->parse(); - } - } else { - // Account is in migration, but the local account is not attached - $message = '<strong>' . wfMessage( 'centralauth-prefs-unattached' )->parse() . '</strong>' . + $message = wfMessage( 'centralauth-prefs-unattached' )->parse() . '<br />' . - wfMessage( 'centralauth-prefs-detail-unattached' )->parse(); + wfMessage( 'centralauth-prefs-count-attached' )->numParams( $attached )->parse() . + '<br />' . + wfMessage( 'centralauth-prefs-count-unattached' )->numParams( $unattached )->parse(); + } elseif ( !$global->isAttached() ) { + // Global account exists but the local account is not attached + $message = wfMessage( 'centralauth-prefs-detail-unattached' )->parse(); } } else { - // Not migrated. + // No global account $message = wfMessage( 'centralauth-prefs-not-managed' )->parse(); } $manageLinks = array(); - $manageLinks[] = Linker::linkKnown( SpecialPage::getTitleFor( 'MergeAccount' ), - wfMessage( 'centralauth-prefs-manage' )->parse() ); + if ( $unattached && $user->isAllowed( 'centralauth-merge' ) ) { + $manageLinks[] = Linker::linkKnown( SpecialPage::getTitleFor( 'MergeAccount' ), + wfMessage( 'centralauth-prefs-manage' )->parse() ); + } $manageLinks[] = Linker::linkKnown( SpecialPage::getTitleFor( 'CentralAuth', $user->getName() ), wfMessage( 'centralauth-prefs-view' )->parse() ); - $manageLinkList = wfMessage( 'parentheses', $wgLang->pipeList( $manageLinks ) )->text(); + $manageLinkList = $wgLang->pipeList( $manageLinks ); - $prefInsert = - array( 'globalaccountstatus' => - array( - 'section' => 'personal/info', - 'label-message' => 'centralauth-prefs-status', - 'type' => 'info', - 'raw' => true, - 'default' => "$message<br />$manageLinkList" - ), - ); - - if ( array_key_exists( 'registrationdate', $preferences ) ) { - $preferences = wfArrayInsertAfter( $preferences, $prefInsert, 'registrationdate' ); - } elseif ( array_key_exists( 'editcount', $preferences ) ) { - $preferences = wfArrayInsertAfter( $preferences, $prefInsert, 'editcount' ); - } else { - $preferences += $prefInsert; + $preferences['globalaccountstatus'] = array( + 'section' => 'personal/info', + 'label-message' => 'centralauth-prefs-status', + 'type' => 'info', + 'raw' => true, + 'default' => $manageLinkList + ); + if ( isset( $message ) ) { + $manageLinkList = wfMessage( 'parentheses', $manageLinkList )->text(); // looks weird otherwise + $preferences['globalaccountstatus']['default'] = "$message<br />$manageLinkList"; } return true; -- To view, visit https://gerrit.wikimedia.org/r/204081 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6ac6271798104289dad03c90a737cb7e96ad1b33 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CentralAuth Gerrit-Branch: master Gerrit-Owner: Glaisher <glaisher.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits