r45510 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45509‎ | r45510 | r45511 >
Date:18:30, 7 January 2009
Author:ialex
Status:deferred
Tags:
Comment:
* Allow schema update to be applied by running update.php
* Removed trailing whitespaces
Modified paths:
  • /trunk/extensions/OpenID/OpenID.hooks.php (modified) (history)
  • /trunk/extensions/OpenID/OpenID.setup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenID/OpenID.hooks.php
@@ -3,13 +3,13 @@
44 class OpenIDHooks {
55 public static function onSpecialPage_initList( &$list ) {
66 global $wgOpenIDOnly, $wgOpenIDClientOnly;
7 -
 7+
88 if ( $wgOpenIDOnly ) {
99 $list['Userlogin'] = array( 'SpecialRedirectToSpecial', 'Userlogin', 'OpenIDLogin' );
1010 # Used in 1.12.x and above
1111 $list['CreateAccount'] = array( 'SpecialRedirectToSpecial', 'CreateAccount', 'OpenIDLogin' );
1212 }
13 -
 13+
1414 # Special pages are added at global scope; remove server-related ones
1515 # if client-only flag is set
1616 $addList = array( 'Login', 'Finish', 'Convert' );
@@ -17,38 +17,38 @@
1818 $addList[] = 'Server';
1919 $addList[] = 'XRDS';
2020 }
21 -
 21+
2222 foreach ( $addList as $sp ) {
2323 $list['OpenID'.$sp] = 'SpecialOpenID' . $sp;
2424 }
25 -
 25+
2626 return true;
2727 }
2828
2929 # Hook is called whenever an article is being viewed
3030 public static function onArticleViewHeader( &$article, &$outputDone, &$pcache ) {
3131 global $wgOut, $wgOpenIDClientOnly;
32 -
 32+
3333 $nt = $article->getTitle();
34 -
 34+
3535 // If the page being viewed is a user page,
3636 // generate the openid.server META tag and output
3737 // the X-XRDS-Location. See the OpenIDXRDS
3838 // special page for the XRDS output / generation
3939 // logic.
40 -
 40+
4141 if ( $nt && $nt->getNamespace() == NS_USER && strpos( $nt->getText(), '/' ) === false ) {
4242 $user = User::newFromName( $nt->getText() );
4343 if ($user && $user->getID() != 0) {
4444 $openid = SpecialOpenID::getUserUrl( $user );
4545 if ( isset( $openid ) && strlen( $openid ) != 0 ) {
4646 global $wgOpenIDShowUrlOnUserPage;
47 -
 47+
4848 if ( $wgOpenIDShowUrlOnUserPage == 'always' ||
4949 ( $wgOpenIDShowUrlOnUserPage == 'user' && !$user->getOption( 'hideopenid' ) ) )
5050 {
5151 global $wgOpenIDLoginLogoUrl;
52 -
 52+
5353 $url = SpecialOpenID::OpenIDToUrl( $openid );
5454 $disp = htmlspecialchars( $openid );
5555 $wgOut->setSubtitle("<span class='subpages'>" .
@@ -71,26 +71,26 @@
7272 }
7373 }
7474 }
75 -
 75+
7676 return true;
7777 }
7878
7979 public static function onPersonalUrls(&$personal_urls, &$title) {
8080 global $wgHideOpenIDLoginLink, $wgUser, $wgLang, $wgOut, $wgOpenIDOnly;
81 -
 81+
8282 if ( !$wgHideOpenIDLoginLink && $wgUser->getID() == 0 ) {
8383 wfLoadExtensionMessages( 'OpenID' );
8484 $wgOut->addHeadItem( 'openidloginstyle', self::loginStyle() );
8585 $sk = $wgUser->getSkin();
8686 $returnto = $title->isSpecial( 'Userlogout' ) ?
8787 '' : ('returnto=' . $title->getPrefixedURL() );
88 -
 88+
8989 $personal_urls['openidlogin'] = array(
9090 'text' => wfMsg( 'openidlogin' ),
9191 'href' => $sk->makeSpecialUrl( 'OpenIDLogin', $returnto ),
9292 'active' => $title->isSpecial( 'OpenIDLogin' )
9393 );
94 -
 94+
9595 if ( $wgOpenIDOnly ) {
9696 # remove other login links
9797 foreach ( array( 'login', 'anonlogin' ) as $k ) {
@@ -100,7 +100,7 @@
101101 }
102102 }
103103 }
104 -
 104+
105105 return true;
106106 }
107107
@@ -110,10 +110,24 @@
111111 if ( $wgOpenIDShowUrlOnUserPage == 'user' ) {
112112 $extraToggles[] = 'hideopenid';
113113 }
114 -
 114+
115115 return true;
116116 }
117117
 118+ public static function onLoadExtensionSchemaUpdates() {
 119+ global $wgDBtype, $wgExtNewTables;
 120+
 121+ $base = dirname( __FILE__ );
 122+
 123+ if( $wgDBtype == 'mysql' ) {
 124+ $wgExtNewTables[] = array( 'user_openid', "$base/openid_table.sql" );
 125+ } else if( $wgDBtype == 'postgres' ) {
 126+ $wgExtNewTables[] = array( 'user_openid', "$base/openid_table.pg.sql" );
 127+ }
 128+
 129+ return true;
 130+ }
 131+
118132 private static function loginStyle() {
119133 global $wgOpenIDLoginLogoUrl;
120134 return <<<EOS
@@ -126,4 +140,4 @@
127141 </style>
128142 EOS;
129143 }
130 -}
\ No newline at end of file
 144+}
Index: trunk/extensions/OpenID/OpenID.setup.php
@@ -148,3 +148,4 @@
149149 $wgHooks['UserToggles'][] = 'OpenIDHooks::onUserToggles';
150150 $wgHooks['ArticleViewHeader'][] = 'OpenIDHooks::onArticleViewHeader';
151151 $wgHooks['SpecialPage_initList'][] = 'OpenIDHooks::onSpecialPage_initList';
 152+$wgHooks['LoadExtensionSchemaUpdates'][] = 'OpenIDHooks::onLoadExtensionSchemaUpdates';

Status & tagging log