Index: trunk/extensions/OpenID/OpenID.i18n.php |
— | — | @@ -469,7 +469,7 @@ |
470 | 470 | 'openiderror' => 'Greška pri provjeri', |
471 | 471 | 'openiderrortext' => 'Desila se greška pri provjeri OpenID URL adrese.', |
472 | 472 | 'openidconfigerror' => 'Greška OpenID postavki', |
473 | | - 'openidconfigerrortext' => 'OpenID konfiguracija spremanja za ovaj wiki je nevaljana. |
| 473 | + 'openidconfigerrortext' => 'OpenID konfiguracija spremanja za ovaj wiki je nevaljana. |
474 | 474 | Molimo konsultujte se sa [[Special:ListUsers/sysop|administratorom]].', |
475 | 475 | 'openidpermission' => 'Greška kod OpenID dopuštenja', |
476 | 476 | 'openidpermissiontext' => 'OpenID koji ste naveli nije dopušteno da se prijavi na ovaj server.', |
— | — | @@ -2636,10 +2636,10 @@ |
2637 | 2637 | 'openidclientonlytext' => 'Nie można korzystać z kont tej wiki jako OpenID w innych witrynach.', |
2638 | 2638 | 'openidloginlabel' => 'Adres URL OpenID', |
2639 | 2639 | 'openidlogininstructions' => '{{SITENAME}} korzysta ze standardu [http://openid.net/ OpenID] dla zapewnienia jednolitego uwierzytelnienia pomiędzy różnymi witrynami w sieci Web. |
2640 | | -OpenID pozwala na zalogowanie się do wielu różnych witryn sieci Web bez użycia osobnego hasła dla każdej witryny. |
| 2640 | +OpenID pozwala na zalogowanie się do wielu różnych witryn sieci Web bez użycia osobnego hasła dla każdej witryny. |
2641 | 2641 | (Zobacz [http://pl.wikipedia.org/wiki/OpenID artykuł o OpenID w Wikipedii] jeśli chcesz uzyskać więcej informacji.) |
2642 | 2642 | |
2643 | | -Jeśli masz już konto w {{GRAMMAR:MS.lp|{{SITENAME}}}}, możesz [[Specjalna:Userlogin|zalogować się]] jak zwykle używając nazwy użytkownika i hasła. |
| 2643 | +Jeśli masz już konto w {{GRAMMAR:MS.lp|{{SITENAME}}}}, możesz [[Specjalna:Userlogin|zalogować się]] jak zwykle używając nazwy użytkownika i hasła. |
2644 | 2644 | Jeśli chcesz w przyszłości używać OpenID do logowania się, możesz [[Special:OpenIDConvert|przełączyć konto na korzystanie z OpenID]] po normalnym zalogowaniu się. |
2645 | 2645 | |
2646 | 2646 | Jest wielu [http://openid.net/get/ operatorów usługi OpenID] i możesz mieć już konto przełączone na korzystanie z OpenID innego usługodawcy.', |
— | — | @@ -3260,7 +3260,7 @@ |
3261 | 3261 | 'openidclientonlytext' => 'Du kan inte använda konton från denna wikin som OpenID på en annan sida.', |
3262 | 3262 | 'openidloginlabel' => 'OpenID-adress', |
3263 | 3263 | 'openidlogininstructions' => '{{SITENAME}} stödjer [http://openid.net/ OpenID]-standarden för enhetlig inlogging på många webbsidor. |
3264 | | -OpenID låter dig logga in på många webbsidor utan att använda olika lösenord för varje. |
| 3264 | +OpenID låter dig logga in på många webbsidor utan att använda olika lösenord för varje. |
3265 | 3265 | (Se [http://en.wikipedia.org/wiki/OpenID Wikipedia-artikeln om OpenID] för mer information.) |
3266 | 3266 | |
3267 | 3267 | Om du redan har ett konto på {{SITENAME}}, kan du [[Special:UserLogin|logga in]] som vanligt med ditt användarnamn och lösenord. |
Index: trunk/extensions/OpenID/openid_table.sql |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | CREATE TABLE /*$wgDBprefix*/user_openid ( |
3 | 3 | uoi_openid varchar(255) NOT NULL, |
4 | 4 | uoi_user int(5) unsigned NOT NULL, |
5 | | - |
| 5 | + |
6 | 6 | PRIMARY KEY uoi_openid (uoi_openid), |
7 | 7 | UNIQUE INDEX uoi_user (uoi_user) |
8 | 8 | ) TYPE=InnoDB; |
Index: trunk/extensions/OpenID/OpenID.hooks.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | } |
21 | 21 | |
22 | 22 | foreach ( $addList as $sp ) { |
23 | | - $list['OpenID'.$sp] = 'SpecialOpenID' . $sp; |
| 23 | + $list['OpenID' . $sp] = 'SpecialOpenID' . $sp; |
24 | 24 | } |
25 | 25 | |
26 | 26 | return true; |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | |
41 | 41 | if ( $nt && $nt->getNamespace() == NS_USER && strpos( $nt->getText(), '/' ) === false ) { |
42 | 42 | $user = User::newFromName( $nt->getText() ); |
43 | | - if ($user && $user->getID() != 0) { |
| 43 | + if ( $user && $user->getID() != 0 ) { |
44 | 44 | $openid = SpecialOpenID::getUserUrl( $user ); |
45 | 45 | if ( isset( $openid ) && strlen( $openid ) != 0 ) { |
46 | 46 | global $wgOpenIDShowUrlOnUserPage; |
— | — | @@ -51,10 +51,10 @@ |
52 | 52 | |
53 | 53 | $url = SpecialOpenID::OpenIDToUrl( $openid ); |
54 | 54 | $disp = htmlspecialchars( $openid ); |
55 | | - $wgOut->setSubtitle("<span class='subpages'>" . |
| 55 | + $wgOut->setSubtitle( "<span class='subpages'>" . |
56 | 56 | "<img src='$wgOpenIDLoginLogoUrl' alt='OpenID' />" . |
57 | 57 | "<a href='$url'>$disp</a>" . |
58 | | - "</span>"); |
| 58 | + "</span>" ); |
59 | 59 | } |
60 | 60 | } else { |
61 | 61 | # Add OpenID data iif its allowed |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | return true; |
77 | 77 | } |
78 | 78 | |
79 | | - public static function onPersonalUrls(&$personal_urls, &$title) { |
| 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,7 +83,7 @@ |
84 | 84 | $wgOut->addHeadItem( 'openidloginstyle', self::loginStyle() ); |
85 | 85 | $sk = $wgUser->getSkin(); |
86 | 86 | $returnto = $title->isSpecial( 'Userlogout' ) ? |
87 | | - '' : ('returnto=' . $title->getPrefixedURL() ); |
| 87 | + '' : ( 'returnto=' . $title->getPrefixedURL() ); |
88 | 88 | |
89 | 89 | $personal_urls['openidlogin'] = array( |
90 | 90 | 'text' => wfMsg( 'openidlogin' ), |
— | — | @@ -108,10 +108,10 @@ |
109 | 109 | private static $oidPrefs = array( 'hide', 'update-userinfo-on-login' ); |
110 | 110 | |
111 | 111 | public static function onInitPreferencesForm( $prefs, $request ) { |
112 | | - foreach (self::$oidPrefs as $oidPref) |
| 112 | + foreach ( self::$oidPrefs as $oidPref ) |
113 | 113 | { |
114 | | - $prefs->mToggles['openid-'.$oidPref] |
115 | | - = $request->getCheck( "wpOpOpenID-".$oidPref ) ? 1 : 0; |
| 114 | + $prefs->mToggles['openid-' . $oidPref] |
| 115 | + = $request->getCheck( "wpOpOpenID-" . $oidPref ) ? 1 : 0; |
116 | 116 | } |
117 | 117 | |
118 | 118 | return true; |
— | — | @@ -122,16 +122,16 @@ |
123 | 123 | |
124 | 124 | $out->addHTML( "\n<fieldset>\n<legend>" . wfMsgHtml( 'openid-prefs' ) . "</legend>\n" ); |
125 | 125 | |
126 | | - $out->addWikiText( wfMsg( 'openid-prefstext') ); |
| 126 | + $out->addWikiText( wfMsg( 'openid-prefstext' ) ); |
127 | 127 | |
128 | | - foreach (self::$oidPrefs as $oidPref) |
| 128 | + foreach ( self::$oidPrefs as $oidPref ) |
129 | 129 | { |
130 | | - $out->addHTML( '<div class="toggle"><input type="checkbox" value="1" '. |
131 | | - 'id="openid-'.$oidPref.'" name="wpOpOpenID-'.$oidPref.'"'. |
132 | | - ($prefs->mToggles['openid-'.$oidPref] == 1 ? ' checked="checked"' : ''). |
| 130 | + $out->addHTML( '<div class="toggle"><input type="checkbox" value="1" ' . |
| 131 | + 'id="openid-' . $oidPref . '" name="wpOpOpenID-' . $oidPref . '"' . |
| 132 | + ( $prefs->mToggles['openid-' . $oidPref] == 1 ? ' checked="checked"' : '' ) . |
133 | 133 | '/> ' . |
134 | | - '<span class="toggletext">'. |
135 | | - '<label for="openid-'.$oidPref.'">'.wfMsg( 'openid-pref-'.$oidPref ).'</label>'. |
| 134 | + '<span class="toggletext">' . |
| 135 | + '<label for="openid-' . $oidPref . '">' . wfMsg( 'openid-pref-' . $oidPref ) . '</label>' . |
136 | 136 | "</span></div>\n" ); |
137 | 137 | } |
138 | 138 | |
— | — | @@ -140,12 +140,12 @@ |
141 | 141 | return true; |
142 | 142 | } |
143 | 143 | |
144 | | - public static function onSavePreferences($prefs, $user, &$message, $old) |
| 144 | + public static function onSavePreferences( $prefs, $user, &$message, $old ) |
145 | 145 | { |
146 | | - foreach (self::$oidPrefs as $oidPref) |
| 146 | + foreach ( self::$oidPrefs as $oidPref ) |
147 | 147 | { |
148 | | - $user->setOption('openid-'.$oidPref, $prefs->mToggles['openid-'.$oidPref]); |
149 | | - wfDebugLog('OpenID', 'Setting user preferences: ' . print_r($user, true) ); |
| 148 | + $user->setOption( 'openid-' . $oidPref, $prefs->mToggles['openid-' . $oidPref] ); |
| 149 | + wfDebugLog( 'OpenID', 'Setting user preferences: ' . print_r( $user, true ) ); |
150 | 150 | } |
151 | 151 | |
152 | 152 | $user->saveSettings(); |
— | — | @@ -156,7 +156,7 @@ |
157 | 157 | public static function onResetPreferences( $prefs, $user ) |
158 | 158 | { |
159 | 159 | foreach ( self::$oidPrefs as $oidPref ) { |
160 | | - $prefs->mToggles['openid-'.$oidPref] = $user->getOption( 'openid-'.$oidPref ); |
| 160 | + $prefs->mToggles['openid-' . $oidPref] = $user->getOption( 'openid-' . $oidPref ); |
161 | 161 | } |
162 | 162 | |
163 | 163 | return true; |
— | — | @@ -167,9 +167,9 @@ |
168 | 168 | |
169 | 169 | $base = dirname( __FILE__ ); |
170 | 170 | |
171 | | - if( $wgDBtype == 'mysql' ) { |
| 171 | + if ( $wgDBtype == 'mysql' ) { |
172 | 172 | $wgExtNewTables[] = array( 'user_openid', "$base/openid_table.sql" ); |
173 | | - } else if( $wgDBtype == 'postgres' ) { |
| 173 | + } else if ( $wgDBtype == 'postgres' ) { |
174 | 174 | $wgExtNewTables[] = array( 'user_openid', "$base/openid_table.pg.sql" ); |
175 | 175 | } |
176 | 176 | |
Index: trunk/extensions/OpenID/SpecialOpenIDServer.body.php |
— | — | @@ -22,11 +22,11 @@ |
23 | 23 | * @addtogroup Extensions |
24 | 24 | */ |
25 | 25 | |
26 | | -if (!defined('MEDIAWIKI')) |
27 | | - exit(1); |
| 26 | +if ( !defined( 'MEDIAWIKI' ) ) |
| 27 | + exit( 1 ); |
28 | 28 | |
29 | | -require_once("Auth/OpenID/Server.php"); |
30 | | -require_once("Auth/OpenID/Consumer.php"); |
| 29 | +require_once( "Auth/OpenID/Server.php" ); |
| 30 | +require_once( "Auth/OpenID/Consumer.php" ); |
31 | 31 | |
32 | 32 | # Special page for the server side of OpenID |
33 | 33 | # It has three major flavors: |
— | — | @@ -47,10 +47,10 @@ |
48 | 48 | class SpecialOpenIDServer extends SpecialOpenID { |
49 | 49 | |
50 | 50 | function SpecialOpenIDServer() { |
51 | | - SpecialPage::SpecialPage("OpenIDServer", '', false); |
| 51 | + SpecialPage::SpecialPage( "OpenIDServer", '', false ); |
52 | 52 | } |
53 | 53 | |
54 | | - function execute($par) { |
| 54 | + function execute( $par ) { |
55 | 55 | |
56 | 56 | global $wgOut, $wgOpenIDClientOnly; |
57 | 57 | |
— | — | @@ -61,89 +61,89 @@ |
62 | 62 | # No server functionality if this site is only a client |
63 | 63 | # Note: special page is un-registered if this flag is set, |
64 | 64 | # so it'd be unusual to get here. |
65 | | - |
66 | | - if ($wgOpenIDClientOnly) { |
67 | | - $wgOut->showErrorPage('openiderror', 'openidclientonlytext'); |
| 65 | + |
| 66 | + if ( $wgOpenIDClientOnly ) { |
| 67 | + $wgOut->showErrorPage( 'openiderror', 'openidclientonlytext' ); |
68 | 68 | return; |
69 | 69 | } |
70 | | - |
| 70 | + |
71 | 71 | $server =& $this->getServer(); |
72 | 72 | |
73 | | - switch ($par) { |
| 73 | + switch ( $par ) { |
74 | 74 | case 'Login': |
75 | | - list($request, $sreg) = $this->FetchValues(); |
76 | | - $result = $this->serverLogin($request); |
77 | | - if ($result) { |
78 | | - if (is_string($result)) { |
79 | | - $this->LoginForm($request, $result); |
| 75 | + list( $request, $sreg ) = $this->FetchValues(); |
| 76 | + $result = $this->serverLogin( $request ); |
| 77 | + if ( $result ) { |
| 78 | + if ( is_string( $result ) ) { |
| 79 | + $this->LoginForm( $request, $result ); |
80 | 80 | return; |
81 | 81 | } else { |
82 | | - $this->Response($server, $result); |
| 82 | + $this->Response( $server, $result ); |
83 | 83 | return; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | break; |
87 | | - case 'Trust': |
88 | | - list($request, $sreg) = $this->FetchValues(); |
89 | | - $result = $this->Trust($request, $sreg); |
90 | | - if ($result) { |
91 | | - if (is_string($result)) { |
92 | | - $this->TrustForm($request, $sreg, $result); |
| 87 | + case 'Trust': |
| 88 | + list( $request, $sreg ) = $this->FetchValues(); |
| 89 | + $result = $this->Trust( $request, $sreg ); |
| 90 | + if ( $result ) { |
| 91 | + if ( is_string( $result ) ) { |
| 92 | + $this->TrustForm( $request, $sreg, $result ); |
93 | 93 | return; |
94 | 94 | } else { |
95 | | - $this->Response($server, $result); |
| 95 | + $this->Response( $server, $result ); |
96 | 96 | return; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | break; |
100 | | - default: |
101 | | - if (strlen($par)) { |
102 | | - wfDebug("OpenID: aborting in user validation because the parameter was empty\n"); |
103 | | - $wgOut->showErrorPage('openiderror', 'openiderrortext'); |
| 100 | + default: |
| 101 | + if ( strlen( $par ) ) { |
| 102 | + wfDebug( "OpenID: aborting in user validation because the parameter was empty\n" ); |
| 103 | + $wgOut->showErrorPage( 'openiderror', 'openiderrortext' ); |
104 | 104 | return; |
105 | 105 | } else { |
106 | 106 | $method = $_SERVER['REQUEST_METHOD']; |
107 | 107 | $query = null; |
108 | | - if ($method == 'GET') { |
| 108 | + if ( $method == 'GET' ) { |
109 | 109 | $query = $_GET; |
110 | 110 | } else { |
111 | 111 | $query = $_POST; |
112 | 112 | } |
113 | 113 | |
114 | 114 | $request = $server->decodeRequest(); |
115 | | - $sreg = $this->SregFromQuery($query); |
| 115 | + $sreg = $this->SregFromQuery( $query ); |
116 | 116 | $response = NULL; |
117 | 117 | break; |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | | - if (!isset($request)) { |
122 | | - wfDebug("OpenID: aborting in user validation because the request was missing\n"); |
123 | | - $wgOut->showErrorPage('openiderror', 'openiderrortext'); |
| 121 | + if ( !isset( $request ) ) { |
| 122 | + wfDebug( "OpenID: aborting in user validation because the request was missing\n" ); |
| 123 | + $wgOut->showErrorPage( 'openiderror', 'openiderrortext' ); |
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | global $wgUser; |
128 | 128 | |
129 | | - switch ($request->mode) { |
| 129 | + switch ( $request->mode ) { |
130 | 130 | case "checkid_setup": |
131 | | - $response = $this->Check($server, $request, $sreg, false); |
| 131 | + $response = $this->Check( $server, $request, $sreg, false ); |
132 | 132 | break; |
133 | 133 | case "checkid_immediate": |
134 | | - $response = $this->Check($server, $request, $sreg, true); |
| 134 | + $response = $this->Check( $server, $request, $sreg, true ); |
135 | 135 | break; |
136 | 136 | default: |
137 | 137 | # For all the other parts, just let the libs do it |
138 | | - $response =& $server->handleRequest($request); |
| 138 | + $response =& $server->handleRequest( $request ); |
139 | 139 | } |
140 | 140 | |
141 | 141 | # OpenIDServerCheck returns NULL if some output (like a form) |
142 | 142 | # has been done |
143 | 143 | |
144 | | - if (isset($response)) { |
| 144 | + if ( isset( $response ) ) { |
145 | 145 | # We're done; clear values |
146 | 146 | $this->ClearValues(); |
147 | | - $this->Response($server, $response); |
| 147 | + $this->Response( $server, $response ); |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
— | — | @@ -151,8 +151,8 @@ |
152 | 152 | # for some requests |
153 | 153 | |
154 | 154 | function Url() { |
155 | | - $nt = Title::makeTitleSafe(NS_SPECIAL, 'OpenIDServer'); |
156 | | - if (isset($nt)) { |
| 155 | + $nt = Title::makeTitleSafe( NS_SPECIAL, 'OpenIDServer' ); |
| 156 | + if ( isset( $nt ) ) { |
157 | 157 | return $nt->getFullURL(); |
158 | 158 | } else { |
159 | 159 | return NULL; |
— | — | @@ -165,97 +165,97 @@ |
166 | 166 | global $wgOpenIDServerStorePath, |
167 | 167 | $wgOpenIDServerStoreType; |
168 | 168 | |
169 | | - $store = $this->getOpenIDStore($wgOpenIDServerStoreType, |
| 169 | + $store = $this->getOpenIDStore( $wgOpenIDServerStoreType, |
170 | 170 | 'server', |
171 | | - array('path' => $wgOpenIDServerStorePath)); |
| 171 | + array( 'path' => $wgOpenIDServerStorePath ) ); |
172 | 172 | |
173 | | - return new Auth_OpenID_Server($store, $this->serverUrl()); |
| 173 | + return new Auth_OpenID_Server( $store, $this->serverUrl() ); |
174 | 174 | } |
175 | 175 | |
176 | 176 | # Checks a validation request. $imm means don't run any UI. |
177 | 177 | # Fairly meticulous and step-by step, and uses assertions |
178 | 178 | # to point out assumptions at each step. |
179 | 179 | # |
180 | | - # XXX: this should probably be broken up into multiple functions for |
| 180 | + # FIXME: this should probably be broken up into multiple functions for |
181 | 181 | # clarity. |
182 | 182 | |
183 | | - function Check($server, $request, $sreg, $imm = true) { |
| 183 | + function Check( $server, $request, $sreg, $imm = true ) { |
184 | 184 | |
185 | 185 | global $wgUser, $wgOut; |
186 | 186 | |
187 | | - assert(isset($wgUser) && isset($wgOut)); |
188 | | - assert(isset($server)); |
189 | | - assert(isset($request)); |
190 | | - assert(isset($sreg)); |
191 | | - assert(isset($imm) && is_bool($imm)); |
| 187 | + assert( isset( $wgUser ) && isset( $wgOut ) ); |
| 188 | + assert( isset( $server ) ); |
| 189 | + assert( isset( $request ) ); |
| 190 | + assert( isset( $sreg ) ); |
| 191 | + assert( isset( $imm ) && is_bool( $imm ) ); |
192 | 192 | |
193 | 193 | # Is the passed identity URL a user page? |
194 | 194 | |
195 | 195 | $url = $request->identity; |
196 | 196 | |
197 | | - assert(isset($url) && strlen($url) > 0); |
| 197 | + assert( isset( $url ) && strlen( $url ) > 0 ); |
198 | 198 | |
199 | | - $name = $this->UrlToUserName($url); |
| 199 | + $name = $this->UrlToUserName( $url ); |
200 | 200 | |
201 | | - if (!isset($name) || strlen($name) == 0) { |
202 | | - wfDebug("OpenID: '$url' not a user page.\n"); |
203 | | - return $request->answer(false, $this->serverUrl()); |
| 201 | + if ( !isset( $name ) || strlen( $name ) == 0 ) { |
| 202 | + wfDebug( "OpenID: '$url' not a user page.\n" ); |
| 203 | + return $request->answer( false, $this->serverUrl() ); |
204 | 204 | } |
205 | 205 | |
206 | | - assert(isset($name) && strlen($name) > 0); |
| 206 | + assert( isset( $name ) && strlen( $name ) > 0 ); |
207 | 207 | |
208 | 208 | # Is there a logged in user? |
209 | 209 | |
210 | | - if ($wgUser->getId() == 0) { |
211 | | - wfDebug("OpenID: User not logged in.\n"); |
212 | | - if ($imm) { |
213 | | - return $request->answer(false, $this->serverUrl()); |
| 210 | + if ( $wgUser->getId() == 0 ) { |
| 211 | + wfDebug( "OpenID: User not logged in.\n" ); |
| 212 | + if ( $imm ) { |
| 213 | + return $request->answer( false, $this->serverUrl() ); |
214 | 214 | } else { |
215 | 215 | # Bank these for later |
216 | | - $this->SaveValues($request, $sreg); |
217 | | - $this->LoginForm($request); |
| 216 | + $this->SaveValues( $request, $sreg ); |
| 217 | + $this->LoginForm( $request ); |
218 | 218 | return NULL; |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | | - assert($wgUser->getId() != 0); |
| 222 | + assert( $wgUser->getId() != 0 ); |
223 | 223 | |
224 | 224 | # Is the user page for the logged-in user? |
225 | 225 | |
226 | | - $user = User::newFromName($name); |
| 226 | + $user = User::newFromName( $name ); |
227 | 227 | |
228 | | - if (!isset($user) || |
229 | | - $user->getId() != $wgUser->getId()) { |
230 | | - wfDebug("OpenID: User from url not logged in user.\n"); |
231 | | - return $request->answer(false, $this->serverUrl()); |
| 228 | + if ( !isset( $user ) || |
| 229 | + $user->getId() != $wgUser->getId() ) { |
| 230 | + wfDebug( "OpenID: User from url not logged in user.\n" ); |
| 231 | + return $request->answer( false, $this->serverUrl() ); |
232 | 232 | } |
233 | 233 | |
234 | | - assert(isset($user) && $user->getId() == $wgUser->getId() && $user->getId() != 0); |
| 234 | + assert( isset( $user ) && $user->getId() == $wgUser->getId() && $user->getId() != 0 ); |
235 | 235 | |
236 | 236 | # Is the user an OpenID user? |
237 | 237 | |
238 | | - $openid = $this->getUserUrl($user); |
| 238 | + $openid = $this->getUserUrl( $user ); |
239 | 239 | |
240 | | - if (isset($openid) && strlen($openid) > 0) { |
241 | | - wfDebug("OpenID: Not one of our users; logs in with OpenID.\n"); |
242 | | - return $request->answer(false, $this->serverUrl()); |
| 240 | + if ( isset( $openid ) && strlen( $openid ) > 0 ) { |
| 241 | + wfDebug( "OpenID: Not one of our users; logs in with OpenID.\n" ); |
| 242 | + return $request->answer( false, $this->serverUrl() ); |
243 | 243 | } |
244 | 244 | |
245 | | - assert(is_array($sreg)); |
| 245 | + assert( is_array( $sreg ) ); |
246 | 246 | |
247 | 247 | # Does the request require sreg fields that the user has not specified? |
248 | 248 | |
249 | | - if (array_key_exists('required', $sreg)) { |
| 249 | + if ( array_key_exists( 'required', $sreg ) ) { |
250 | 250 | $notFound = false; |
251 | | - foreach ($sreg['required'] as $reqfield) { |
252 | | - if (is_null($this->GetUserField($user, $reqfield))) { |
| 251 | + foreach ( $sreg['required'] as $reqfield ) { |
| 252 | + if ( is_null( $this->GetUserField( $user, $reqfield ) ) ) { |
253 | 253 | $notFound = true; |
254 | 254 | break; |
255 | 255 | } |
256 | 256 | } |
257 | | - if ($notFound) { |
258 | | - wfDebug("OpenID: Consumer demands info we don't have.\n"); |
259 | | - return $request->answer(false, $this->serverUrl()); |
| 257 | + if ( $notFound ) { |
| 258 | + wfDebug( "OpenID: Consumer demands info we don't have.\n" ); |
| 259 | + return $request->answer( false, $this->serverUrl() ); |
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
— | — | @@ -263,71 +263,71 @@ |
264 | 264 | |
265 | 265 | $trust_root = $request->trust_root; |
266 | 266 | |
267 | | - assert(isset($trust_root) && is_string($trust_root) && strlen($trust_root) > 0); |
| 267 | + assert( isset( $trust_root ) && is_string( $trust_root ) && strlen( $trust_root ) > 0 ); |
268 | 268 | |
269 | | - $trust = $this->GetUserTrust($user, $trust_root); |
| 269 | + $trust = $this->GetUserTrust( $user, $trust_root ); |
270 | 270 | |
271 | 271 | # Is there a trust record? |
272 | 272 | |
273 | | - if (is_null($trust)) { |
274 | | - wfDebug("OpenID: No trust record.\n"); |
275 | | - if ($imm) { |
276 | | - return $request->answer(false, $this->serverUrl()); |
| 273 | + if ( is_null( $trust ) ) { |
| 274 | + wfDebug( "OpenID: No trust record.\n" ); |
| 275 | + if ( $imm ) { |
| 276 | + return $request->answer( false, $this->serverUrl() ); |
277 | 277 | } else { |
278 | 278 | # Bank these for later |
279 | | - $this->SaveValues($request, $sreg); |
280 | | - $this->TrustForm($request, $sreg); |
| 279 | + $this->SaveValues( $request, $sreg ); |
| 280 | + $this->TrustForm( $request, $sreg ); |
281 | 281 | return NULL; |
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | | - assert(!is_null($trust)); |
| 285 | + assert( !is_null( $trust ) ); |
286 | 286 | |
287 | 287 | # Is the trust record _not_ to allow trust? |
288 | 288 | # NB: exactly equal |
289 | 289 | |
290 | | - if ($trust === false) { |
291 | | - wfDebug("OpenID: User specified not to allow trust.\n"); |
292 | | - return $request->answer(false, $this->serverUrl()); |
| 290 | + if ( $trust === false ) { |
| 291 | + wfDebug( "OpenID: User specified not to allow trust.\n" ); |
| 292 | + return $request->answer( false, $this->serverUrl() ); |
293 | 293 | } |
294 | 294 | |
295 | | - assert(isset($trust) && is_array($trust)); |
| 295 | + assert( isset( $trust ) && is_array( $trust ) ); |
296 | 296 | |
297 | 297 | # Does the request require sreg fields that the user has |
298 | 298 | # not allowed us to pass, or has not specified? |
299 | 299 | |
300 | | - if (array_key_exists('required', $sreg)) { |
| 300 | + if ( array_key_exists( 'required', $sreg ) ) { |
301 | 301 | $notFound = false; |
302 | | - foreach ($sreg['required'] as $reqfield) { |
303 | | - if (!in_array($reqfield, $trust) || |
304 | | - is_null($this->GetUserField($user, $reqfield))) { |
| 302 | + foreach ( $sreg['required'] as $reqfield ) { |
| 303 | + if ( !in_array( $reqfield, $trust ) || |
| 304 | + is_null( $this->GetUserField( $user, $reqfield ) ) ) { |
305 | 305 | $notFound = true; |
306 | 306 | break; |
307 | 307 | } |
308 | 308 | } |
309 | | - if ($notFound) { |
310 | | - wfDebug("OpenID: Consumer demands info user doesn't want shared.\n"); |
311 | | - return $request->answer(false, $this->serverUrl()); |
| 309 | + if ( $notFound ) { |
| 310 | + wfDebug( "OpenID: Consumer demands info user doesn't want shared.\n" ); |
| 311 | + return $request->answer( false, $this->serverUrl() ); |
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | | - # assert(all required sreg fields are in $trust) |
| 315 | + # assert(all required sreg fields are in $trust) |
316 | 316 | |
317 | | - # XXX: run a hook here to check |
| 317 | + # FIXME: run a hook here to check |
318 | 318 | |
319 | 319 | # SUCCESS |
320 | 320 | |
321 | | - $response_fields = array_intersect(array_unique(array_merge($sreg['required'], $sreg['optional'])), |
322 | | - $trust); |
| 321 | + $response_fields = array_intersect( array_unique( array_merge( $sreg['required'], $sreg['optional'] ) ), |
| 322 | + $trust ); |
323 | 323 | |
324 | | - $response = $request->answer(true); |
| 324 | + $response = $request->answer( true ); |
325 | 325 | |
326 | | - assert(isset($response)); |
| 326 | + assert( isset( $response ) ); |
327 | 327 | |
328 | | - foreach ($response_fields as $field) { |
329 | | - $value = $this->GetUserField($user, $field); |
330 | | - if (!is_null($value)) { |
331 | | - $response->addField('sreg', $field, $value); |
| 328 | + foreach ( $response_fields as $field ) { |
| 329 | + $value = $this->GetUserField( $user, $field ); |
| 330 | + if ( !is_null( $value ) ) { |
| 331 | + $response->addField( 'sreg', $field, $value ); |
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
— | — | @@ -340,53 +340,53 @@ |
341 | 341 | # * false -> stored trust preference is not to trust |
342 | 342 | # * array -> possibly empty array of allowed profile fields; trust is OK |
343 | 343 | |
344 | | - function GetUserTrust($user, $trust_root) { |
345 | | - static $allFields = array('nickname', 'fullname', 'email', 'language'); |
| 344 | + function GetUserTrust( $user, $trust_root ) { |
| 345 | + static $allFields = array( 'nickname', 'fullname', 'email', 'language' ); |
346 | 346 | global $wgOpenIDServerForceAllowTrust; |
347 | 347 | |
348 | | - foreach ($wgOpenIDServerForceAllowTrust as $force) { |
349 | | - if (preg_match($force, $trust_root)) { |
| 348 | + foreach ( $wgOpenIDServerForceAllowTrust as $force ) { |
| 349 | + if ( preg_match( $force, $trust_root ) ) { |
350 | 350 | return $allFields; |
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | | - $trust_array = $this->GetUserTrustArray($user); |
| 354 | + $trust_array = $this->GetUserTrustArray( $user ); |
355 | 355 | |
356 | | - if (array_key_exists($trust_root, $trust_array)) { |
| 356 | + if ( array_key_exists( $trust_root, $trust_array ) ) { |
357 | 357 | return $trust_array[$trust_root]; |
358 | 358 | } else { |
359 | 359 | return null; # Unspecified trust |
360 | 360 | } |
361 | 361 | } |
362 | 362 | |
363 | | - function SetUserTrust(&$user, $trust_root, $value) { |
| 363 | + function SetUserTrust( &$user, $trust_root, $value ) { |
364 | 364 | |
365 | | - $trust_array = $this->GetUserTrustArray($user); |
| 365 | + $trust_array = $this->GetUserTrustArray( $user ); |
366 | 366 | |
367 | | - if (is_null($value)) { |
368 | | - if (array_key_exists($trust_root, $trust_array)) { |
369 | | - unset($trust_array[$trust_root]); |
| 367 | + if ( is_null( $value ) ) { |
| 368 | + if ( array_key_exists( $trust_root, $trust_array ) ) { |
| 369 | + unset( $trust_array[$trust_root] ); |
370 | 370 | } |
371 | 371 | } else { |
372 | 372 | $trust_array[$trust_root] = $value; |
373 | 373 | } |
374 | 374 | |
375 | | - $this->SetUserTrustArray($user, $trust_array); |
| 375 | + $this->SetUserTrustArray( $user, $trust_array ); |
376 | 376 | } |
377 | 377 | |
378 | | - function GetUserTrustArray($user) { |
| 378 | + function GetUserTrustArray( $user ) { |
379 | 379 | $trust_array = array(); |
380 | | - $trust_str = $user->getOption('openid_trust'); |
381 | | - if (strlen($trust_str) > 0) { |
382 | | - $trust_records = explode("\x1E", $trust_str); |
383 | | - foreach ($trust_records as $record) { |
384 | | - $fields = explode("\x1F", $record); |
385 | | - $trust_root = array_shift($fields); |
386 | | - if (count($fields) == 1 && strcmp($fields[0], 'no') == 0) { |
| 380 | + $trust_str = $user->getOption( 'openid_trust' ); |
| 381 | + if ( strlen( $trust_str ) > 0 ) { |
| 382 | + $trust_records = explode( "\x1E", $trust_str ); |
| 383 | + foreach ( $trust_records as $record ) { |
| 384 | + $fields = explode( "\x1F", $record ); |
| 385 | + $trust_root = array_shift( $fields ); |
| 386 | + if ( count( $fields ) == 1 && strcmp( $fields[0], 'no' ) == 0 ) { |
387 | 387 | $trust_array[$trust_root] = false; |
388 | 388 | } else { |
389 | | - $fields = array_map('trim', $fields); |
390 | | - $fields = array_filter($fields, array($this, 'ValidField')); |
| 389 | + $fields = array_map( 'trim', $fields ); |
| 390 | + $fields = array_filter( $fields, array( $this, 'ValidField' ) ); |
391 | 391 | $trust_array[$trust_root] = $fields; |
392 | 392 | } |
393 | 393 | } |
— | — | @@ -394,62 +394,62 @@ |
395 | 395 | return $trust_array; |
396 | 396 | } |
397 | 397 | |
398 | | - function SetUserTrustArray(&$user, $arr) { |
| 398 | + function SetUserTrustArray( &$user, $arr ) { |
399 | 399 | $trust_records = array(); |
400 | | - foreach ($arr as $root => $value) { |
401 | | - if ($value === false) { |
402 | | - $record = implode("\x1F", array($root, 'no')); |
403 | | - } else if (is_array($value)) { |
404 | | - if (count($value) == 0) { |
| 400 | + foreach ( $arr as $root => $value ) { |
| 401 | + if ( $value === false ) { |
| 402 | + $record = implode( "\x1F", array( $root, 'no' ) ); |
| 403 | + } else if ( is_array( $value ) ) { |
| 404 | + if ( count( $value ) == 0 ) { |
405 | 405 | $record = $root; |
406 | 406 | } else { |
407 | | - $value = array_map('trim', $value); |
408 | | - $value = array_filter($value, array($this, 'ValidField')); |
409 | | - $record = implode("\x1F", array_merge(array($root), $value)); |
| 407 | + $value = array_map( 'trim', $value ); |
| 408 | + $value = array_filter( $value, array( $this, 'ValidField' ) ); |
| 409 | + $record = implode( "\x1F", array_merge( array( $root ), $value ) ); |
410 | 410 | } |
411 | 411 | } else { |
412 | 412 | continue; |
413 | 413 | } |
414 | 414 | $trust_records[] = $record; |
415 | 415 | } |
416 | | - $trust_str = implode("\x1E", $trust_records); |
417 | | - $user->setOption('openid_trust', $trust_str); |
| 416 | + $trust_str = implode( "\x1E", $trust_records ); |
| 417 | + $user->setOption( 'openid_trust', $trust_str ); |
418 | 418 | } |
419 | 419 | |
420 | | - function ValidField($name) { |
421 | | - # XXX: eventually add timezone |
422 | | - static $fields = array('nickname', 'email', 'fullname', 'language'); |
423 | | - return in_array($name, $fields); |
| 420 | + function ValidField( $name ) { |
| 421 | + # FIXME: eventually add timezone |
| 422 | + static $fields = array( 'nickname', 'email', 'fullname', 'language' ); |
| 423 | + return in_array( $name, $fields ); |
424 | 424 | } |
425 | 425 | |
426 | | - function SregFromQuery($query) { |
427 | | - $sreg = array('required' => array(), 'optional' => array(), |
428 | | - 'policy_url' => NULL); |
429 | | - if (array_key_exists('openid.sreg.required', $query)) { |
430 | | - $sreg['required'] = explode(',', $query['openid.sreg.required']); |
| 426 | + function SregFromQuery( $query ) { |
| 427 | + $sreg = array( 'required' => array(), 'optional' => array(), |
| 428 | + 'policy_url' => NULL ); |
| 429 | + if ( array_key_exists( 'openid.sreg.required', $query ) ) { |
| 430 | + $sreg['required'] = explode( ',', $query['openid.sreg.required'] ); |
431 | 431 | } |
432 | | - if (array_key_exists('openid.sreg.optional', $query)) { |
433 | | - $sreg['optional'] = explode(',', $query['openid.sreg.optional']); |
| 432 | + if ( array_key_exists( 'openid.sreg.optional', $query ) ) { |
| 433 | + $sreg['optional'] = explode( ',', $query['openid.sreg.optional'] ); |
434 | 434 | } |
435 | | - if (array_key_exists('openid.sreg.policy_url', $query)) { |
| 435 | + if ( array_key_exists( 'openid.sreg.policy_url', $query ) ) { |
436 | 436 | $sreg['policy_url'] = $query['openid.sreg.policy_url']; |
437 | 437 | } |
438 | 438 | return $sreg; |
439 | 439 | } |
440 | 440 | |
441 | | - function SetUserField(&$user, $field, $value) { |
442 | | - switch ($field) { |
| 441 | + function SetUserField( &$user, $field, $value ) { |
| 442 | + switch ( $field ) { |
443 | 443 | case 'fullname': |
444 | | - $user->setRealName($value); |
| 444 | + $user->setRealName( $value ); |
445 | 445 | return true; |
446 | 446 | break; |
447 | 447 | case 'email': |
448 | 448 | # FIXME: deal with validation |
449 | | - $user->setEmail($value); |
| 449 | + $user->setEmail( $value ); |
450 | 450 | return true; |
451 | 451 | break; |
452 | 452 | case 'language': |
453 | | - $user->setOption('language', $value); |
| 453 | + $user->setOption( 'language', $value ); |
454 | 454 | return true; |
455 | 455 | break; |
456 | 456 | default: |
— | — | @@ -457,8 +457,8 @@ |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | | - function GetUserField($user, $field) { |
462 | | - switch ($field) { |
| 461 | + function GetUserField( $user, $field ) { |
| 462 | + switch ( $field ) { |
463 | 463 | case 'nickname': |
464 | 464 | return $user->getName(); |
465 | 465 | break; |
— | — | @@ -469,29 +469,29 @@ |
470 | 470 | return $user->getEmail(); |
471 | 471 | break; |
472 | 472 | case 'language': |
473 | | - return $user->getOption('language'); |
| 473 | + return $user->getOption( 'language' ); |
474 | 474 | break; |
475 | 475 | default: |
476 | 476 | return NULL; |
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | | - function Response(&$server, &$response) { |
| 480 | + function Response( &$server, &$response ) { |
481 | 481 | global $wgOut; |
482 | 482 | |
483 | | - assert(!is_null($server)); |
484 | | - assert(!is_null($response)); |
| 483 | + assert( !is_null( $server ) ); |
| 484 | + assert( !is_null( $response ) ); |
485 | 485 | |
486 | 486 | $wgOut->disable(); |
487 | 487 | |
488 | | - $wr =& $server->encodeResponse($response); |
| 488 | + $wr =& $server->encodeResponse( $response ); |
489 | 489 | |
490 | | - assert(!is_null($wr)); |
| 490 | + assert( !is_null( $wr ) ); |
491 | 491 | |
492 | | - header("Status: " . $wr->code); |
| 492 | + header( "Status: " . $wr->code ); |
493 | 493 | |
494 | | - foreach ($wr->headers as $k => $v) { |
495 | | - header("$k: $v"); |
| 494 | + foreach ( $wr->headers as $k => $v ) { |
| 495 | + header( "$k: $v" ); |
496 | 496 | } |
497 | 497 | |
498 | 498 | print $wr->body; |
— | — | @@ -499,43 +499,43 @@ |
500 | 500 | return; |
501 | 501 | } |
502 | 502 | |
503 | | - function LoginForm($request, $msg = null) { |
| 503 | + function LoginForm( $request, $msg = null ) { |
504 | 504 | |
505 | 505 | global $wgOut, $wgUser; |
506 | 506 | |
507 | 507 | $url = $request->identity; |
508 | | - $name = $this->UrlToUserName($url); |
| 508 | + $name = $this->UrlToUserName( $url ); |
509 | 509 | $trust_root = $request->trust_root; |
510 | 510 | |
511 | | - $instructions = wfMsg('openidserverlogininstructions', $url, $name, $trust_root); |
| 511 | + $instructions = wfMsg( 'openidserverlogininstructions', $url, $name, $trust_root ); |
512 | 512 | |
513 | | - $username = wfMsg('yourname'); |
514 | | - $password = wfMsg('yourpassword'); |
515 | | - $ok = wfMsg('ok'); |
516 | | - $cancel = wfMsg('cancel'); |
| 513 | + $username = wfMsg( 'yourname' ); |
| 514 | + $password = wfMsg( 'yourpassword' ); |
| 515 | + $ok = wfMsg( 'ok' ); |
| 516 | + $cancel = wfMsg( 'cancel' ); |
517 | 517 | |
518 | | - if (isset($msg)) { |
519 | | - $wgOut->addHTML("<p class='error'>{$msg}</p>"); |
| 518 | + if ( isset( $msg ) ) { |
| 519 | + $wgOut->addHTML( "<p class='error'>{$msg}</p>" ); |
520 | 520 | } |
521 | 521 | |
522 | 522 | $sk = $wgUser->getSkin(); |
523 | 523 | |
524 | | - $wgOut->addHTML("<p>{$instructions}</p>" . |
525 | | - '<form action="' . $sk->makeSpecialUrl('OpenIDServer/Login') . '" method="POST">' . |
| 524 | + $wgOut->addHTML( "<p>{$instructions}</p>" . |
| 525 | + '<form action="' . $sk->makeSpecialUrl( 'OpenIDServer/Login' ) . '" method="POST">' . |
526 | 526 | '<table>' . |
527 | 527 | "<tr><td><label for='username'>{$username}</label></td>" . |
528 | | - ' <td><span id="username">' . htmlspecialchars($name) . '</span></td></tr>' . |
| 528 | + ' <td><span id="username">' . htmlspecialchars( $name ) . '</span></td></tr>' . |
529 | 529 | "<tr><td><label for='password'>{$password}</label></td>" . |
530 | 530 | ' <td><input type="password" name="wpPassword" size="32" value="" /></td></tr>' . |
531 | 531 | "<tr><td colspan='2'><input type='submit' name='wpOK' value='{$ok}' /> <input type='submit' name='wpCancel' value='{$cancel}' /></td></tr>" . |
532 | 532 | '</table>' . |
533 | | - '</form>'); |
| 533 | + '</form>' ); |
534 | 534 | } |
535 | 535 | |
536 | | - function SaveValues($request, $sreg) { |
| 536 | + function SaveValues( $request, $sreg ) { |
537 | 537 | global $wgSessionStarted, $wgUser; |
538 | 538 | |
539 | | - if (!$wgSessionStarted) { |
| 539 | + if ( !$wgSessionStarted ) { |
540 | 540 | $wgUser->SetupSession(); |
541 | 541 | } |
542 | 542 | |
— | — | @@ -546,154 +546,154 @@ |
547 | 547 | } |
548 | 548 | |
549 | 549 | function FetchValues() { |
550 | | - return array($_SESSION['openid_server_request'], $_SESSION['openid_server_sreg']); |
| 550 | + return array( $_SESSION['openid_server_request'], $_SESSION['openid_server_sreg'] ); |
551 | 551 | } |
552 | 552 | |
553 | 553 | function ClearValues() { |
554 | | - unset($_SESSION['openid_server_request']); |
555 | | - unset($_SESSION['openid_server_sreg']); |
| 554 | + unset( $_SESSION['openid_server_request'] ); |
| 555 | + unset( $_SESSION['openid_server_sreg'] ); |
556 | 556 | return true; |
557 | 557 | } |
558 | 558 | |
559 | | - function serverLogin($request) { |
| 559 | + function serverLogin( $request ) { |
560 | 560 | |
561 | 561 | global $wgRequest, $wgUser; |
562 | 562 | |
563 | | - assert(isset($request)); |
| 563 | + assert( isset( $request ) ); |
564 | 564 | |
565 | | - assert(isset($wgRequest)); |
| 565 | + assert( isset( $wgRequest ) ); |
566 | 566 | |
567 | | - if ($wgRequest->getCheck('wpCancel')) { |
568 | | - return $request->answer(false); |
| 567 | + if ( $wgRequest->getCheck( 'wpCancel' ) ) { |
| 568 | + return $request->answer( false ); |
569 | 569 | } |
570 | 570 | |
571 | | - $password = $wgRequest->getText('wpPassword'); |
| 571 | + $password = $wgRequest->getText( 'wpPassword' ); |
572 | 572 | |
573 | | - if (!isset($password) || strlen($password) == 0) { |
574 | | - return wfMsg('wrongpasswordempty'); |
| 573 | + if ( !isset( $password ) || strlen( $password ) == 0 ) { |
| 574 | + return wfMsg( 'wrongpasswordempty' ); |
575 | 575 | } |
576 | 576 | |
577 | | - assert (isset($password) && strlen($password) > 0); |
| 577 | + assert ( isset( $password ) && strlen( $password ) > 0 ); |
578 | 578 | |
579 | 579 | $url = $request->identity; |
580 | 580 | |
581 | | - assert(isset($url) && is_string($url) && strlen($url) > 0); |
| 581 | + assert( isset( $url ) && is_string( $url ) && strlen( $url ) > 0 ); |
582 | 582 | |
583 | | - $name = $this->UrlToUserName($url); |
| 583 | + $name = $this->UrlToUserName( $url ); |
584 | 584 | |
585 | | - assert(isset($name) && is_string($name) && strlen($name) > 0); |
| 585 | + assert( isset( $name ) && is_string( $name ) && strlen( $name ) > 0 ); |
586 | 586 | |
587 | | - $user = User::newFromName($name); |
| 587 | + $user = User::newFromName( $name ); |
588 | 588 | |
589 | | - assert(isset($user)); |
| 589 | + assert( isset( $user ) ); |
590 | 590 | |
591 | | - if (!$user->checkPassword($password)) { |
592 | | - return wfMsg('wrongpassword'); |
| 591 | + if ( !$user->checkPassword( $password ) ) { |
| 592 | + return wfMsg( 'wrongpassword' ); |
593 | 593 | } else { |
594 | 594 | $id = $user->getId(); |
595 | 595 | $wgUser = $user; |
596 | 596 | $wgUser->SetupSession(); |
597 | 597 | $wgUser->SetCookies(); |
598 | | - wfRunHooks('UserLoginComplete', array(&$wgUser)); |
| 598 | + wfRunHooks( 'UserLoginComplete', array( &$wgUser ) ); |
599 | 599 | return false; |
600 | 600 | } |
601 | 601 | } |
602 | 602 | |
603 | | - function TrustForm($request, $sreg, $msg = NULL) { |
| 603 | + function TrustForm( $request, $sreg, $msg = NULL ) { |
604 | 604 | |
605 | 605 | global $wgOut, $wgUser; |
606 | 606 | |
607 | 607 | $url = $request->identity; |
608 | | - $name = $this->UrlToUserName($url); |
| 608 | + $name = $this->UrlToUserName( $url ); |
609 | 609 | $trust_root = $request->trust_root; |
610 | 610 | |
611 | | - $instructions = wfMsg('openidtrustinstructions', $trust_root); |
612 | | - $allow = wfMsg('openidallowtrust', $trust_root); |
| 611 | + $instructions = wfMsg( 'openidtrustinstructions', $trust_root ); |
| 612 | + $allow = wfMsg( 'openidallowtrust', $trust_root ); |
613 | 613 | |
614 | | - if (is_null($sreg['policy_url'])) { |
615 | | - $policy = wfMsg('openidnopolicy'); |
| 614 | + if ( is_null( $sreg['policy_url'] ) ) { |
| 615 | + $policy = wfMsg( 'openidnopolicy' ); |
616 | 616 | } else { |
617 | | - $policy = wfMsg('openidpolicy', $sreg['policy_url']); |
| 617 | + $policy = wfMsg( 'openidpolicy', $sreg['policy_url'] ); |
618 | 618 | } |
619 | 619 | |
620 | | - if (isset($msg)) { |
621 | | - $wgOut->addHTML("<p class='error'>{$msg}</p>"); |
| 620 | + if ( isset( $msg ) ) { |
| 621 | + $wgOut->addHTML( "<p class='error'>{$msg}</p>" ); |
622 | 622 | } |
623 | 623 | |
624 | | - $ok = wfMsg('ok'); |
625 | | - $cancel = wfMsg('cancel'); |
| 624 | + $ok = wfMsg( 'ok' ); |
| 625 | + $cancel = wfMsg( 'cancel' ); |
626 | 626 | |
627 | 627 | $sk = $wgUser->getSkin(); |
628 | 628 | |
629 | | - $wgOut->addHTML("<p>{$instructions}</p>" . |
630 | | - '<form action="' . $sk->makeSpecialUrl('OpenIDServer/Trust') . '" method="POST">' . |
| 629 | + $wgOut->addHTML( "<p>{$instructions}</p>" . |
| 630 | + '<form action="' . $sk->makeSpecialUrl( 'OpenIDServer/Trust' ) . '" method="POST">' . |
631 | 631 | '<input name="wpAllowTrust" type="checkbox" value="on" checked="checked" id="wpAllowTrust">' . |
632 | | - '<label for="wpAllowTrust">' . $allow . '</label><br />'); |
| 632 | + '<label for="wpAllowTrust">' . $allow . '</label><br />' ); |
633 | 633 | |
634 | | - $fields = array_filter(array_unique(array_merge($sreg['optional'], $sreg['required'])), |
635 | | - array($this, 'ValidField')); |
| 634 | + $fields = array_filter( array_unique( array_merge( $sreg['optional'], $sreg['required'] ) ), |
| 635 | + array( $this, 'ValidField' ) ); |
636 | 636 | |
637 | | - if (count($fields) > 0) { |
638 | | - $wgOut->addHTML('<table>'); |
639 | | - foreach ($fields as $field) { |
640 | | - $wgOut->addHTML("<tr>"); |
641 | | - $wgOut->addHTML("<th><label for='wpAllow{$field}'>"); |
642 | | - $wgOut->addHTML(wfMsg("openid$field")); |
643 | | - $wgOut->addHTML("</label></th>"); |
644 | | - $value = $this->GetUserField($wgUser, $field); |
645 | | - $wgOut->addHTML("</td>"); |
646 | | - $wgOut->addHTML("<td> " . ((is_null($value)) ? '' : $value) . "</td>"); |
647 | | - $wgOut->addHTML("<td>" . ((in_array($field, $sreg['required'])) ? wfMsg('openidrequired') : wfMsg('openidoptional')) . "</td>"); |
648 | | - $wgOut->addHTML("<td><input name='wpAllow{$field}' id='wpAllow{$field}' type='checkbox'"); |
649 | | - if (!is_null($value)) { |
650 | | - $wgOut->addHTML(" value='on' checked='checked' />"); |
| 637 | + if ( count( $fields ) > 0 ) { |
| 638 | + $wgOut->addHTML( '<table>' ); |
| 639 | + foreach ( $fields as $field ) { |
| 640 | + $wgOut->addHTML( "<tr>" ); |
| 641 | + $wgOut->addHTML( "<th><label for='wpAllow{$field}'>" ); |
| 642 | + $wgOut->addHTML( wfMsg( "openid$field" ) ); |
| 643 | + $wgOut->addHTML( "</label></th>" ); |
| 644 | + $value = $this->GetUserField( $wgUser, $field ); |
| 645 | + $wgOut->addHTML( "</td>" ); |
| 646 | + $wgOut->addHTML( "<td> " . ( ( is_null( $value ) ) ? '' : $value ) . "</td>" ); |
| 647 | + $wgOut->addHTML( "<td>" . ( ( in_array( $field, $sreg['required'] ) ) ? wfMsg( 'openidrequired' ) : wfMsg( 'openidoptional' ) ) . "</td>" ); |
| 648 | + $wgOut->addHTML( "<td><input name='wpAllow{$field}' id='wpAllow{$field}' type='checkbox'" ); |
| 649 | + if ( !is_null( $value ) ) { |
| 650 | + $wgOut->addHTML( " value='on' checked='checked' />" ); |
651 | 651 | } else { |
652 | | - $wgOut->addHTML(" disabled='disabled' />"); |
| 652 | + $wgOut->addHTML( " disabled='disabled' />" ); |
653 | 653 | } |
654 | | - $wgOut->addHTML("</tr>"); |
| 654 | + $wgOut->addHTML( "</tr>" ); |
655 | 655 | } |
656 | | - $wgOut->addHTML('</table>'); |
| 656 | + $wgOut->addHTML( '</table>' ); |
657 | 657 | } |
658 | | - $wgOut->addHTML("<input type='submit' name='wpOK' value='{$ok}' /> <input type='submit' name='wpCancel' value='{$cancel}' /></form>"); |
| 658 | + $wgOut->addHTML( "<input type='submit' name='wpOK' value='{$ok}' /> <input type='submit' name='wpCancel' value='{$cancel}' /></form>" ); |
659 | 659 | return NULL; |
660 | 660 | } |
661 | 661 | |
662 | | - function Trust($request, $sreg) { |
| 662 | + function Trust( $request, $sreg ) { |
663 | 663 | global $wgRequest, $wgUser; |
664 | 664 | |
665 | | - assert(isset($request)); |
666 | | - assert(isset($sreg)); |
667 | | - assert(isset($wgRequest)); |
| 665 | + assert( isset( $request ) ); |
| 666 | + assert( isset( $sreg ) ); |
| 667 | + assert( isset( $wgRequest ) ); |
668 | 668 | |
669 | | - if ($wgRequest->getCheck('wpCancel')) { |
670 | | - return $request->answer(false); |
| 669 | + if ( $wgRequest->getCheck( 'wpCancel' ) ) { |
| 670 | + return $request->answer( false ); |
671 | 671 | } |
672 | 672 | |
673 | 673 | $trust_root = $request->trust_root; |
674 | 674 | |
675 | | - assert(isset($trust_root) && strlen($trust_root) > 0); |
| 675 | + assert( isset( $trust_root ) && strlen( $trust_root ) > 0 ); |
676 | 676 | |
677 | 677 | # If they don't want us to allow trust, save that. |
678 | 678 | |
679 | | - if (!$wgRequest->getCheck('wpAllowTrust')) { |
| 679 | + if ( !$wgRequest->getCheck( 'wpAllowTrust' ) ) { |
680 | 680 | |
681 | | - $this->SetUserTrust($wgUser, $trust_root, false); |
| 681 | + $this->SetUserTrust( $wgUser, $trust_root, false ); |
682 | 682 | # Set'em and sav'em |
683 | 683 | $wgUser->saveSettings(); |
684 | 684 | } else { |
685 | 685 | |
686 | | - $fields = array_filter(array_unique(array_merge($sreg['optional'], $sreg['required'])), |
687 | | - array($this, 'ValidField')); |
| 686 | + $fields = array_filter( array_unique( array_merge( $sreg['optional'], $sreg['required'] ) ), |
| 687 | + array( $this, 'ValidField' ) ); |
688 | 688 | |
689 | 689 | $allow = array(); |
690 | 690 | |
691 | | - foreach ($fields as $field) { |
692 | | - if ($wgRequest->getCheck('wpAllow' . $field)) { |
| 691 | + foreach ( $fields as $field ) { |
| 692 | + if ( $wgRequest->getCheck( 'wpAllow' . $field ) ) { |
693 | 693 | $allow[] = $field; |
694 | 694 | } |
695 | 695 | } |
696 | 696 | |
697 | | - $this->SetUserTrust($wgUser, $trust_root, $allow); |
| 697 | + $this->SetUserTrust( $wgUser, $trust_root, $allow ); |
698 | 698 | # Set'em and sav'em |
699 | 699 | $wgUser->saveSettings(); |
700 | 700 | } |
— | — | @@ -702,40 +702,40 @@ |
703 | 703 | |
704 | 704 | # Converts an URL to a user name, if possible |
705 | 705 | |
706 | | - function UrlToUserName($url) { |
| 706 | + function UrlToUserName( $url ) { |
707 | 707 | |
708 | 708 | global $wgArticlePath, $wgServer; |
709 | 709 | |
710 | 710 | # URL must be a string |
711 | 711 | |
712 | | - if (!isset($url) || !is_string($url) || strlen($url) == 0) { |
| 712 | + if ( !isset( $url ) || !is_string( $url ) || strlen( $url ) == 0 ) { |
713 | 713 | return null; |
714 | 714 | } |
715 | 715 | |
716 | 716 | # it must start with our server, case doesn't matter |
717 | 717 | |
718 | | - if (strpos(strtolower($url), strtolower($wgServer)) !== 0) { |
| 718 | + if ( strpos( strtolower( $url ), strtolower( $wgServer ) ) !== 0 ) { |
719 | 719 | return null; |
720 | 720 | } |
721 | 721 | |
722 | | - $parts = parse_url($url); |
| 722 | + $parts = parse_url( $url ); |
723 | 723 | |
724 | 724 | $relative = $parts['path']; |
725 | | - if (!is_null($parts['query']) && strlen($parts['query']) > 0) { |
| 725 | + if ( !is_null( $parts['query'] ) && strlen( $parts['query'] ) > 0 ) { |
726 | 726 | $relative .= '?' . $parts['query']; |
727 | 727 | } |
728 | 728 | |
729 | 729 | # Use regexps to extract user name |
730 | 730 | |
731 | | - $pattern = str_replace('$1', '(.*)', $wgArticlePath); |
732 | | - $pattern = str_replace('?', '\?', $pattern); |
| 731 | + $pattern = str_replace( '$1', '(.*)', $wgArticlePath ); |
| 732 | + $pattern = str_replace( '?', '\?', $pattern ); |
733 | 733 | # Can't have a pound-sign in the relative, since that's for fragments |
734 | | - if (!preg_match("#$pattern#", $relative, $matches)) { |
| 734 | + if ( !preg_match( "#$pattern#", $relative, $matches ) ) { |
735 | 735 | return null; |
736 | 736 | } else { |
737 | | - $titletext = urldecode($matches[1]); |
738 | | - $nt = Title::newFromText($titletext); |
739 | | - if (is_null($nt) || $nt->getNamespace() != NS_USER) { |
| 737 | + $titletext = urldecode( $matches[1] ); |
| 738 | + $nt = Title::newFromText( $titletext ); |
| 739 | + if ( is_null( $nt ) || $nt->getNamespace() != NS_USER ) { |
740 | 740 | return null; |
741 | 741 | } else { |
742 | 742 | return $nt->getText(); |
— | — | @@ -744,6 +744,6 @@ |
745 | 745 | } |
746 | 746 | |
747 | 747 | function serverUrl() { |
748 | | - return $this->fullURL('OpenIDServer'); |
| 748 | + return $this->fullURL( 'OpenIDServer' ); |
749 | 749 | } |
750 | 750 | } |
Index: trunk/extensions/OpenID/SpecialOpenIDLogin.body.php |
— | — | @@ -22,18 +22,18 @@ |
23 | 23 | * @addtogroup Extensions |
24 | 24 | */ |
25 | 25 | |
26 | | -if (!defined('MEDIAWIKI')) |
27 | | - exit(1); |
| 26 | +if ( !defined( 'MEDIAWIKI' ) ) |
| 27 | + exit( 1 ); |
28 | 28 | |
29 | | -require_once("Auth/OpenID/Consumer.php"); |
| 29 | +require_once( "Auth/OpenID/Consumer.php" ); |
30 | 30 | |
31 | 31 | class SpecialOpenIDLogin extends SpecialOpenID { |
32 | 32 | |
33 | 33 | function SpecialOpenIDLogin() { |
34 | | - SpecialPage::SpecialPage("OpenIDLogin"); |
| 34 | + SpecialPage::SpecialPage( "OpenIDLogin" ); |
35 | 35 | } |
36 | 36 | |
37 | | - function execute($par) { |
| 37 | + function execute( $par ) { |
38 | 38 | global $wgRequest, $wgUser, $wgOut, $wgScriptPath, $wgOpenIDShowProviderIcons; |
39 | 39 | |
40 | 40 | wfLoadExtensionMessages( 'OpenID' ); |
— | — | @@ -46,25 +46,25 @@ |
47 | 47 | 'rel' => 'stylesheet', |
48 | 48 | 'type' => 'text/css', |
49 | 49 | 'media' => 'screen, projection', |
50 | | - 'href' => $oidScriptPath.($wgOpenIDShowProviderIcons ? '/skin/openid.css' : '/skin/openid-plain.css') |
51 | | - )); |
| 50 | + 'href' => $oidScriptPath . ( $wgOpenIDShowProviderIcons ? '/skin/openid.css' : '/skin/openid-plain.css' ) |
| 51 | + ) ); |
52 | 52 | |
53 | | - $wgOut->addScript('<script type="text/javascript" src="'.$oidScriptPath.'/skin/jquery-1.3.2.min.js"></script>'."\n"); |
54 | | - $wgOut->addScript('<script type="text/javascript" src="'.$oidScriptPath.'/skin/openid.js"></script>'."\n"); |
| 53 | + $wgOut->addScript( '<script type="text/javascript" src="' . $oidScriptPath . '/skin/jquery-1.3.2.min.js"></script>' . "\n" ); |
| 54 | + $wgOut->addScript( '<script type="text/javascript" src="' . $oidScriptPath . '/skin/openid.js"></script>' . "\n" ); |
55 | 55 | |
56 | | - if ($wgUser->getID() != 0) { |
| 56 | + if ( $wgUser->getID() != 0 ) { |
57 | 57 | $this->alreadyLoggedIn(); |
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | | - if ($wgRequest->getText('returnto')) { |
62 | | - $this->setReturnTo($wgRequest->getText('returnto')); |
| 61 | + if ( $wgRequest->getText( 'returnto' ) ) { |
| 62 | + $this->setReturnTo( $wgRequest->getText( 'returnto' ) ); |
63 | 63 | } |
64 | 64 | |
65 | | - $openid_url = $wgRequest->getText('openid_url'); |
| 65 | + $openid_url = $wgRequest->getText( 'openid_url' ); |
66 | 66 | |
67 | | - if (isset($openid_url) && strlen($openid_url) > 0) { |
68 | | - $this->login($openid_url); |
| 67 | + if ( isset( $openid_url ) && strlen( $openid_url ) > 0 ) { |
| 68 | + $this->login( $openid_url ); |
69 | 69 | } else { |
70 | 70 | $this->loginForm(); |
71 | 71 | } |
— | — | @@ -73,22 +73,22 @@ |
74 | 74 | function loginForm() { |
75 | 75 | global $wgOut, $wgUser, $wgOpenIDLoginLogoUrl, $wgOpenIDShowProviderIcons; |
76 | 76 | $sk = $wgUser->getSkin(); |
77 | | - $instructions = wfMsgExt('openidlogininstructions', array('parse')); |
| 77 | + $instructions = wfMsgExt( 'openidlogininstructions', array( 'parse' ) ); |
78 | 78 | |
79 | 79 | $formsHTML = ''; |
80 | 80 | |
81 | 81 | $largeButtonsHTML = '<div id="openid_large_providers">'; |
82 | | - foreach (OpenIDProvider::getLargeProviders() as $provider) { |
| 82 | + foreach ( OpenIDProvider::getLargeProviders() as $provider ) { |
83 | 83 | $largeButtonsHTML .= $provider->getLargeButtonHTML(); |
84 | 84 | $formsHTML .= $provider->getLoginFormHTML(); |
85 | 85 | } |
86 | 86 | $largeButtonsHTML .= '</div>'; |
87 | 87 | |
88 | 88 | $smallButtonsHTML = ''; |
89 | | - if ($wgOpenIDShowProviderIcons) { |
| 89 | + if ( $wgOpenIDShowProviderIcons ) { |
90 | 90 | $smallButtonsHTML .= '<div id="openid_small_providers_icons">'; |
91 | | - foreach (OpenIDProvider::getSmallProviders() as $provider) { |
92 | | - $smallButtonsHTML .= $provider->getSmallButtonHTML(); |
| 91 | + foreach ( OpenIDProvider::getSmallProviders() as $provider ) { |
| 92 | + $smallButtonsHTML .= $provider->getSmallButtonHTML(); |
93 | 93 | $formsHTML .= $provider->getLoginFormHTML(); |
94 | 94 | } |
95 | 95 | $smallButtonsHTML .= '</div>'; |
— | — | @@ -101,13 +101,13 @@ |
102 | 102 | |
103 | 103 | $i = 0; |
104 | 104 | $break = true; |
105 | | - foreach ($small as $provider) { |
106 | | - if ($break && $i > count($small)/2) { |
| 105 | + foreach ( $small as $provider ) { |
| 106 | + if ( $break && $i > count( $small ) / 2 ) { |
107 | 107 | $smallButtonsHTML .= '</ul><ul class="openid_small_providers_block">'; |
108 | 108 | $break = false; |
109 | 109 | } |
110 | 110 | |
111 | | - $smallButtonsHTML .= '<li>'.$provider->getSmallButtonHTML().'</li>'; |
| 111 | + $smallButtonsHTML .= '<li>' . $provider->getSmallButtonHTML() . '</li>'; |
112 | 112 | |
113 | 113 | $formsHTML .= $provider->getLoginFormHTML(); |
114 | 114 | $i++; |
— | — | @@ -116,25 +116,25 @@ |
117 | 117 | $smallButtonsHTML .= '</div>'; |
118 | 118 | } |
119 | 119 | |
120 | | - $wgOut->addHTML('<form id="openid_form" action="' . $sk->makeSpecialUrl('OpenIDLogin') . '" method="POST" onsubmit="openid.update()"">' . |
121 | | - '<fieldset><legend>' . wfMsg('openidsigninorcreateaccount') . '</legend>' . |
| 120 | + $wgOut->addHTML( '<form id="openid_form" action="' . $sk->makeSpecialUrl( 'OpenIDLogin' ) . '" method="POST" onsubmit="openid.update()"">' . |
| 121 | + '<fieldset><legend>' . wfMsg( 'openidsigninorcreateaccount' ) . '</legend>' . |
122 | 122 | $largeButtonsHTML . |
123 | 123 | '<div id="openid_input_area">' . |
124 | 124 | $formsHTML . |
125 | | - '</div>' . |
| 125 | + '</div>' . |
126 | 126 | $smallButtonsHTML . |
127 | 127 | '</fieldset></form>' . |
128 | 128 | $instructions |
129 | 129 | ); |
130 | 130 | } |
131 | 131 | |
132 | | - function toUserName($openid) { |
133 | | - if (Services_Yadis_identifierScheme($openid) == 'XRI') { |
134 | | - wfDebug("OpenID: Handling an XRI: $openid\n"); |
135 | | - return $this->toUserNameXri($openid); |
| 132 | + function toUserName( $openid ) { |
| 133 | + if ( Services_Yadis_identifierScheme( $openid ) == 'XRI' ) { |
| 134 | + wfDebug( "OpenID: Handling an XRI: $openid\n" ); |
| 135 | + return $this->toUserNameXri( $openid ); |
136 | 136 | } else { |
137 | | - wfDebug("OpenID: Handling an URL: $openid\n"); |
138 | | - return $this->toUserNameUrl($openid); |
| 137 | + wfDebug( "OpenID: Handling an URL: $openid\n" ); |
| 138 | + return $this->toUserNameUrl( $openid ); |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
— | — | @@ -146,58 +146,58 @@ |
147 | 147 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
148 | 148 | $wgOut->setArticleRelated( false ); |
149 | 149 | $wgOut->addWikiText( wfMsg( 'openidalreadyloggedin', $wgUser->getName() ) ); |
150 | | - $wgOut->returnToMain(false, $this->returnTo() ); |
| 150 | + $wgOut->returnToMain( false, $this->returnTo() ); |
151 | 151 | } |
152 | 152 | |
153 | | - function setUserUrl($user, $url) { |
154 | | - $other = $this->getUserUrl($user); |
155 | | - if (isset($other)) { |
156 | | - $this->updateUserUrl($user, $url); |
| 153 | + function setUserUrl( $user, $url ) { |
| 154 | + $other = $this->getUserUrl( $user ); |
| 155 | + if ( isset( $other ) ) { |
| 156 | + $this->updateUserUrl( $user, $url ); |
157 | 157 | } else { |
158 | | - $this->insertUserUrl($user, $url); |
| 158 | + $this->insertUserUrl( $user, $url ); |
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | | - function insertUserUrl($user, $url) { |
| 162 | + function insertUserUrl( $user, $url ) { |
163 | 163 | global $wgSharedDB, $wgDBname; |
164 | 164 | $dbw =& wfGetDB( DB_MASTER ); |
165 | 165 | |
166 | | - if (isset($wgSharedDB)) { |
| 166 | + if ( isset( $wgSharedDB ) ) { |
167 | 167 | # It would be nicer to get the existing dbname |
168 | 168 | # and save it, but it's not possible |
169 | | - $dbw->selectDB($wgSharedDB); |
| 169 | + $dbw->selectDB( $wgSharedDB ); |
170 | 170 | } |
171 | 171 | |
172 | | - $dbw->insert('user_openid', array('uoi_user' => $user->getId(), |
173 | | - 'uoi_openid' => $url)); |
| 172 | + $dbw->insert( 'user_openid', array( 'uoi_user' => $user->getId(), |
| 173 | + 'uoi_openid' => $url ) ); |
174 | 174 | |
175 | | - if (isset($wgSharedDB)) { |
176 | | - $dbw->selectDB($wgDBname); |
| 175 | + if ( isset( $wgSharedDB ) ) { |
| 176 | + $dbw->selectDB( $wgDBname ); |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | | - function updateUserUrl($user, $url) { |
| 180 | + function updateUserUrl( $user, $url ) { |
181 | 181 | global $wgSharedDB, $wgDBname; |
182 | 182 | $dbw =& wfGetDB( DB_MASTER ); |
183 | 183 | |
184 | | - if (isset($wgSharedDB)) { |
| 184 | + if ( isset( $wgSharedDB ) ) { |
185 | 185 | # It would be nicer to get the existing dbname |
186 | 186 | # and save it, but it's not possible |
187 | | - $dbw->selectDB($wgSharedDB); |
| 187 | + $dbw->selectDB( $wgSharedDB ); |
188 | 188 | } |
189 | 189 | |
190 | | - $dbw->set('user_openid', 'uoi_openid', $url, |
191 | | - 'uoi_user = ' . $user->getID()); |
| 190 | + $dbw->set( 'user_openid', 'uoi_openid', $url, |
| 191 | + 'uoi_user = ' . $user->getID() ); |
192 | 192 | |
193 | | - if (isset($wgSharedDB)) { |
194 | | - $dbw->selectDB($wgDBname); |
| 193 | + if ( isset( $wgSharedDB ) ) { |
| 194 | + $dbw->selectDB( $wgDBname ); |
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | | - function saveValues($response, $sreg) { |
| 198 | + function saveValues( $response, $sreg ) { |
199 | 199 | global $wgSessionStarted, $wgUser; |
200 | 200 | |
201 | | - if (!$wgSessionStarted) { |
| 201 | + if ( !$wgSessionStarted ) { |
202 | 202 | $wgUser->SetupSession(); |
203 | 203 | } |
204 | 204 | |
— | — | @@ -208,20 +208,20 @@ |
209 | 209 | } |
210 | 210 | |
211 | 211 | function clearValues() { |
212 | | - unset($_SESSION['openid_consumer_response']); |
213 | | - unset($_SESSION['openid_consumer_sreg']); |
| 212 | + unset( $_SESSION['openid_consumer_response'] ); |
| 213 | + unset( $_SESSION['openid_consumer_sreg'] ); |
214 | 214 | return true; |
215 | 215 | } |
216 | 216 | |
217 | 217 | function fetchValues() { |
218 | | - return array($_SESSION['openid_consumer_response'], $_SESSION['openid_consumer_sreg']); |
| 218 | + return array( $_SESSION['openid_consumer_response'], $_SESSION['openid_consumer_sreg'] ); |
219 | 219 | } |
220 | 220 | |
221 | 221 | function returnTo() { |
222 | 222 | return $_SESSION['openid_consumer_returnto']; |
223 | 223 | } |
224 | 224 | |
225 | | - function setReturnTo($returnto) { |
| 225 | + function setReturnTo( $returnto ) { |
226 | 226 | $_SESSION['openid_consumer_returnto'] = $returnto; |
227 | 227 | } |
228 | 228 | } |
Index: trunk/extensions/OpenID/SpecialOpenID.body.php |
— | — | @@ -25,69 +25,69 @@ |
26 | 26 | # FIXME: for login(); figure out better way to share this code |
27 | 27 | # between Login and Convert |
28 | 28 | |
29 | | -require_once("Auth/OpenID/Consumer.php"); |
30 | | -require_once("Auth/OpenID/SReg.php"); |
31 | | -require_once("Auth/OpenID/FileStore.php"); |
| 29 | +require_once( "Auth/OpenID/Consumer.php" ); |
| 30 | +require_once( "Auth/OpenID/SReg.php" ); |
| 31 | +require_once( "Auth/OpenID/FileStore.php" ); |
32 | 32 | |
33 | 33 | class SpecialOpenID extends SpecialPage { |
34 | 34 | |
35 | | - function getOpenIDStore($storeType, $prefix, $options) { |
36 | | - global $wgOut; |
| 35 | + function getOpenIDStore( $storeType, $prefix, $options ) { |
| 36 | + global $wgOut; |
37 | 37 | |
38 | 38 | # FIXME: support other kinds of store |
39 | 39 | # XXX: used to support memc, now use memcached from php-openid |
40 | 40 | |
41 | | - switch ($storeType) { |
| 41 | + switch ( $storeType ) { |
42 | 42 | |
43 | | - case 'file': |
| 43 | + case 'file': |
44 | 44 | # Auto-create path if it doesn't exist |
45 | | - if (!is_dir($options['path'])) { |
46 | | - if (!mkdir($options['path'], 0770, true)) { |
47 | | - $wgOut->showErrorPage('openidconfigerror', 'openidconfigerrortext'); |
| 45 | + if ( !is_dir( $options['path'] ) ) { |
| 46 | + if ( !mkdir( $options['path'], 0770, true ) ) { |
| 47 | + $wgOut->showErrorPage( 'openidconfigerror', 'openidconfigerrortext' ); |
48 | 48 | return NULL; |
49 | 49 | } |
50 | 50 | } |
51 | | - return new Auth_OpenID_FileStore($options['path']); |
| 51 | + return new Auth_OpenID_FileStore( $options['path'] ); |
52 | 52 | |
53 | 53 | default: |
54 | | - $wgOut->showErrorPage('openidconfigerror', 'openidconfigerrortext'); |
55 | | - } |
| 54 | + $wgOut->showErrorPage( 'openidconfigerror', 'openidconfigerrortext' ); |
| 55 | + } |
56 | 56 | } |
57 | 57 | |
58 | | - function xriBase($xri) { |
59 | | - if (substr($xri, 0, 6) == 'xri://') { |
60 | | - return substr($xri, 6); |
| 58 | + function xriBase( $xri ) { |
| 59 | + if ( substr( $xri, 0, 6 ) == 'xri://' ) { |
| 60 | + return substr( $xri, 6 ); |
61 | 61 | } else { |
62 | 62 | return $xri; |
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | | - function xriToUrl($xri) { |
67 | | - return 'http://xri.net/' . OpenIDXriBase($xri); |
| 66 | + function xriToUrl( $xri ) { |
| 67 | + return 'http://xri.net/' . OpenIDXriBase( $xri ); |
68 | 68 | } |
69 | 69 | |
70 | | - static function OpenIDToUrl($openid) { |
| 70 | + static function OpenIDToUrl( $openid ) { |
71 | 71 | /* ID is either an URL already or an i-name */ |
72 | | - if (Auth_Yadis_identifierScheme($openid) == 'XRI') { |
73 | | - return OpenIDXriToUrl($openid); |
| 72 | + if ( Auth_Yadis_identifierScheme( $openid ) == 'XRI' ) { |
| 73 | + return OpenIDXriToUrl( $openid ); |
74 | 74 | } else { |
75 | 75 | return $openid; |
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | | - function interwikiExpand($openid_url) { |
| 79 | + function interwikiExpand( $openid_url ) { |
80 | 80 | # try to make it into a title object |
81 | | - $nt = Title::newFromText($openid_url); |
| 81 | + $nt = Title::newFromText( $openid_url ); |
82 | 82 | # If it's got an iw, return that |
83 | | - if (!is_null($nt) && !is_null($nt->getInterwiki()) |
84 | | - && strlen($nt->getInterwiki()) > 0) { |
| 83 | + if ( !is_null( $nt ) && !is_null( $nt->getInterwiki() ) |
| 84 | + && strlen( $nt->getInterwiki() ) > 0 ) { |
85 | 85 | return $nt->getFullUrl(); |
86 | 86 | } else { |
87 | 87 | return $openid_url; |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | | - static function getUserUrl($user) { |
| 91 | + static function getUserUrl( $user ) { |
92 | 92 | $openid_url = null; |
93 | 93 | |
94 | 94 | if ( isset( $user ) && $user->getId() != 0 ) { |
— | — | @@ -122,26 +122,26 @@ |
123 | 123 | function getConsumer() { |
124 | 124 | global $wgOpenIDConsumerStoreType, $wgOpenIDConsumerStorePath; |
125 | 125 | |
126 | | - $store = $this->getOpenIDStore($wgOpenIDConsumerStoreType, |
| 126 | + $store = $this->getOpenIDStore( $wgOpenIDConsumerStoreType, |
127 | 127 | 'consumer', |
128 | | - array('path' => $wgOpenIDConsumerStorePath)); |
| 128 | + array( 'path' => $wgOpenIDConsumerStorePath ) ); |
129 | 129 | |
130 | | - return new Auth_OpenID_Consumer($store); |
| 130 | + return new Auth_OpenID_Consumer( $store ); |
131 | 131 | } |
132 | 132 | |
133 | | - function fullUrl($title) { |
134 | | - $nt = Title::makeTitleSafe(NS_SPECIAL, $title); |
135 | | - if (isset($nt)) { |
| 133 | + function fullUrl( $title ) { |
| 134 | + $nt = Title::makeTitleSafe( NS_SPECIAL, $title ); |
| 135 | + if ( isset( $nt ) ) { |
136 | 136 | return $nt->getFullURL(); |
137 | 137 | } else { |
138 | 138 | return NULL; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | | - function scriptUrl($title) { |
| 142 | + function scriptUrl( $title ) { |
143 | 143 | global $wgServer, $wgScript; |
144 | | - $nt = Title::makeTitleSafe(NS_SPECIAL, $title); |
145 | | - if (isset($nt)) { |
| 144 | + $nt = Title::makeTitleSafe( NS_SPECIAL, $title ); |
| 145 | + if ( isset( $nt ) ) { |
146 | 146 | $dbkey = wfUrlencode( $nt->getPrefixedDBkey() ); |
147 | 147 | return "{$wgServer}{$wgScript}?title={$dbkey}"; |
148 | 148 | } else { |
— | — | @@ -149,23 +149,23 @@ |
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | | - function canLogin($openid_url) { |
| 153 | + function canLogin( $openid_url ) { |
154 | 154 | |
155 | 155 | global $wgOpenIDConsumerDenyByDefault, $wgOpenIDConsumerAllow, $wgOpenIDConsumerDeny; |
156 | 156 | |
157 | | - if ($this->isLocalUrl($openid_url)) { |
| 157 | + if ( $this->isLocalUrl( $openid_url ) ) { |
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | |
161 | | - if ($wgOpenIDConsumerDenyByDefault) { |
| 161 | + if ( $wgOpenIDConsumerDenyByDefault ) { |
162 | 162 | $canLogin = false; |
163 | | - foreach ($wgOpenIDConsumerAllow as $allow) { |
164 | | - if (preg_match($allow, $openid_url)) { |
165 | | - wfDebug("OpenID: $openid_url matched allow pattern $allow.\n"); |
| 163 | + foreach ( $wgOpenIDConsumerAllow as $allow ) { |
| 164 | + if ( preg_match( $allow, $openid_url ) ) { |
| 165 | + wfDebug( "OpenID: $openid_url matched allow pattern $allow.\n" ); |
166 | 166 | $canLogin = true; |
167 | | - foreach ($wgOpenIDConsumerDeny as $deny) { |
168 | | - if (preg_match($deny, $openid_url)) { |
169 | | - wfDebug("OpenID: $openid_url matched deny pattern $deny.\n"); |
| 167 | + foreach ( $wgOpenIDConsumerDeny as $deny ) { |
| 168 | + if ( preg_match( $deny, $openid_url ) ) { |
| 169 | + wfDebug( "OpenID: $openid_url matched deny pattern $deny.\n" ); |
170 | 170 | $canLogin = false; |
171 | 171 | break; |
172 | 172 | } |
— | — | @@ -175,13 +175,13 @@ |
176 | 176 | } |
177 | 177 | } else { |
178 | 178 | $canLogin = true; |
179 | | - foreach ($wgOpenIDConsumerDeny as $deny) { |
180 | | - if (preg_match($deny, $openid_url)) { |
181 | | - wfDebug("OpenID: $openid_url matched deny pattern $deny.\n"); |
| 179 | + foreach ( $wgOpenIDConsumerDeny as $deny ) { |
| 180 | + if ( preg_match( $deny, $openid_url ) ) { |
| 181 | + wfDebug( "OpenID: $openid_url matched deny pattern $deny.\n" ); |
182 | 182 | $canLogin = false; |
183 | | - foreach ($wgOpenIDConsumerAllow as $allow) { |
184 | | - if (preg_match($allow, $openid_url)) { |
185 | | - wfDebug("OpenID: $openid_url matched allow pattern $allow.\n"); |
| 183 | + foreach ( $wgOpenIDConsumerAllow as $allow ) { |
| 184 | + if ( preg_match( $allow, $openid_url ) ) { |
| 185 | + wfDebug( "OpenID: $openid_url matched allow pattern $allow.\n" ); |
186 | 186 | $canLogin = true; |
187 | 187 | break; |
188 | 188 | } |
— | — | @@ -193,67 +193,67 @@ |
194 | 194 | return $canLogin; |
195 | 195 | } |
196 | 196 | |
197 | | - function isLocalUrl($url) { |
| 197 | + function isLocalUrl( $url ) { |
198 | 198 | |
199 | 199 | global $wgServer, $wgArticlePath; |
200 | 200 | |
201 | 201 | $pattern = $wgServer . $wgArticlePath; |
202 | | - $pattern = str_replace('$1', '(.*)', $pattern); |
203 | | - $pattern = str_replace('?', '\?', $pattern); |
| 202 | + $pattern = str_replace( '$1', '(.*)', $pattern ); |
| 203 | + $pattern = str_replace( '?', '\?', $pattern ); |
204 | 204 | |
205 | | - return preg_match('|^' . $pattern . '$|', $url); |
| 205 | + return preg_match( '|^' . $pattern . '$|', $url ); |
206 | 206 | } |
207 | 207 | |
208 | 208 | # Find the user with the given openid, if any |
209 | 209 | |
210 | | - function getUser($openid) { |
| 210 | + function getUser( $openid ) { |
211 | 211 | global $wgSharedDB, $wgDBprefix; |
212 | 212 | |
213 | | - if (isset($wgSharedDB)) { |
| 213 | + if ( isset( $wgSharedDB ) ) { |
214 | 214 | $tableName = "`$wgSharedDB`.${wgDBprefix}user_openid"; |
215 | 215 | } else { |
216 | 216 | $tableName = 'user_openid'; |
217 | 217 | } |
218 | 218 | |
219 | 219 | $dbr =& wfGetDB( DB_SLAVE ); |
220 | | - $id = $dbr->selectField($tableName, 'uoi_user', |
221 | | - array('uoi_openid' => $openid)); |
222 | | - if ($id) { |
223 | | - $name = User::whoIs($id); |
224 | | - return User::newFromName($name); |
| 220 | + $id = $dbr->selectField( $tableName, 'uoi_user', |
| 221 | + array( 'uoi_openid' => $openid ) ); |
| 222 | + if ( $id ) { |
| 223 | + $name = User::whoIs( $id ); |
| 224 | + return User::newFromName( $name ); |
225 | 225 | } else { |
226 | 226 | return NULL; |
227 | 227 | } |
228 | 228 | } |
229 | | - function login($openid_url, $finish_page = 'OpenIDFinish') { |
| 229 | + function login( $openid_url, $finish_page = 'OpenIDFinish' ) { |
230 | 230 | |
231 | 231 | global $wgUser, $wgTrustRoot, $wgOut; |
232 | 232 | |
233 | 233 | # If it's an interwiki link, expand it |
234 | 234 | |
235 | | - $openid_url = $this->interwikiExpand($openid_url); |
| 235 | + $openid_url = $this->interwikiExpand( $openid_url ); |
236 | 236 | |
237 | 237 | # Check if the URL is allowed |
238 | 238 | |
239 | | - if (!$this->canLogin($openid_url)) { |
240 | | - $wgOut->showErrorPage('openidpermission', 'openidpermissiontext'); |
| 239 | + if ( !$this->canLogin( $openid_url ) ) { |
| 240 | + $wgOut->showErrorPage( 'openidpermission', 'openidpermissiontext' ); |
241 | 241 | return; |
242 | 242 | } |
243 | 243 | |
244 | 244 | $sk = $wgUser->getSkin(); |
245 | 245 | |
246 | | - if (isset($wgTrustRoot)) { |
| 246 | + if ( isset( $wgTrustRoot ) ) { |
247 | 247 | $trust_root = $wgTrustRoot; |
248 | 248 | } else { |
249 | 249 | global $wgArticlePath, $wgServer; |
250 | | - $root_article = str_replace('$1', '', $wgArticlePath); |
| 250 | + $root_article = str_replace( '$1', '', $wgArticlePath ); |
251 | 251 | $trust_root = $wgServer . $root_article; |
252 | 252 | } |
253 | 253 | |
254 | 254 | $consumer = $this->getConsumer(); |
255 | 255 | |
256 | | - if (!$consumer) { |
257 | | - $wgOut->showErrorPage('openiderror', 'openiderrortext'); |
| 256 | + if ( !$consumer ) { |
| 257 | + $wgOut->showErrorPage( 'openiderror', 'openiderrortext' ); |
258 | 258 | return; |
259 | 259 | } |
260 | 260 | |
— | — | @@ -261,15 +261,15 @@ |
262 | 262 | |
263 | 263 | global $wgSessionStarted; |
264 | 264 | |
265 | | - if (!$wgSessionStarted) { |
| 265 | + if ( !$wgSessionStarted ) { |
266 | 266 | $wgUser->SetupSession(); |
267 | 267 | } |
268 | 268 | |
269 | | - $auth_request = $consumer->begin($openid_url); |
| 269 | + $auth_request = $consumer->begin( $openid_url ); |
270 | 270 | |
271 | 271 | // Handle failure status return values. |
272 | | - if (!$auth_request) { |
273 | | - $wgOut->showErrorPage('openiderror', 'openiderrortext'); |
| 272 | + if ( !$auth_request ) { |
| 273 | + $wgOut->showErrorPage( 'openiderror', 'openiderrortext' ); |
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
— | — | @@ -277,16 +277,16 @@ |
278 | 278 | |
279 | 279 | $endpoint = $auth_request->endpoint; |
280 | 280 | |
281 | | - if (isset($endpoint)) { |
| 281 | + if ( isset( $endpoint ) ) { |
282 | 282 | # Check if the URL is allowed |
283 | 283 | |
284 | | - if (isset($endpoint->identity_url) && !$this->canLogin($endpoint->identity_url)) { |
285 | | - $wgOut->showErrorPage('openidpermission', 'openidpermissiontext'); |
| 284 | + if ( isset( $endpoint->identity_url ) && !$this->canLogin( $endpoint->identity_url ) ) { |
| 285 | + $wgOut->showErrorPage( 'openidpermission', 'openidpermissiontext' ); |
286 | 286 | return; |
287 | 287 | } |
288 | 288 | |
289 | | - if (isset($endpoint->delegate) && !$this->canLogin($endpoint->delegate)) { |
290 | | - $wgOut->showErrorPage('openidpermission', 'openidpermissiontext'); |
| 289 | + if ( isset( $endpoint->delegate ) && !$this->canLogin( $endpoint->delegate ) ) { |
| 290 | + $wgOut->showErrorPage( 'openidpermission', 'openidpermissiontext' ); |
291 | 291 | return; |
292 | 292 | } |
293 | 293 | } |
— | — | @@ -295,84 +295,84 @@ |
296 | 296 | // Required |
297 | 297 | array(), |
298 | 298 | // Optional |
299 | | - array('nickname','email', |
300 | | - 'fullname','language','timezone')); |
| 299 | + array( 'nickname', 'email', |
| 300 | + 'fullname', 'language', 'timezone' ) ); |
301 | 301 | |
302 | | - if ($sreg_request) { |
303 | | - $auth_request->addExtension($sreg_request); |
| 302 | + if ( $sreg_request ) { |
| 303 | + $auth_request->addExtension( $sreg_request ); |
304 | 304 | } |
305 | 305 | |
306 | | - $process_url = $this->scriptUrl($finish_page); |
| 306 | + $process_url = $this->scriptUrl( $finish_page ); |
307 | 307 | |
308 | | - if ($auth_request->shouldSendRedirect()) { |
309 | | - $redirect_url = $auth_request->redirectURL($trust_root, |
310 | | - $process_url); |
311 | | - if (Auth_OpenID::isFailure($redirect_url)) { |
312 | | - displayError("Could not redirect to server: " . $redirect_url->message); |
| 308 | + if ( $auth_request->shouldSendRedirect() ) { |
| 309 | + $redirect_url = $auth_request->redirectURL( $trust_root, |
| 310 | + $process_url ); |
| 311 | + if ( Auth_OpenID::isFailure( $redirect_url ) ) { |
| 312 | + displayError( "Could not redirect to server: " . $redirect_url->message ); |
313 | 313 | } else { |
314 | 314 | # OK, now go |
315 | | - $wgOut->redirect($redirect_url); |
| 315 | + $wgOut->redirect( $redirect_url ); |
316 | 316 | } |
317 | 317 | } else { |
318 | 318 | // Generate form markup and render it. |
319 | 319 | $form_id = 'openid_message'; |
320 | | - $form_html = $auth_request->formMarkup($trust_root, $process_url, |
321 | | - false, array('id' => $form_id)); |
| 320 | + $form_html = $auth_request->formMarkup( $trust_root, $process_url, |
| 321 | + false, array( 'id' => $form_id ) ); |
322 | 322 | |
323 | 323 | // Display an error if the form markup couldn't be generated; |
324 | 324 | // otherwise, render the HTML. |
325 | | - if (Auth_OpenID::isFailure($form_html)) { |
326 | | - displayError("Could not redirect to server: " . $form_html->message); |
| 325 | + if ( Auth_OpenID::isFailure( $form_html ) ) { |
| 326 | + displayError( "Could not redirect to server: " . $form_html->message ); |
327 | 327 | } else { |
328 | | - $wgOut->addHTML("<p>" . wfMsg("openidautosubmit") . "</p>"); |
329 | | - $wgOut->addHTML($form_html); |
330 | | - $wgOut->addInlineScript("function submitOpenIDForm() {\n document.getElementById(\"".$form_id."\").submit()\n }\nhookEvent(\"load\", submitOpenIDForm);\n"); |
| 328 | + $wgOut->addHTML( "<p>" . wfMsg( "openidautosubmit" ) . "</p>" ); |
| 329 | + $wgOut->addHTML( $form_html ); |
| 330 | + $wgOut->addInlineScript( "function submitOpenIDForm() {\n document.getElementById(\"" . $form_id . "\").submit()\n }\nhookEvent(\"load\", submitOpenIDForm);\n" ); |
331 | 331 | } |
332 | 332 | } |
333 | 333 | } |
334 | | - |
335 | | - function setUserUrl($user, $url) { |
336 | | - $other = $this->getUserUrl($user); |
337 | | - if (isset($other)) { |
338 | | - $this->updateUserUrl($user, $url); |
| 334 | + |
| 335 | + function setUserUrl( $user, $url ) { |
| 336 | + $other = $this->getUserUrl( $user ); |
| 337 | + if ( isset( $other ) ) { |
| 338 | + $this->updateUserUrl( $user, $url ); |
339 | 339 | } else { |
340 | | - $this->insertUserUrl($user, $url); |
| 340 | + $this->insertUserUrl( $user, $url ); |
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
344 | | - function insertUserUrl($user, $url) { |
| 344 | + function insertUserUrl( $user, $url ) { |
345 | 345 | global $wgSharedDB, $wgDBname; |
346 | 346 | $dbw =& wfGetDB( DB_MASTER ); |
347 | 347 | |
348 | | - if (isset($wgSharedDB)) { |
| 348 | + if ( isset( $wgSharedDB ) ) { |
349 | 349 | # It would be nicer to get the existing dbname |
350 | 350 | # and save it, but it's not possible |
351 | | - $dbw->selectDB($wgSharedDB); |
| 351 | + $dbw->selectDB( $wgSharedDB ); |
352 | 352 | } |
353 | 353 | |
354 | | - $dbw->insert('user_openid', array('uoi_user' => $user->getId(), |
355 | | - 'uoi_openid' => $url)); |
| 354 | + $dbw->insert( 'user_openid', array( 'uoi_user' => $user->getId(), |
| 355 | + 'uoi_openid' => $url ) ); |
356 | 356 | |
357 | | - if (isset($wgSharedDB)) { |
358 | | - $dbw->selectDB($wgDBname); |
| 357 | + if ( isset( $wgSharedDB ) ) { |
| 358 | + $dbw->selectDB( $wgDBname ); |
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
362 | | - function updateUserUrl($user, $url) { |
| 362 | + function updateUserUrl( $user, $url ) { |
363 | 363 | global $wgSharedDB, $wgDBname; |
364 | 364 | $dbw =& wfGetDB( DB_MASTER ); |
365 | 365 | |
366 | | - if (isset($wgSharedDB)) { |
| 366 | + if ( isset( $wgSharedDB ) ) { |
367 | 367 | # It would be nicer to get the existing dbname |
368 | 368 | # and save it, but it's not possible |
369 | | - $dbw->selectDB($wgSharedDB); |
| 369 | + $dbw->selectDB( $wgSharedDB ); |
370 | 370 | } |
371 | 371 | |
372 | | - $dbw->set('user_openid', 'uoi_openid', $url, |
373 | | - 'uoi_user = ' . $user->getID()); |
| 372 | + $dbw->set( 'user_openid', 'uoi_openid', $url, |
| 373 | + 'uoi_user = ' . $user->getID() ); |
374 | 374 | |
375 | | - if (isset($wgSharedDB)) { |
376 | | - $dbw->selectDB($wgDBname); |
| 375 | + if ( isset( $wgSharedDB ) ) { |
| 376 | + $dbw->selectDB( $wgDBname ); |
377 | 377 | } |
378 | 378 | } |
379 | 379 | } |
Index: trunk/extensions/OpenID/SpecialOpenIDConvert.body.php |
— | — | @@ -22,17 +22,17 @@ |
23 | 23 | * @addtogroup Extensions |
24 | 24 | */ |
25 | 25 | |
26 | | -if (!defined('MEDIAWIKI')) { |
| 26 | +if ( !defined( 'MEDIAWIKI' ) ) { |
27 | 27 | exit( 1 ); |
28 | 28 | } |
29 | 29 | |
30 | 30 | class SpecialOpenIDConvert extends SpecialOpenID { |
31 | 31 | |
32 | 32 | function SpecialOpenIDConvert() { |
33 | | - SpecialPage::SpecialPage("OpenIDConvert"); |
| 33 | + SpecialPage::SpecialPage( "OpenIDConvert" ); |
34 | 34 | } |
35 | 35 | |
36 | | - function execute($par) { |
| 36 | + function execute( $par ) { |
37 | 37 | |
38 | 38 | global $wgRequest, $wgUser, $wgOut; |
39 | 39 | |
— | — | @@ -40,76 +40,76 @@ |
41 | 41 | |
42 | 42 | $this->setHeaders(); |
43 | 43 | |
44 | | - if ($wgUser->getID() == 0) { |
45 | | - $wgOut->showErrorPage('openiderror', 'notloggedin'); |
| 44 | + if ( $wgUser->getID() == 0 ) { |
| 45 | + $wgOut->showErrorPage( 'openiderror', 'notloggedin' ); |
46 | 46 | return; |
47 | 47 | } |
48 | 48 | |
49 | | - switch ($par) { |
| 49 | + switch ( $par ) { |
50 | 50 | case 'Finish': |
51 | 51 | $this->finish(); |
52 | 52 | break; |
53 | 53 | default: |
54 | | - $openid_url = $wgRequest->getText('openid_url'); |
55 | | - if (isset($openid_url) && strlen($openid_url) > 0) { |
56 | | - $this->convert($openid_url); |
| 54 | + $openid_url = $wgRequest->getText( 'openid_url' ); |
| 55 | + if ( isset( $openid_url ) && strlen( $openid_url ) > 0 ) { |
| 56 | + $this->convert( $openid_url ); |
57 | 57 | } else { |
58 | 58 | $this->Form(); |
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | | - function convert($openid_url) { |
| 63 | + function convert( $openid_url ) { |
64 | 64 | |
65 | 65 | global $wgUser, $wgOut; |
66 | 66 | |
67 | 67 | # Expand Interwiki |
68 | 68 | |
69 | | - $openid_url = $this->interwikiExpand($openid_url); |
| 69 | + $openid_url = $this->interwikiExpand( $openid_url ); |
70 | 70 | |
71 | 71 | # Is this ID allowed to log in? |
72 | 72 | |
73 | | - if (!$this->CanLogin($openid_url)) { |
74 | | - $wgOut->showErrorPage('openidpermission', 'openidpermissiontext'); |
| 73 | + if ( !$this->CanLogin( $openid_url ) ) { |
| 74 | + $wgOut->showErrorPage( 'openidpermission', 'openidpermissiontext' ); |
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
78 | 78 | # Is this ID already taken? |
79 | 79 | |
80 | | - $other = $this->getUser($openid_url); |
| 80 | + $other = $this->getUser( $openid_url ); |
81 | 81 | |
82 | | - if (isset($other)) { |
83 | | - if ($other->getId() == $wgUser->getID()) { |
84 | | - $wgOut->showErrorPage('openiderror', 'openidconvertyourstext'); |
| 82 | + if ( isset( $other ) ) { |
| 83 | + if ( $other->getId() == $wgUser->getID() ) { |
| 84 | + $wgOut->showErrorPage( 'openiderror', 'openidconvertyourstext' ); |
85 | 85 | } else { |
86 | | - $wgOut->showErrorPage('openiderror', 'openidconvertothertext'); |
| 86 | + $wgOut->showErrorPage( 'openiderror', 'openidconvertothertext' ); |
87 | 87 | } |
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | 91 | # If we're OK to here, let the user go log in |
92 | 92 | |
93 | | - $this->Login($openid_url, 'OpenIDConvert/Finish'); |
| 93 | + $this->Login( $openid_url, 'OpenIDConvert/Finish' ); |
94 | 94 | } |
95 | 95 | |
96 | 96 | function form() { |
97 | 97 | global $wgOut, $wgUser; |
98 | 98 | $sk = $wgUser->getSkin(); |
99 | | - $url = $this->GetUserUrl($wgUser); |
100 | | - if (is_null($url)) { |
| 99 | + $url = $this->GetUserUrl( $wgUser ); |
| 100 | + if ( is_null( $url ) ) { |
101 | 101 | $url = ''; |
102 | 102 | } |
103 | 103 | |
104 | | - $ok = wfMsg('ok'); |
105 | | - $instructions = wfMsg('openidconvertinstructions'); |
106 | | - $wgOut->addHTML("<p>{$instructions}</p>" . |
107 | | - '<form action="' . $sk->makeSpecialUrl('OpenIDConvert') . '" method="POST">' . |
| 104 | + $ok = wfMsg( 'ok' ); |
| 105 | + $instructions = wfMsg( 'openidconvertinstructions' ); |
| 106 | + $wgOut->addHTML( "<p>{$instructions}</p>" . |
| 107 | + '<form action="' . $sk->makeSpecialUrl( 'OpenIDConvert' ) . '" method="POST">' . |
108 | 108 | '<input type="text" name="openid_url" size="30" ' . |
109 | 109 | ' style="background: url(http://www.openid.net/login-bg.gif) ' . |
110 | 110 | ' no-repeat; background-color: #fff; background-position: 0 50%; ' . |
111 | 111 | ' color: #000; padding-left: 18px;" value="' . $url . '" />' . |
112 | 112 | '<input type="submit" value="' . $ok . '" />' . |
113 | | - '</form>'); |
| 113 | + '</form>' ); |
114 | 114 | } |
115 | 115 | |
116 | 116 | function finish() { |
— | — | @@ -118,48 +118,48 @@ |
119 | 119 | |
120 | 120 | $consumer = $this->getConsumer(); |
121 | 121 | |
122 | | - $response = $consumer->complete($this->scriptUrl('OpenIDConvert/Finish')); |
| 122 | + $response = $consumer->complete( $this->scriptUrl( 'OpenIDConvert/Finish' ) ); |
123 | 123 | |
124 | | - if (!isset($response)) { |
125 | | - wfDebug("OpenID: aborting in openid converter because the response was missing\n"); |
126 | | - $wgOut->showErrorPage('openiderror', 'openiderrortext'); |
| 124 | + if ( !isset( $response ) ) { |
| 125 | + wfDebug( "OpenID: aborting in openid converter because the response was missing\n" ); |
| 126 | + $wgOut->showErrorPage( 'openiderror', 'openiderrortext' ); |
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | | - switch ($response->status) { |
| 130 | + switch ( $response->status ) { |
131 | 131 | case Auth_OpenID_CANCEL: |
132 | 132 | // This means the authentication was cancelled. |
133 | | - $wgOut->showErrorPage('openidcancel', 'openidcanceltext'); |
| 133 | + $wgOut->showErrorPage( 'openidcancel', 'openidcanceltext' ); |
134 | 134 | break; |
135 | 135 | case Auth_OpenID_FAILURE: |
136 | | - wfDebug("OpenID: error in convert: '" . $response->message . "'\n"); |
137 | | - $wgOut->showErrorPage('openidfailure', 'openidfailuretext', array($response->message)); |
| 136 | + wfDebug( "OpenID: error in convert: '" . $response->message . "'\n" ); |
| 137 | + $wgOut->showErrorPage( 'openidfailure', 'openidfailuretext', array( $response->message ) ); |
138 | 138 | break; |
139 | 139 | case Auth_OpenID_SUCCESS: |
140 | 140 | // This means the authentication succeeded. |
141 | 141 | $openid_url = $response->identity_url; |
142 | 142 | |
143 | | - if (!isset($openid_url)) { |
144 | | - wfDebug("OpenID: aborting in openid converter because the openid_url was missing\n"); |
145 | | - $wgOut->showErrorPage('openiderror', 'openiderrortext'); |
| 143 | + if ( !isset( $openid_url ) ) { |
| 144 | + wfDebug( "OpenID: aborting in openid converter because the openid_url was missing\n" ); |
| 145 | + $wgOut->showErrorPage( 'openiderror', 'openiderrortext' ); |
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
149 | 149 | # We check again for dupes; this may be normalized or |
150 | 150 | # reformatted by the server. |
151 | 151 | |
152 | | - $other = $this->getUser($openid_url); |
| 152 | + $other = $this->getUser( $openid_url ); |
153 | 153 | |
154 | | - if (isset($other)) { |
155 | | - if ($other->getId() == $wgUser->getID()) { |
156 | | - $wgOut->showErrorPage('openiderror', 'openidconvertyourstext'); |
| 154 | + if ( isset( $other ) ) { |
| 155 | + if ( $other->getId() == $wgUser->getID() ) { |
| 156 | + $wgOut->showErrorPage( 'openiderror', 'openidconvertyourstext' ); |
157 | 157 | } else { |
158 | | - $wgOut->showErrorPage('openiderror', 'openidconvertothertext'); |
| 158 | + $wgOut->showErrorPage( 'openiderror', 'openidconvertothertext' ); |
159 | 159 | } |
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | | - $this->setUserUrl($wgUser, $openid_url); |
| 163 | + $this->setUserUrl( $wgUser, $openid_url ); |
164 | 164 | |
165 | 165 | $wgOut->setPageTitle( wfMsg( 'openidconvertsuccess' ) ); |
166 | 166 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
Index: trunk/extensions/OpenID/SpecialOpenIDFinish.body.php |
— | — | @@ -22,20 +22,19 @@ |
23 | 23 | * @addtogroup Extensions |
24 | 24 | */ |
25 | 25 | |
26 | | -if (!defined('MEDIAWIKI')) |
27 | | - exit(1); |
| 26 | +if ( !defined( 'MEDIAWIKI' ) ) |
| 27 | + exit( 1 ); |
28 | 28 | |
29 | | -require_once("Auth/OpenID/Consumer.php"); |
30 | | -require_once("Auth/OpenID/SReg.php"); |
31 | | -require_once("Auth/Yadis/XRI.php"); |
| 29 | +require_once( "Auth/OpenID/Consumer.php" ); |
| 30 | +require_once( "Auth/OpenID/SReg.php" ); |
| 31 | +require_once( "Auth/Yadis/XRI.php" ); |
32 | 32 | |
33 | 33 | class SpecialOpenIDFinish extends SpecialOpenID { |
34 | | - |
35 | 34 | function SpecialOpenIDFinish() { |
36 | | - SpecialPage::SpecialPage("OpenIDFinish", '', false); |
| 35 | + SpecialPage::SpecialPage( "OpenIDFinish", '', false ); |
37 | 36 | } |
38 | 37 | |
39 | | - function execute( $par) { |
| 38 | + function execute( $par ) { |
40 | 39 | |
41 | 40 | global $wgUser, $wgOut, $wgRequest; |
42 | 41 | |
— | — | @@ -54,7 +53,7 @@ |
55 | 54 | |
56 | 55 | switch ( $par ) { |
57 | 56 | case 'ChooseName': |
58 | | - list( $openid, $sreg) = $this->fetchValues(); |
| 57 | + list( $openid, $sreg ) = $this->fetchValues(); |
59 | 58 | if ( !isset( $openid ) ) { |
60 | 59 | wfDebug( "OpenID: aborting in ChooseName because identity_url is missing\n" ); |
61 | 60 | $this->clearValues(); |
— | — | @@ -72,7 +71,7 @@ |
73 | 72 | $choice = $wgRequest->getText( 'wpNameChoice' ); |
74 | 73 | $nameValue = $wgRequest->getText( 'wpNameValue' ); |
75 | 74 | |
76 | | - if ($choice == 'existing') { |
| 75 | + if ( $choice == 'existing' ) { |
77 | 76 | $user = $this->attachUser( $openid, $sreg, |
78 | 77 | $wgRequest->getText( 'wpExistingName' ), |
79 | 78 | $wgRequest->getText( 'wpExistingPassword' ) |
— | — | @@ -83,19 +82,19 @@ |
84 | 83 | return; |
85 | 84 | } |
86 | 85 | |
87 | | - if ($wgRequest->getText( 'wpUpdateUserInfo' )) |
| 86 | + if ( $wgRequest->getText( 'wpUpdateUserInfo' ) ) |
88 | 87 | { |
89 | 88 | $this->updateUser( $user, $sreg ); |
90 | 89 | } |
91 | 90 | } else { |
92 | | - $name = $this->getUserName( $openid, $sreg, $choice, $nameValue); |
| 91 | + $name = $this->getUserName( $openid, $sreg, $choice, $nameValue ); |
93 | 92 | |
94 | 93 | if ( !$name || !$this->userNameOK( $name ) ) { |
95 | 94 | wfDebug( "OpenID: Name not OK: '$name'\n" ); |
96 | 95 | $this->chooseNameForm( $openid, $sreg ); |
97 | 96 | return; |
98 | 97 | } |
99 | | - |
| 98 | + |
100 | 99 | $user = $this->createUser( $openid, $sreg, $name ); |
101 | 100 | } |
102 | 101 | |
— | — | @@ -139,7 +138,7 @@ |
140 | 139 | $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse( $response ); |
141 | 140 | $sreg = $sreg_resp->contents(); |
142 | 141 | |
143 | | - if (!isset($openid)) { |
| 142 | + if ( !isset( $openid ) ) { |
144 | 143 | wfDebug( "OpenID: aborting in auth success because display identifier is missing\n" ); |
145 | 144 | $wgOut->showErrorPage( 'openiderror', 'openiderrortext' ); |
146 | 145 | return; |
— | — | @@ -149,9 +148,9 @@ |
150 | 149 | |
151 | 150 | if ( isset( $user ) ) |
152 | 151 | { |
153 | | - if ($user->getOption('openid-update-userinfo-on-login')) |
| 152 | + if ( $user->getOption( 'openid-update-userinfo-on-login' ) ) |
154 | 153 | { |
155 | | - $this->updateUser( $user, $sreg); # update from server |
| 154 | + $this->updateUser( $user, $sreg ); # update from server |
156 | 155 | } |
157 | 156 | } else { |
158 | 157 | # For easy names |
— | — | @@ -189,7 +188,7 @@ |
190 | 189 | |
191 | 190 | # Set a cookie for later check-immediate use |
192 | 191 | |
193 | | - $this->loginSetCookie($openid); |
| 192 | + $this->loginSetCookie( $openid ); |
194 | 193 | |
195 | 194 | $wgOut->setPageTitle( wfMsg( 'openidsuccess' ) ); |
196 | 195 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
— | — | @@ -205,15 +204,15 @@ |
206 | 205 | |
207 | 206 | $exp = time() + $wgOpenIDCookieExpiration; |
208 | 207 | |
209 | | - setcookie( $wgCookiePrefix.'OpenID', $openid, $exp, $wgCookiePath, $wgCookieDomain, $wgCookieSecure ); |
| 208 | + setcookie( $wgCookiePrefix . 'OpenID', $openid, $exp, $wgCookiePath, $wgCookieDomain, $wgCookieSecure ); |
210 | 209 | } |
211 | 210 | |
212 | 211 | function chooseNameForm( $openid, $sreg, $messagekey = NULL ) { |
213 | 212 | |
214 | 213 | global $wgOut, $wgUser, $wgOpenIDOnly; |
215 | | - |
| 214 | + |
216 | 215 | $sk = $wgUser->getSkin(); |
217 | | - if ($messagekey) { |
| 216 | + if ( $messagekey ) { |
218 | 217 | $message = wfMsg( $messagekey ); |
219 | 218 | } else if ( array_key_exists( 'nickname', $sreg ) ) { |
220 | 219 | $message = wfMsg( 'openidnotavailable', $sreg['nickname'] ); |
— | — | @@ -228,9 +227,9 @@ |
229 | 228 | |
230 | 229 | if ( !$wgOpenIDOnly ) { |
231 | 230 | # Let them attach it to an existing user |
232 | | - |
| 231 | + |
233 | 232 | # Grab the UserName in the cookie if it exists |
234 | | - |
| 233 | + |
235 | 234 | global $wgCookiePrefix; |
236 | 235 | $name = ''; |
237 | 236 | if ( isset( $_COOKIE["{$wgCookiePrefix}UserName"] ) ) { |
— | — | @@ -238,39 +237,39 @@ |
239 | 238 | } |
240 | 239 | |
241 | 240 | # show OpenID Attributes |
242 | | - $oidAttributesToAccept = array('fullname', 'nickname', 'email', 'language'); |
| 241 | + $oidAttributesToAccept = array( 'fullname', 'nickname', 'email', 'language' ); |
243 | 242 | $oidAttributes = array(); |
244 | 243 | |
245 | | - foreach ($oidAttributesToAccept as $oidAttr) |
| 244 | + foreach ( $oidAttributesToAccept as $oidAttr ) |
246 | 245 | { |
247 | | - if ($oidAttr == 'fullname' && !$wgAllowRealName) |
| 246 | + if ( $oidAttr == 'fullname' && !$wgAllowRealName ) |
248 | 247 | { |
249 | 248 | next; |
250 | 249 | } |
251 | 250 | |
252 | | - if ( array_key_exists( $oidAttr, $sreg )) { |
253 | | - $oidAttributes[] = '<div>'.wfMsg( "openid$oidAttr" ).': <i>'.$sreg[$oidAttr].'</i></div>'; |
| 251 | + if ( array_key_exists( $oidAttr, $sreg ) ) { |
| 252 | + $oidAttributes[] = '<div>' . wfMsg( "openid$oidAttr" ) . ': <i>' . $sreg[$oidAttr] . '</i></div>'; |
254 | 253 | } |
255 | 254 | } |
256 | 255 | |
257 | 256 | $oidAttributesUpdate = ''; |
258 | | - if (count($oidAttributes) > 0) |
| 257 | + if ( count( $oidAttributes ) > 0 ) |
259 | 258 | { |
260 | | - $oidAttributesUpdate = '<div style="margin-left: 25px">'. |
| 259 | + $oidAttributesUpdate = '<div style="margin-left: 25px">' . |
261 | 260 | '<input type="checkbox" name="wpUpdateUserInfo" id="wpUpdateUserInfo">' . |
262 | 261 | '<label for="wpUpdateUserInfo">' . wfMsg( "openidupdateuserinfo" ) . |
263 | | - '<div style="margin-left: 25px">'.implode('', $oidAttributes).'</div>'. |
| 262 | + '<div style="margin-left: 25px">' . implode( '', $oidAttributes ) . '</div>' . |
264 | 263 | '</label></div>'; |
265 | 264 | } |
266 | | - |
267 | | - $wgOut->addHTML("<div><input type='radio' name='wpNameChoice' id='wpNameChoiceExisting' value='existing' />" . |
| 265 | + |
| 266 | + $wgOut->addHTML( "<div><input type='radio' name='wpNameChoice' id='wpNameChoiceExisting' value='existing' />" . |
268 | 267 | "<label for='wpNameChoiceExisting'>" . wfMsg( "openidchooseexisting" ) . "</label> " . |
269 | 268 | "<input type='text' name='wpExistingName' id='wpExistingName' size='16' value='{$name}'> " . |
270 | 269 | "<label for='wpExistingPassword'>" . wfMsg( "openidchoosepassword" ) . "</label> " . |
271 | 270 | "<input type='password' name='wpExistingPassword' size='8' /> " . |
272 | 271 | $oidAttributesUpdate . "</div>\n" ); |
273 | 272 | } |
274 | | - |
| 273 | + |
275 | 274 | # These options won't exist if we can't get them. |
276 | 275 | |
277 | 276 | if ( array_key_exists( 'fullname', $sreg ) && $this->userNameOK( $sreg['fullname'] ) ) { |
— | — | @@ -293,14 +292,14 @@ |
294 | 293 | |
295 | 294 | $wgOut->addHTML( "<div><input type='radio' name='wpNameChoice' id='wpNameChoiceAuto' value='auto' " . |
296 | 295 | ( ( !$def ) ? "checked = 'checked'" : "" ) . " />" . |
297 | | - "<label for='wpNameChoiceAuto'>" . wfMsg( "openidchooseauto", $this->automaticName( $sreg ) ) . "</label></div>\n"); |
| 296 | + "<label for='wpNameChoiceAuto'>" . wfMsg( "openidchooseauto", $this->automaticName( $sreg ) ) . "</label></div>\n" ); |
298 | 297 | |
299 | 298 | $def = true; |
300 | 299 | |
301 | | - $wgOut->addHTML("<div><input type='radio' name='wpNameChoice' id='wpNameChoiceManual' value='manual' " . |
| 300 | + $wgOut->addHTML( "<div><input type='radio' name='wpNameChoice' id='wpNameChoiceManual' value='manual' " . |
302 | 301 | " checked='off' />" . |
303 | 302 | "<label for='wpNameChoiceManual'>" . wfMsg( "openidchoosemanual" ) . "</label> " . |
304 | | - "<input type='text' name='wpNameValue' id='wpNameValue' size='16' /></div>\n"); |
| 303 | + "<input type='text' name='wpNameValue' id='wpNameValue' size='16' /></div>\n" ); |
305 | 304 | |
306 | 305 | $ok = wfMsg( 'login' ); |
307 | 306 | $cancel = wfMsg( 'cancel' ); |
— | — | @@ -391,13 +390,13 @@ |
392 | 391 | global $wgAllowRealName; |
393 | 392 | |
394 | 393 | # FIXME: only update if there's been a change |
395 | | - $user->setOption('nickname', array_key_exists( 'nickname', $sreg ) |
396 | | - ? $sreg['nickname'] : ''); |
| 394 | + $user->setOption( 'nickname', array_key_exists( 'nickname', $sreg ) |
| 395 | + ? $sreg['nickname'] : '' ); |
397 | 396 | |
398 | 397 | $user->setEmail( array_key_exists( 'email', $sreg ) ? $sreg['email'] : '' ); |
399 | 398 | |
400 | | - $user->setRealName( (array_key_exists( 'fullname', $sreg ) && $wgAllowRealName) |
401 | | - ? $sreg['fullname'] : ''); |
| 399 | + $user->setRealName( ( array_key_exists( 'fullname', $sreg ) && $wgAllowRealName ) |
| 400 | + ? $sreg['fullname'] : '' ); |
402 | 401 | |
403 | 402 | if ( array_key_exists( 'language', $sreg ) ) { |
404 | 403 | # FIXME: check and make sure the language exists |
— | — | @@ -406,7 +405,7 @@ |
407 | 406 | $user->setOption( 'language', NULL ); |
408 | 407 | } |
409 | 408 | |
410 | | - if (array_key_exists( 'timezone', $sreg ) ) { |
| 409 | + if ( array_key_exists( 'timezone', $sreg ) ) { |
411 | 410 | # FIXME: do something with it. |
412 | 411 | # $offset = OpenIDTimezoneToTzoffset($sreg['timezone']); |
413 | 412 | # $user->setOption('timecorrection', $offset); |
— | — | @@ -417,39 +416,39 @@ |
418 | 417 | $user->saveSettings(); |
419 | 418 | } |
420 | 419 | |
421 | | - function createUser($openid, $sreg, $name) { |
| 420 | + function createUser( $openid, $sreg, $name ) { |
422 | 421 | |
423 | 422 | global $wgAuth, $wgAllowRealName; |
424 | 423 | |
425 | | - $user = User::newFromName($name); |
| 424 | + $user = User::newFromName( $name ); |
426 | 425 | |
427 | | - if (!$user) { |
428 | | - wfDebug("OpenID: Error adding new user.\n"); |
| 426 | + if ( !$user ) { |
| 427 | + wfDebug( "OpenID: Error adding new user.\n" ); |
429 | 428 | return NULL; |
430 | 429 | } |
431 | | - |
| 430 | + |
432 | 431 | $user->addToDatabase(); |
433 | 432 | |
434 | | - if (!$user->getId()) { |
435 | | - wfDebug("OpenID: Error adding new user.\n"); |
| 433 | + if ( !$user->getId() ) { |
| 434 | + wfDebug( "OpenID: Error adding new user.\n" ); |
436 | 435 | } else { |
437 | 436 | |
438 | | - $this->insertUserUrl($user, $openid); |
| 437 | + $this->insertUserUrl( $user, $openid ); |
439 | 438 | |
440 | | - if (array_key_exists('nickname', $sreg)) { |
441 | | - $user->setOption('nickname', $sreg['nickname']); |
| 439 | + if ( array_key_exists( 'nickname', $sreg ) ) { |
| 440 | + $user->setOption( 'nickname', $sreg['nickname'] ); |
442 | 441 | } |
443 | | - if (array_key_exists('email', $sreg)) { |
| 442 | + if ( array_key_exists( 'email', $sreg ) ) { |
444 | 443 | $user->setEmail( $sreg['email'] ); |
445 | 444 | } |
446 | | - if ($wgAllowRealName && array_key_exists('fullname', $sreg)) { |
447 | | - $user->setRealName($sreg['fullname']); |
| 445 | + if ( $wgAllowRealName && array_key_exists( 'fullname', $sreg ) ) { |
| 446 | + $user->setRealName( $sreg['fullname'] ); |
448 | 447 | } |
449 | | - if (array_key_exists('language', $sreg)) { |
| 448 | + if ( array_key_exists( 'language', $sreg ) ) { |
450 | 449 | # FIXME: check and make sure the language exists |
451 | | - $user->setOption('language', $sreg['language']); |
| 450 | + $user->setOption( 'language', $sreg['language'] ); |
452 | 451 | } |
453 | | - if (array_key_exists('timezone', $sreg)) { |
| 452 | + if ( array_key_exists( 'timezone', $sreg ) ) { |
454 | 453 | # FIXME: do something with it. |
455 | 454 | # $offset = OpenIDTimezoneToTzoffset($sreg['timezone']); |
456 | 455 | # $user->setOption('timecorrection', $offset); |
— | — | @@ -459,20 +458,20 @@ |
460 | 459 | } |
461 | 460 | } |
462 | 461 | |
463 | | - function createName($openid, $sreg) { |
| 462 | + function createName( $openid, $sreg ) { |
464 | 463 | |
465 | | - if (array_key_exists('nickname', $sreg) && # try nickname |
466 | | - $this->userNameOK($sreg['nickname'])) |
| 464 | + if ( array_key_exists( 'nickname', $sreg ) && # try nickname |
| 465 | + $this->userNameOK( $sreg['nickname'] ) ) |
467 | 466 | { |
468 | 467 | return $sreg['nickname']; |
469 | 468 | } |
470 | 469 | } |
471 | 470 | |
472 | | - function toUserName($openid) { |
473 | | - if (Auth_Yadis_identifierScheme($openid) == 'XRI') { |
474 | | - return $this->toUserNameXri($openid); |
| 471 | + function toUserName( $openid ) { |
| 472 | + if ( Auth_Yadis_identifierScheme( $openid ) == 'XRI' ) { |
| 473 | + return $this->toUserNameXri( $openid ); |
475 | 474 | } else { |
476 | | - return $this->toUserNameUrl($openid); |
| 475 | + return $this->toUserNameUrl( $openid ); |
477 | 476 | } |
478 | 477 | } |
479 | 478 | |
— | — | @@ -481,15 +480,15 @@ |
482 | 481 | # 2. One element in path, like http://profile.typekey.com/EvanProdromou/ |
483 | 482 | # or http://getopenid.com/evanprodromou |
484 | 483 | |
485 | | - function toUserNameUrl($openid) { |
486 | | - static $bad = array('query', 'user', 'password', 'port', 'fragment'); |
| 484 | + function toUserNameUrl( $openid ) { |
| 485 | + static $bad = array( 'query', 'user', 'password', 'port', 'fragment' ); |
487 | 486 | |
488 | | - $parts = parse_url($openid); |
| 487 | + $parts = parse_url( $openid ); |
489 | 488 | |
490 | 489 | # If any of these parts exist, this won't work |
491 | 490 | |
492 | | - foreach ($bad as $badpart) { |
493 | | - if (array_key_exists($badpart, $parts)) { |
| 491 | + foreach ( $bad as $badpart ) { |
| 492 | + if ( array_key_exists( $badpart, $parts ) ) { |
494 | 493 | return NULL; |
495 | 494 | } |
496 | 495 | } |
— | — | @@ -497,16 +496,16 @@ |
498 | 497 | # We just have host and/or path |
499 | 498 | |
500 | 499 | # If it's just a host... |
501 | | - if (array_key_exists('host', $parts) && |
502 | | - (!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0)) |
| 500 | + if ( array_key_exists( 'host', $parts ) && |
| 501 | + ( !array_key_exists( 'path', $parts ) || strcmp( $parts['path'], '/' ) == 0 ) ) |
503 | 502 | { |
504 | | - $hostparts = explode('.', $parts['host']); |
| 503 | + $hostparts = explode( '.', $parts['host'] ); |
505 | 504 | |
506 | 505 | # Try to catch common idiom of nickname.service.tld |
507 | 506 | |
508 | | - if ((count($hostparts) > 2) && |
509 | | - (strlen($hostparts[count($hostparts) - 2]) > 3) && # try to skip .co.uk, .com.au |
510 | | - (strcmp($hostparts[0], 'www') != 0)) |
| 507 | + if ( ( count( $hostparts ) > 2 ) && |
| 508 | + ( strlen( $hostparts[count( $hostparts ) - 2] ) > 3 ) && # try to skip .co.uk, .com.au |
| 509 | + ( strcmp( $hostparts[0], 'www' ) != 0 ) ) |
511 | 510 | { |
512 | 511 | return $hostparts[0]; |
513 | 512 | } else { |
— | — | @@ -514,11 +513,11 @@ |
515 | 514 | return $parts['host']; |
516 | 515 | } |
517 | 516 | } else { |
518 | | - if (array_key_exists('path', $parts)) { |
| 517 | + if ( array_key_exists( 'path', $parts ) ) { |
519 | 518 | # Strip starting, ending slashes |
520 | | - $path = preg_replace('@/$@', '', $parts['path']); |
521 | | - $path = preg_replace('@^/@', '', $path); |
522 | | - if (strpos($path, '/') === false) { |
| 519 | + $path = preg_replace( '@/$@', '', $parts['path'] ); |
| 520 | + $path = preg_replace( '@^/@', '', $path ); |
| 521 | + if ( strpos( $path, '/' ) === false ) { |
523 | 522 | return $path; |
524 | 523 | } |
525 | 524 | } |
— | — | @@ -527,33 +526,33 @@ |
528 | 527 | return NULL; |
529 | 528 | } |
530 | 529 | |
531 | | - function toUserNameXri($xri) { |
532 | | - $base = $this->xriBase($xri); |
| 530 | + function toUserNameXri( $xri ) { |
| 531 | + $base = $this->xriBase( $xri ); |
533 | 532 | |
534 | | - if (!$base) { |
| 533 | + if ( !$base ) { |
535 | 534 | return NULL; |
536 | 535 | } else { |
537 | 536 | # =evan.prodromou |
538 | 537 | # or @gratis*evan.prodromou |
539 | | - $parts = explode('*', substr($base, 1)); |
540 | | - return array_pop($parts); |
| 538 | + $parts = explode( '*', substr( $base, 1 ) ); |
| 539 | + return array_pop( $parts ); |
541 | 540 | } |
542 | 541 | } |
543 | 542 | |
544 | 543 | # Is this name OK to use as a user name? |
545 | 544 | |
546 | | - function userNameOK($name) { |
| 545 | + function userNameOK( $name ) { |
547 | 546 | global $wgReservedUsernames; |
548 | | - return (0 == User::idFromName($name) && |
549 | | - !in_array( $name, $wgReservedUsernames )); |
| 547 | + return ( 0 == User::idFromName( $name ) && |
| 548 | + !in_array( $name, $wgReservedUsernames ) ); |
550 | 549 | } |
551 | 550 | |
552 | 551 | # Get an auto-incremented name |
553 | 552 | |
554 | | - function firstAvailable($prefix) { |
555 | | - for ($i = 2; ; $i++) { # FIXME: this is the DUMB WAY to do this |
| 553 | + function firstAvailable( $prefix ) { |
| 554 | + for ( $i = 2; ; $i++ ) { # FIXME: this is the DUMB WAY to do this |
556 | 555 | $name = "$prefix$i"; |
557 | | - if ($this->userNameOK($name)) { |
| 556 | + if ( $this->userNameOK( $name ) ) { |
558 | 557 | return $name; |
559 | 558 | } |
560 | 559 | } |
— | — | @@ -600,10 +599,10 @@ |
601 | 600 | return $openid_url; |
602 | 601 | } |
603 | 602 | |
604 | | - function saveValues($openid, $sreg) { |
| 603 | + function saveValues( $openid, $sreg ) { |
605 | 604 | global $wgSessionStarted, $wgUser; |
606 | 605 | |
607 | | - if (!$wgSessionStarted) { |
| 606 | + if ( !$wgSessionStarted ) { |
608 | 607 | $wgUser->SetupSession(); |
609 | 608 | } |
610 | 609 | |
— | — | @@ -627,11 +626,11 @@ |
628 | 627 | return $_SESSION['openid_consumer_returnto']; |
629 | 628 | } |
630 | 629 | |
631 | | - function setReturnTo($returnto) { |
| 630 | + function setReturnTo( $returnto ) { |
632 | 631 | $_SESSION['openid_consumer_returnto'] = $returnto; |
633 | 632 | } |
634 | 633 | |
635 | | - function getUserName($openid, $sreg, $choice, $nameValue) { |
| 634 | + function getUserName( $openid, $sreg, $choice, $nameValue ) { |
636 | 635 | switch ( $choice ) { |
637 | 636 | case 'full': |
638 | 637 | return ( ( array_key_exists( 'fullname', $sreg ) ) ? $sreg['fullname'] : null ); |
— | — | @@ -651,13 +650,13 @@ |
652 | 651 | |
653 | 652 | function automaticName( $sreg ) { |
654 | 653 | if ( array_key_exists( 'nickname', $sreg ) && # try auto-generated from nickname |
655 | | - strlen( $sreg['nickname']) > 0 ) { |
| 654 | + strlen( $sreg['nickname'] ) > 0 ) { |
656 | 655 | return $this->firstAvailable( $sreg['nickname'] ); |
657 | 656 | } else { # try auto-generated |
658 | 657 | return $this->firstAvailable( wfMsg( 'openidusernameprefix' ) ); |
659 | 658 | } |
660 | 659 | } |
661 | | - |
| 660 | + |
662 | 661 | function attachUser( $openid, $sreg, $name, $password ) { |
663 | 662 | |
664 | 663 | $user = User::newFromName( $name ); |
— | — | @@ -665,13 +664,13 @@ |
666 | 665 | if ( !$user ) { |
667 | 666 | return NULL; |
668 | 667 | } |
669 | | - |
| 668 | + |
670 | 669 | if ( !$user->checkPassword( $password ) ) { |
671 | 670 | return NULL; |
672 | 671 | } |
673 | | - |
| 672 | + |
674 | 673 | $this->setUserUrl( $user, $openid ); |
675 | | - |
| 674 | + |
676 | 675 | return $user; |
677 | 676 | } |
678 | 677 | } |
Index: trunk/extensions/OpenID/SpecialOpenIDXRDS.body.php |
— | — | @@ -22,8 +22,8 @@ |
23 | 23 | * @addtogroup Extensions |
24 | 24 | */ |
25 | 25 | |
26 | | -if (!defined('MEDIAWIKI')) |
27 | | - exit(1); |
| 26 | +if ( !defined( 'MEDIAWIKI' ) ) |
| 27 | + exit( 1 ); |
28 | 28 | |
29 | 29 | # Outputs a Yadis (http://yadis.org/) XRDS file, saying that this server |
30 | 30 | # supports OpenID and lots of other jazz. |
— | — | @@ -31,85 +31,85 @@ |
32 | 32 | class SpecialOpenIDXRDS extends SpecialOpenID { |
33 | 33 | |
34 | 34 | function SpecialOpenIDXRDS() { |
35 | | - SpecialPage::SpecialPage("OpenIDXRDS", '', false); |
| 35 | + SpecialPage::SpecialPage( "OpenIDXRDS", '', false ); |
36 | 36 | } |
37 | 37 | |
38 | 38 | # $par is a user name |
39 | 39 | |
40 | | - function execute($par) { |
| 40 | + function execute( $par ) { |
41 | 41 | global $wgOut, $wgOpenIDClientOnly; |
42 | 42 | |
43 | 43 | wfLoadExtensionMessages( 'OpenID' ); |
44 | | - |
| 44 | + |
45 | 45 | # No server functionality if this site is only a client |
46 | 46 | # Note: special page is un-registered if this flag is set, |
47 | 47 | # so it'd be unusual to get here. |
48 | | - |
49 | | - if ($wgOpenIDClientOnly) { |
50 | | - wfHttpError(404, "Not Found", wfMsg('openidclientonlytext')); |
| 48 | + |
| 49 | + if ( $wgOpenIDClientOnly ) { |
| 50 | + wfHttpError( 404, "Not Found", wfMsg( 'openidclientonlytext' ) ); |
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | 54 | // XRDS preamble XML. |
55 | | - $xml_template = array('<?xml version="1.0" encoding="UTF-8"?>', |
56 | | - '<xrds:XRDS', |
57 | | - ' xmlns:xrds="xri://\$xrds"', |
58 | | - ' xmlns:openid="http://openid.net/xmlns/1.0"', |
59 | | - ' xmlns="xri://$xrd*($v*2.0)">', |
60 | | - '<XRD>'); |
| 55 | + $xml_template = array( '<?xml version="1.0" encoding="UTF-8"?>', |
| 56 | + '<xrds:XRDS', |
| 57 | + ' xmlns:xrds="xri://\$xrds"', |
| 58 | + ' xmlns:openid="http://openid.net/xmlns/1.0"', |
| 59 | + ' xmlns="xri://$xrd*($v*2.0)">', |
| 60 | + '<XRD>' ); |
61 | 61 | |
62 | 62 | # Check to see if the parameter is really a user name |
63 | 63 | |
64 | | - if (!$par) { |
65 | | - wfHttpError(404, "Not Found", wfMsg('openidnousername')); |
| 64 | + if ( !$par ) { |
| 65 | + wfHttpError( 404, "Not Found", wfMsg( 'openidnousername' ) ); |
66 | 66 | } |
67 | 67 | |
68 | | - $user = User::newFromName($par); |
| 68 | + $user = User::newFromName( $par ); |
69 | 69 | |
70 | | - if (!$user || $user->getID() == 0) { |
71 | | - wfHttpError(404, "Not Found", wfMsg('openidbadusername')); |
| 70 | + if ( !$user || $user->getID() == 0 ) { |
| 71 | + wfHttpError( 404, "Not Found", wfMsg( 'openidbadusername' ) ); |
72 | 72 | } |
73 | 73 | |
74 | 74 | // Generate the user page URL. |
75 | 75 | |
76 | | - $user_title = Title::makeTitle(NS_USER, $user->getName()); |
| 76 | + $user_title = Title::makeTitle( NS_USER, $user->getName() ); |
77 | 77 | $user_url = $user_title->getFullURL(); |
78 | 78 | |
79 | 79 | // Generate the OpenID server endpoint URL. |
80 | | - $server_title = Title::makeTitle(NS_SPECIAL, 'OpenIDServer'); |
| 80 | + $server_title = Title::makeTitle( NS_SPECIAL, 'OpenIDServer' ); |
81 | 81 | $server_url = $server_title->getFullURL(); |
82 | 82 | |
83 | 83 | // Define array of Yadis services to be included in |
84 | 84 | // the XRDS output. |
85 | 85 | $services = array( |
86 | | - array('uri' => $server_url, |
| 86 | + array( 'uri' => $server_url, |
87 | 87 | 'priority' => '0', |
88 | | - 'types' => array('http://openid.net/signon/1.0', |
| 88 | + 'types' => array( 'http://openid.net/signon/1.0', |
89 | 89 | 'http://openid.net/sreg/1.0', |
90 | | - 'http://specs.openid.net/auth/2.0/signon'), |
91 | | - 'delegate' => $user_url), |
| 90 | + 'http://specs.openid.net/auth/2.0/signon' ), |
| 91 | + 'delegate' => $user_url ), |
92 | 92 | ); |
93 | 93 | |
94 | 94 | // Generate <Service> elements into $service_text. |
95 | 95 | $service_text = "\n"; |
96 | | - foreach ($services as $service) { |
97 | | - $types = array(); |
98 | | - foreach ($service['types'] as $type_uri) { |
99 | | - $types[] = ' <Type>'.$type_uri.'</Type>'; |
100 | | - } |
101 | | - $service_text .= implode("\n", |
102 | | - array(' <Service priority="'.$service['priority'].'">', |
103 | | - ' <URI>'.$server_url.'</URI>', |
104 | | - implode("\n", $types), |
105 | | - ' </Service>')); |
| 96 | + foreach ( $services as $service ) { |
| 97 | + $types = array(); |
| 98 | + foreach ( $service['types'] as $type_uri ) { |
| 99 | + $types[] = ' <Type>' . $type_uri . '</Type>'; |
| 100 | + } |
| 101 | + $service_text .= implode( "\n", |
| 102 | + array( ' <Service priority="' . $service['priority'] . '">', |
| 103 | + ' <URI>' . $server_url . '</URI>', |
| 104 | + implode( "\n", $types ), |
| 105 | + ' </Service>' ) ); |
106 | 106 | } |
107 | 107 | |
108 | 108 | $wgOut->disable(); |
109 | 109 | |
110 | 110 | // Print content-type and XRDS XML. |
111 | | - header("Content-Type: application/xrds+xml"); |
112 | | - print implode("\n", $xml_template); |
| 111 | + header( "Content-Type: application/xrds+xml" ); |
| 112 | + print implode( "\n", $xml_template ); |
113 | 113 | print $service_text; |
114 | | - print implode("\n", array("</XRD>", "</xrds:XRDS>")); |
| 114 | + print implode( "\n", array( "</XRD>", "</xrds:XRDS>" ) ); |
115 | 115 | } |
116 | 116 | } |
\ No newline at end of file |
Index: trunk/extensions/OpenID/OpenID.setup.php |
— | — | @@ -22,11 +22,11 @@ |
23 | 23 | * @addtogroup Extensions |
24 | 24 | */ |
25 | 25 | |
26 | | -if (!defined('MEDIAWIKI')) { |
| 26 | +if ( !defined( 'MEDIAWIKI' ) ) { |
27 | 27 | exit( 1 ); |
28 | 28 | } |
29 | 29 | |
30 | | -define('MEDIAWIKI_OPENID_VERSION', '0.8.4.1'); |
| 30 | +define( 'MEDIAWIKI_OPENID_VERSION', '0.8.4.1' ); |
31 | 31 | |
32 | 32 | # CONFIGURATION VARIABLES |
33 | 33 | |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | |
36 | 36 | $wgHideOpenIDLoginLink = false; |
37 | 37 | |
38 | | -# Location of the OpenID login logo. You can copy this to your server if you want. |
| 38 | +# Location of the OpenID login logo. You can copy this to your server if you want. |
39 | 39 | $wgOpenIDLoginLogoUrl = $wgScriptPath . '/extensions/OpenID/skin/icons/openid-inputicon.png'; |
40 | 40 | |
41 | 41 | # Whether to show the OpenID identity URL on a user's home page. Possible values are 'always', 'never', or 'user' |
— | — | @@ -158,5 +158,5 @@ |
159 | 159 | $wgHooks['InitPreferencesForm'][] = 'OpenIDHooks::onInitPreferencesForm'; |
160 | 160 | $wgHooks['ResetPreferences'][] = 'OpenIDHooks::onResetPreferences'; |
161 | 161 | $wgHooks['SavePreferences'][] = 'OpenIDHooks::onSavePreferences'; |
162 | | -#Fixme, function does not exist |
163 | | -#$wgHooks['UserLoginForm'][] = 'OpenIDHooks::onUserLoginForm'; |
| 162 | +# FIXME, function does not exist |
| 163 | +# $wgHooks['UserLoginForm'][] = 'OpenIDHooks::onUserLoginForm'; |
Index: trunk/extensions/OpenID/OpenID.php |
— | — | @@ -1,3 +1,3 @@ |
2 | 2 | <?php |
3 | 3 | # backwards compatibility; new sites should require OpenID.setup.php |
4 | | -require_once(dirname(__FILE__) . '/OpenID.setup.php'); |
| 4 | +require_once( dirname( __FILE__ ) . '/OpenID.setup.php' ); |
Index: trunk/extensions/OpenID/TODO |
— | — | @@ -62,4 +62,3 @@ |
63 | 63 | - Dynamic HTML swap in of OpenID login form on Special:Userlogin |
64 | 64 | - warn if a user account has been used as a login before attaching an |
65 | 65 | OpenID |
66 | | - |
\ No newline at end of file |
Index: trunk/extensions/OpenID/optionToTable.php |
— | — | @@ -22,28 +22,28 @@ |
23 | 23 | * @addtogroup Extensions |
24 | 24 | */ |
25 | 25 | |
26 | | -require_once('commandLine.inc'); |
27 | | -ini_set( "include_path", "/usr/share/php:" . ini_get("include_path")); |
| 26 | +require_once( 'commandLine.inc' ); |
| 27 | +ini_set( "include_path", "/usr/share/php:" . ini_get( "include_path" ) ); |
28 | 28 | |
29 | | -require_once("$IP/extensions/OpenID/Consumer.php"); |
| 29 | +require_once( "$IP/extensions/OpenID/Consumer.php" ); |
30 | 30 | |
31 | 31 | global $wgSharedDB, $wgDBprefix; |
32 | 32 | $tableName = "${wgDBprefix}user_openid"; |
33 | | -if (isset($wgSharedDB)) { |
| 33 | +if ( isset( $wgSharedDB ) ) { |
34 | 34 | $tableName = "`$wgSharedDB`.$tableName"; |
35 | 35 | } |
36 | 36 | |
37 | 37 | $dbr =& wfGetDB( DB_SLAVE ); |
38 | 38 | |
39 | | -$res = $dbr->select(array('user'), |
40 | | - array('user_name'), |
41 | | - array('user_options LIKE "%openid_url%"'), |
| 39 | +$res = $dbr->select( array( 'user' ), |
| 40 | + array( 'user_name' ), |
| 41 | + array( 'user_options LIKE "%openid_url%"' ), |
42 | 42 | 'optionToTable', |
43 | | - array('ORDER BY' => 'user_name')); |
| 43 | + array( 'ORDER BY' => 'user_name' ) ); |
44 | 44 | |
45 | | -while ($res && $row = $dbr->fetchObject($res)) { |
46 | | - $user = User::newFromName($row->user_name); |
47 | | - print( $user->getName() . ": " . $user->getOption('openid_url') . "\n"); |
48 | | - OpenIDSetUserUrl($user, $user->getOption('openid_url')); |
| 45 | +while ( $res && $row = $dbr->fetchObject( $res ) ) { |
| 46 | + $user = User::newFromName( $row->user_name ); |
| 47 | + print( $user->getName() . ": " . $user->getOption( 'openid_url' ) . "\n" ); |
| 48 | + OpenIDSetUserUrl( $user, $user->getOption( 'openid_url' ) ); |
49 | 49 | } |
50 | | -$dbr->freeResult($res); |
| 50 | +$dbr->freeResult( $res ); |
Index: trunk/extensions/OpenID/OpenIDProvider.body.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <? |
3 | | -if (!defined('MEDIAWIKI')) |
4 | | - exit(1); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) |
| 4 | + exit( 1 ); |
5 | 5 | |
6 | 6 | class OpenIDProvider { |
7 | 7 | var $id; |
— | — | @@ -8,50 +8,50 @@ |
9 | 9 | var $label; |
10 | 10 | var $url; |
11 | 11 | |
12 | | - function OpenIDProvider($id, $name, $label, $url) { |
| 12 | + function OpenIDProvider( $id, $name, $label, $url ) { |
13 | 13 | $this->id = $id; |
14 | 14 | $this->name = $name; |
15 | 15 | $this->label = $label; |
16 | 16 | $this->url = $url; |
17 | 17 | } |
18 | 18 | |
19 | | - function getButtonHTML($isLarge) { |
| 19 | + function getButtonHTML( $isLarge ) { |
20 | 20 | global $wgOpenIDShowProviderIcons, $wgOpenIDIconPath; |
21 | 21 | |
22 | | - if ($wgOpenIDShowProviderIcons) |
| 22 | + if ( $wgOpenIDShowProviderIcons ) |
23 | 23 | { |
24 | 24 | return '<a id="openid_provider_' . $this->id . '_icon" title="' . $this->name . '"' . |
25 | 25 | ' href="javascript: openid.show(\'' . $this->id . '\');"' . |
26 | | - ' class="openid_' . ($isLarge ? 'large' : 'small') . '_btn' . |
27 | | - ($this->id == 'openid' ? ' openid_selected' : '') . '"></a>'; |
| 26 | + ' class="openid_' . ( $isLarge ? 'large' : 'small' ) . '_btn' . |
| 27 | + ( $this->id == 'openid' ? ' openid_selected' : '' ) . '"></a>'; |
28 | 28 | } |
29 | 29 | else |
30 | 30 | { |
31 | 31 | return '<a id="openid_provider_' . $this->id . '_link" title="' . $this->name . '"' . |
32 | 32 | ' href="javascript: openid.show(\'' . $this->id . '\');"' . |
33 | | - ' class="openid_'.($isLarge ? 'large' : 'small') . '_link' . |
34 | | - ($this->id == 'openid' ? ' openid_selected' : '') . '">' . $this->name . '</a>'; |
| 33 | + ' class="openid_' . ( $isLarge ? 'large' : 'small' ) . '_link' . |
| 34 | + ( $this->id == 'openid' ? ' openid_selected' : '' ) . '">' . $this->name . '</a>'; |
35 | 35 | } |
36 | 36 | } |
37 | | - function getLargeButtonHTML() { return $this->getButtonHTML(true); } |
38 | | - function getSmallButtonHTML() { return $this->getButtonHTML(false); } |
| 37 | + function getLargeButtonHTML() { return $this->getButtonHTML( true ); } |
| 38 | + function getSmallButtonHTML() { return $this->getButtonHTML( false ); } |
39 | 39 | |
40 | 40 | function getLoginFormHTML() { |
41 | 41 | $html = '<div id="provider_form_' . $this->id . '"' . |
42 | | - ($this->id == 'openid' ? '' : ' style="display:none"') . '>' . |
| 42 | + ( $this->id == 'openid' ? '' : ' style="display:none"' ) . '>' . |
43 | 43 | '<div><label for="openid_url">' . $this->label . '</label></div>'; |
44 | 44 | |
45 | | - if ($this->id == 'openid') { |
| 45 | + if ( $this->id == 'openid' ) { |
46 | 46 | $html .= '<input type="text" name="openid_url" id="openid_url" size="50" value="" />'; |
47 | | - $html .= '<input type="submit" value="' . wfMsg('login') . '"/>'; |
| 47 | + $html .= '<input type="submit" value="' . wfMsg( 'login' ) . '"/>'; |
48 | 48 | } else { |
49 | | - $html .= '<input type="hidden" id="openid_provider_url_'.$this->id.'" value="'.$this->url.'" />'; |
50 | | - if (strpos($this->url, '{') === false) { |
51 | | - $html .= '<input type="hidden" id="openid_provider_param_'.$this->id.'" size="25" value="" />'; |
| 49 | + $html .= '<input type="hidden" id="openid_provider_url_' . $this->id . '" value="' . $this->url . '" />'; |
| 50 | + if ( strpos( $this->url, '{' ) === false ) { |
| 51 | + $html .= '<input type="hidden" id="openid_provider_param_' . $this->id . '" size="25" value="" />'; |
52 | 52 | } else { |
53 | | - $html .= '<input type="text" id="openid_provider_param_'.$this->id.'" size="25" value="" />'; |
| 53 | + $html .= '<input type="text" id="openid_provider_param_' . $this->id . '" size="25" value="" />'; |
54 | 54 | } |
55 | | - $html .= '<input type="submit" value="' . wfMsg('login') . '"/>'; |
| 55 | + $html .= '<input type="submit" value="' . wfMsg( 'login' ) . '"/>'; |
56 | 56 | } |
57 | 57 | $html .= '</div>'; |
58 | 58 | |
— | — | @@ -61,35 +61,35 @@ |
62 | 62 | # large ones |
63 | 63 | static function getLargeProviders() { |
64 | 64 | return array( |
65 | | - new self('openid', 'OpenID', wfMsg('openid-provider-label-openid'), '{URL}'), |
66 | | - new self('google', 'Google', wfMsg('openid-provider-label-google'), 'https://www.google.com/accounts/o8/id'), |
67 | | - new self('yahoo', 'Yahoo', wfMsg('openid-provider-label-yahoo'), 'http://yahoo.com/'), |
68 | | - new self('aol', 'AOL', wfMsg('openid-provider-label-aol'), 'http://openid.aol.com/{username}') |
| 65 | + new self( 'openid', 'OpenID', wfMsg( 'openid-provider-label-openid' ), '{URL}' ), |
| 66 | + new self( 'google', 'Google', wfMsg( 'openid-provider-label-google' ), 'https://www.google.com/accounts/o8/id' ), |
| 67 | + new self( 'yahoo', 'Yahoo', wfMsg( 'openid-provider-label-yahoo' ), 'http://yahoo.com/' ), |
| 68 | + new self( 'aol', 'AOL', wfMsg( 'openid-provider-label-aol' ), 'http://openid.aol.com/{username}' ) |
69 | 69 | ); |
70 | 70 | } |
71 | 71 | |
72 | 72 | # smaller ones |
73 | 73 | static function getSmallProviders() { |
74 | 74 | return array( |
75 | | - new self('myopenid', 'MyOpenID', wfMsg('openid-provider-label-other-username', 'MyOpenID'), |
76 | | - 'http://{username}.myopenid.com/'), |
77 | | - new self('livejournal', 'LiveJournal', wfMsg('openid-provider-label-other-username', 'LiveJournal'), |
78 | | - 'http://{username}.livejournal.com/'), |
79 | | - new self('vox', 'VOX', wfMsg('openid-provider-label-other-username', 'VOX'), |
80 | | - 'http://{username}.vox.com/'), |
| 75 | + new self( 'myopenid', 'MyOpenID', wfMsg( 'openid-provider-label-other-username', 'MyOpenID' ), |
| 76 | + 'http://{username}.myopenid.com/' ), |
| 77 | + new self( 'livejournal', 'LiveJournal', wfMsg( 'openid-provider-label-other-username', 'LiveJournal' ), |
| 78 | + 'http://{username}.livejournal.com/' ), |
| 79 | + new self( 'vox', 'VOX', wfMsg( 'openid-provider-label-other-username', 'VOX' ), |
| 80 | + 'http://{username}.vox.com/' ), |
81 | 81 | # wordpress.com doesn't work for some reason |
82 | 82 | # new self('wordpress', 'Wordpress.com', wfMsg('openid-provider-label-other-username', 'Wordpress.com'), |
83 | 83 | # 'http://{username}.wordpress.com/'), |
84 | | - new self('blogger', 'Bloggger', wfMsg('openid-provider-label-other-username', 'Bloggger'), |
85 | | - 'http://{username}.blogspot.com/'), |
86 | | - new self('flickr', 'Flickr', wfMsg('openid-provider-label-other-username', 'Flickr'), |
87 | | - 'http://flickr.com/photos/{username}/'), |
88 | | - new self('verisign', 'Verisign', wfMsg('openid-provider-label-other-username', 'Verisign'), |
89 | | - 'http://{username}.pip.verisignlabs.com/'), |
90 | | - new self('vidoop', 'Vidoop', wfMsg('openid-provider-label-other-username', 'Vidoop'), |
91 | | - 'http://{username}.myvidoop.com/'), |
92 | | - new self('claimid', 'ClaimID', wfMsg('openid-provider-label-other-username', 'ClaimID'), |
93 | | - 'http://claimid.com/{username}') |
| 84 | + new self( 'blogger', 'Bloggger', wfMsg( 'openid-provider-label-other-username', 'Bloggger' ), |
| 85 | + 'http://{username}.blogspot.com/' ), |
| 86 | + new self( 'flickr', 'Flickr', wfMsg( 'openid-provider-label-other-username', 'Flickr' ), |
| 87 | + 'http://flickr.com/photos/{username}/' ), |
| 88 | + new self( 'verisign', 'Verisign', wfMsg( 'openid-provider-label-other-username', 'Verisign' ), |
| 89 | + 'http://{username}.pip.verisignlabs.com/' ), |
| 90 | + new self( 'vidoop', 'Vidoop', wfMsg( 'openid-provider-label-other-username', 'Vidoop' ), |
| 91 | + 'http://{username}.myvidoop.com/' ), |
| 92 | + new self( 'claimid', 'ClaimID', wfMsg( 'openid-provider-label-other-username', 'ClaimID' ), |
| 93 | + 'http://claimid.com/{username}' ) |
94 | 94 | ); |
95 | 95 | } |
96 | 96 | } |