Index: trunk/extensions/OpenID/OpenID.hooks.php |
— | — | @@ -3,13 +3,13 @@ |
4 | 4 | class OpenIDHooks { |
5 | 5 | public static function onSpecialPage_initList( &$list ) { |
6 | 6 | global $wgOpenIDOnly, $wgOpenIDClientOnly; |
7 | | - |
| 7 | + |
8 | 8 | if ( $wgOpenIDOnly ) { |
9 | 9 | $list['Userlogin'] = array( 'SpecialRedirectToSpecial', 'Userlogin', 'OpenIDLogin' ); |
10 | 10 | # Used in 1.12.x and above |
11 | 11 | $list['CreateAccount'] = array( 'SpecialRedirectToSpecial', 'CreateAccount', 'OpenIDLogin' ); |
12 | 12 | } |
13 | | - |
| 13 | + |
14 | 14 | # Special pages are added at global scope; remove server-related ones |
15 | 15 | # if client-only flag is set |
16 | 16 | $addList = array( 'Login', 'Finish', 'Convert' ); |
— | — | @@ -17,38 +17,38 @@ |
18 | 18 | $addList[] = 'Server'; |
19 | 19 | $addList[] = 'XRDS'; |
20 | 20 | } |
21 | | - |
| 21 | + |
22 | 22 | foreach ( $addList as $sp ) { |
23 | 23 | $list['OpenID'.$sp] = 'SpecialOpenID' . $sp; |
24 | 24 | } |
25 | | - |
| 25 | + |
26 | 26 | return true; |
27 | 27 | } |
28 | 28 | |
29 | 29 | # Hook is called whenever an article is being viewed |
30 | 30 | public static function onArticleViewHeader( &$article, &$outputDone, &$pcache ) { |
31 | 31 | global $wgOut, $wgOpenIDClientOnly; |
32 | | - |
| 32 | + |
33 | 33 | $nt = $article->getTitle(); |
34 | | - |
| 34 | + |
35 | 35 | // If the page being viewed is a user page, |
36 | 36 | // generate the openid.server META tag and output |
37 | 37 | // the X-XRDS-Location. See the OpenIDXRDS |
38 | 38 | // special page for the XRDS output / generation |
39 | 39 | // logic. |
40 | | - |
| 40 | + |
41 | 41 | if ( $nt && $nt->getNamespace() == NS_USER && strpos( $nt->getText(), '/' ) === false ) { |
42 | 42 | $user = User::newFromName( $nt->getText() ); |
43 | 43 | if ($user && $user->getID() != 0) { |
44 | 44 | $openid = SpecialOpenID::getUserUrl( $user ); |
45 | 45 | if ( isset( $openid ) && strlen( $openid ) != 0 ) { |
46 | 46 | global $wgOpenIDShowUrlOnUserPage; |
47 | | - |
| 47 | + |
48 | 48 | if ( $wgOpenIDShowUrlOnUserPage == 'always' || |
49 | 49 | ( $wgOpenIDShowUrlOnUserPage == 'user' && !$user->getOption( 'hideopenid' ) ) ) |
50 | 50 | { |
51 | 51 | global $wgOpenIDLoginLogoUrl; |
52 | | - |
| 52 | + |
53 | 53 | $url = SpecialOpenID::OpenIDToUrl( $openid ); |
54 | 54 | $disp = htmlspecialchars( $openid ); |
55 | 55 | $wgOut->setSubtitle("<span class='subpages'>" . |
— | — | @@ -71,26 +71,26 @@ |
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
75 | | - |
| 75 | + |
76 | 76 | return true; |
77 | 77 | } |
78 | 78 | |
79 | 79 | public static function onPersonalUrls(&$personal_urls, &$title) { |
80 | 80 | global $wgHideOpenIDLoginLink, $wgUser, $wgLang, $wgOut, $wgOpenIDOnly; |
81 | | - |
| 81 | + |
82 | 82 | if ( !$wgHideOpenIDLoginLink && $wgUser->getID() == 0 ) { |
83 | 83 | wfLoadExtensionMessages( 'OpenID' ); |
84 | 84 | $wgOut->addHeadItem( 'openidloginstyle', self::loginStyle() ); |
85 | 85 | $sk = $wgUser->getSkin(); |
86 | 86 | $returnto = $title->isSpecial( 'Userlogout' ) ? |
87 | 87 | '' : ('returnto=' . $title->getPrefixedURL() ); |
88 | | - |
| 88 | + |
89 | 89 | $personal_urls['openidlogin'] = array( |
90 | 90 | 'text' => wfMsg( 'openidlogin' ), |
91 | 91 | 'href' => $sk->makeSpecialUrl( 'OpenIDLogin', $returnto ), |
92 | 92 | 'active' => $title->isSpecial( 'OpenIDLogin' ) |
93 | 93 | ); |
94 | | - |
| 94 | + |
95 | 95 | if ( $wgOpenIDOnly ) { |
96 | 96 | # remove other login links |
97 | 97 | foreach ( array( 'login', 'anonlogin' ) as $k ) { |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
104 | | - |
| 104 | + |
105 | 105 | return true; |
106 | 106 | } |
107 | 107 | |
— | — | @@ -110,10 +110,24 @@ |
111 | 111 | if ( $wgOpenIDShowUrlOnUserPage == 'user' ) { |
112 | 112 | $extraToggles[] = 'hideopenid'; |
113 | 113 | } |
114 | | - |
| 114 | + |
115 | 115 | return true; |
116 | 116 | } |
117 | 117 | |
| 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 | + |
118 | 132 | private static function loginStyle() { |
119 | 133 | global $wgOpenIDLoginLogoUrl; |
120 | 134 | return <<<EOS |
— | — | @@ -126,4 +140,4 @@ |
127 | 141 | </style> |
128 | 142 | EOS; |
129 | 143 | } |
130 | | -} |
\ No newline at end of file |
| 144 | +} |
Index: trunk/extensions/OpenID/OpenID.setup.php |
— | — | @@ -148,3 +148,4 @@ |
149 | 149 | $wgHooks['UserToggles'][] = 'OpenIDHooks::onUserToggles'; |
150 | 150 | $wgHooks['ArticleViewHeader'][] = 'OpenIDHooks::onArticleViewHeader'; |
151 | 151 | $wgHooks['SpecialPage_initList'][] = 'OpenIDHooks::onSpecialPage_initList'; |
| 152 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'OpenIDHooks::onLoadExtensionSchemaUpdates'; |