Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.hooks.php |
— | — | @@ -20,41 +20,41 @@ |
21 | 21 | } |
22 | 22 | |
23 | 23 | public static function personalUrls( &$personal_urls, &$title ) { |
24 | | - global $wgUser; |
25 | | - global $wgOptInAlwaysShowPersonalLink, $wgOptInNeverShowPersonalLink; |
| 24 | + global $wgUser, $wgOptInAlwaysShowPersonalLink; |
| 25 | + global $wgOptInNeverShowPersonalLink; |
26 | 26 | |
27 | | - // Checks if... |
28 | | - if ( |
29 | | - // This should be shown because... |
30 | | - ( |
31 | | - // The user is opted in |
32 | | - SpecialOptIn::isOptedIn( $wgUser ) || |
33 | | - // Or the link should always be shown |
34 | | - $wgOptInAlwaysShowPersonalLink |
35 | | - ) && |
36 | | - // And the link is allowed to be shown |
37 | | - !$wgOptInNeverShowPersonalLink && |
38 | | - // We're not at the OptIn page |
39 | | - current( explode( '/', $title->getText() ) ) !== SpecialPage::getLocalNameFor( 'OptIn' ) |
40 | | - ) { |
41 | | - // Loads opt-in messages |
42 | | - wfLoadExtensionMessages( 'OptIn' ); |
43 | | - // Inserts a link into personal tools |
44 | | - $personal_urls = array_merge( |
45 | | - array( |
46 | | - 'acaibeta' => array( |
47 | | - 'text' => SpecialOptIn::isOptedIn( $wgUser ) ? |
48 | | - wfMsg( 'optin-leave' ) : |
49 | | - wfMsg( 'optin-try' ), |
50 | | - 'href' => SpecialPage::getTitleFor( |
51 | | - 'UsabilityInitiativeOptIn', $title->getFullText() |
52 | | - )->getLocalUrl(), |
53 | | - 'class' => 'no-text-transform' |
54 | | - ) |
55 | | - ), |
56 | | - $personal_urls |
57 | | - ); |
58 | | - } |
| 27 | + if ( $wgOptInNeverShowPersonalLink || |
| 28 | + ( !SpecialOptIn::isOptedIn( $wgUser ) && |
| 29 | + !$wgOptInAlwaysShowPersonalLink ) ) |
| 30 | + // Don't show the link |
| 31 | + return true; |
| 32 | + |
| 33 | + // Loads opt-in messages |
| 34 | + wfLoadExtensionMessages( 'OptIn' ); |
| 35 | + |
| 36 | + // Make sure we don't create links that return to |
| 37 | + // Special:UsabilityOptIn itself |
| 38 | + $titleParts = explode( '/', $title->getText() ); |
| 39 | + if ( $titleParts[0] == SpecialPage::getLocalNameFor( 'OptIn' ) ) |
| 40 | + $link = $title->getLocalUrl(); |
| 41 | + else |
| 42 | + $link = SpecialPage::getTitleFor( |
| 43 | + 'OptIn', $title->getFullText() |
| 44 | + )->getLocalUrl(); |
| 45 | + |
| 46 | + // Inserts a link into personal tools |
| 47 | + $personal_urls = array_merge( |
| 48 | + array( |
| 49 | + 'acaibeta' => array( |
| 50 | + 'text' => SpecialOptIn::isOptedIn( $wgUser ) ? |
| 51 | + wfMsg( 'optin-leave' ) : |
| 52 | + wfMsg( 'optin-try' ), |
| 53 | + 'href' => $link, |
| 54 | + 'class' => 'no-text-transform' |
| 55 | + ) |
| 56 | + ), |
| 57 | + $personal_urls |
| 58 | + ); |
59 | 59 | return true; |
60 | 60 | } |
61 | 61 | } |