Index: trunk/extensions/CentralAuth/CentralAuthPlugin.php |
— | — | @@ -86,9 +86,8 @@ |
87 | 87 | * |
88 | 88 | * @param $username String: username. |
89 | 89 | * @return bool |
90 | | - * @public |
91 | 90 | */ |
92 | | - function strictUserAuth( $username ) { |
| 91 | + public function strictUserAuth( $username ) { |
93 | 92 | // Authenticate locally if the global account doesn't exist, |
94 | 93 | // or the local account isn't attached |
95 | 94 | // If strict is on, local authentication won't work at all |
— | — | @@ -104,10 +103,10 @@ |
105 | 104 | * The User object is passed by reference so it can be modified; don't |
106 | 105 | * forget the & on your function declaration. |
107 | 106 | * |
108 | | - * @param User $user |
109 | | - * @public |
| 107 | + * @param $user User |
| 108 | + * @return bool |
110 | 109 | */ |
111 | | - function updateUser( &$user ) { |
| 110 | + public function updateUser( &$user ) { |
112 | 111 | $central = CentralAuthUser::getInstance( $user ); |
113 | 112 | if ( $central->exists() && $central->isAttached() && |
114 | 113 | $central->getEmail() != $user->getEmail() ) |
— | — | @@ -132,9 +131,8 @@ |
133 | 132 | * This is just a question, and shouldn't perform any actions. |
134 | 133 | * |
135 | 134 | * @return bool |
136 | | - * @public |
137 | 135 | */ |
138 | | - function autoCreate() { |
| 136 | + public function autoCreate() { |
139 | 137 | global $wgGroupPermissions; |
140 | 138 | // Yes unless account creation is restricted on this wiki |
141 | 139 | return !empty( $wgGroupPermissions['*']['createaccount'] ) |
— | — | @@ -148,9 +146,8 @@ |
149 | 147 | * @param $user User object. |
150 | 148 | * @param $password String: password. |
151 | 149 | * @return bool |
152 | | - * @public |
153 | 150 | */ |
154 | | - function setPassword( $user, $password ) { |
| 151 | + public function setPassword( $user, $password ) { |
155 | 152 | // Fixme: password changes should happen through central interface. |
156 | 153 | $central = CentralAuthUser::getInstance( $user ); |
157 | 154 | if ( $central->isAttached() ) { |
— | — | @@ -167,9 +164,8 @@ |
168 | 165 | * |
169 | 166 | * @param $user User object. |
170 | 167 | * @return bool |
171 | | - * @public |
172 | 168 | */ |
173 | | - function updateExternalDB( $user ) { |
| 169 | + public function updateExternalDB( $user ) { |
174 | 170 | return true; |
175 | 171 | } |
176 | 172 | |
— | — | @@ -177,9 +173,8 @@ |
178 | 174 | * Check to see if external accounts can be created. |
179 | 175 | * Return true if external accounts can be created. |
180 | 176 | * @return bool |
181 | | - * @public |
182 | 177 | */ |
183 | | - function canCreateAccounts() { |
| 178 | + public function canCreateAccounts() { |
184 | 179 | // Require accounts to be created through the central login interface? |
185 | 180 | return true; |
186 | 181 | } |
— | — | @@ -196,9 +191,8 @@ |
197 | 192 | * @param string $email |
198 | 193 | * @param string $realname |
199 | 194 | * @return bool |
200 | | - * @public |
201 | 195 | */ |
202 | | - function addUser( $user, $password, $email = '', $realname = '' ) { |
| 196 | + public function addUser( $user, $password, $email = '', $realname = '' ) { |
203 | 197 | global $wgCentralAuthAutoNew; |
204 | 198 | if ( $wgCentralAuthAutoNew ) { |
205 | 199 | $central = CentralAuthUser::getInstance( $user ); |
— | — | @@ -220,9 +214,8 @@ |
221 | 215 | * This is just a question, and shouldn't perform any actions. |
222 | 216 | * |
223 | 217 | * @return bool |
224 | | - * @public |
225 | 218 | */ |
226 | | - function strict() { |
| 219 | + public function strict() { |
227 | 220 | global $wgCentralAuthStrict; |
228 | 221 | return $wgCentralAuthStrict; |
229 | 222 | } |
— | — | @@ -236,9 +229,9 @@ |
237 | 230 | * forget the & on your function declaration. |
238 | 231 | * |
239 | 232 | * @param $user User object. |
240 | | - * @public |
| 233 | + * @param $autocreate bool |
241 | 234 | */ |
242 | | - function initUser( &$user, $autocreate = false ) { |
| 235 | + public function initUser( &$user, $autocreate = false ) { |
243 | 236 | if ( $autocreate ) { |
244 | 237 | $central = CentralAuthUser::getInstance( $user ); |
245 | 238 | if ( $central->exists() ) { |
— | — | @@ -249,17 +242,26 @@ |
250 | 243 | } |
251 | 244 | } |
252 | 245 | |
| 246 | + /** |
| 247 | + * @param User $user |
| 248 | + * @return CentralAuthUser |
| 249 | + */ |
253 | 250 | public function getUserInstance( User &$user ) { |
254 | 251 | return CentralAuthUser::getInstance( $user ); |
255 | 252 | } |
256 | | - |
| 253 | + |
| 254 | + /** |
| 255 | + * @param $template |
| 256 | + * @param $type |
| 257 | + * @return mixed |
| 258 | + */ |
257 | 259 | public function modifyUITemplate( &$template, &$type ) { |
258 | 260 | global $wgCentralAuthCookies; |
259 | 261 | |
260 | 262 | $template->set( 'usedomain', false ); |
261 | 263 | |
262 | 264 | if ( !$wgCentralAuthCookies ) return; |
263 | | - |
| 265 | + |
264 | 266 | $label = Xml::checkLabel( wfMsg( 'centralauth-login-global' ), 'wpCentralLogin', 'wpCentralLogin', true, array( 'tabindex' => '4' ) ); |
265 | 267 | $field = <<<HTML |
266 | 268 | <tr id="mw-centralauth-login"> |
Index: trunk/extensions/CentralAuth/CentralAuthUserArray.php |
— | — | @@ -9,6 +9,9 @@ |
10 | 10 | class CentralAuthUserArrayFromResult extends UserArrayFromResult { |
11 | 11 | var $globalData; |
12 | 12 | |
| 13 | + /** |
| 14 | + * @param $res ResultWrapper |
| 15 | + */ |
13 | 16 | function __construct( $res ) { |
14 | 17 | parent::__construct( $res ); |
15 | 18 | |
— | — | @@ -40,6 +43,9 @@ |
41 | 44 | array_keys( $this->globalData ) ) . "\n" ); |
42 | 45 | } |
43 | 46 | |
| 47 | + /** |
| 48 | + * @param $row |
| 49 | + */ |
44 | 50 | function setCurrent( $row ) { |
45 | 51 | parent::setCurrent( $row ); |
46 | 52 | |
Index: trunk/extensions/CentralAuth/CentralAuthUser.php |
— | — | @@ -1341,6 +1341,12 @@ |
1342 | 1342 | return false; |
1343 | 1343 | } |
1344 | 1344 | |
| 1345 | + /** |
| 1346 | + * @param $passwords |
| 1347 | + * @param $salt |
| 1348 | + * @param $encrypted |
| 1349 | + * @return bool |
| 1350 | + */ |
1345 | 1351 | protected function matchHashes( $passwords, $salt, $encrypted ) { |
1346 | 1352 | foreach ( $passwords as $plaintext ) { |
1347 | 1353 | if ( $this->matchHash( $plaintext, $salt, $encrypted ) ) { |
Index: trunk/extensions/CentralAuth/CentralAuth.php |
— | — | @@ -250,6 +250,15 @@ |
251 | 251 | $wgLogActionsHandlers["gblrights/{$type}"] = 'efHandleWikiSetLogEntry'; |
252 | 252 | } |
253 | 253 | |
| 254 | +/** |
| 255 | + * @param $type |
| 256 | + * @param $action |
| 257 | + * @param $title |
| 258 | + * @param $skin Skin |
| 259 | + * @param $params |
| 260 | + * @param $filterWikilinks bool |
| 261 | + * @return String |
| 262 | + */ |
254 | 263 | function efHandleWikiSetLogEntry( $type, $action, $title, $skin, $params, $filterWikilinks = false ) { |
255 | 264 | $link = $skin ? $skin->makeLinkObj( $title, htmlspecialchars( $params[0] ) ) : $params[0]; |
256 | 265 | |
Index: trunk/extensions/CentralAuth/specials/SpecialGlobalGroupMembership.php |
— | — | @@ -90,12 +90,22 @@ |
91 | 91 | return CentralAuthUser::availableGlobalGroups(); |
92 | 92 | } |
93 | 93 | |
| 94 | + /** |
| 95 | + * @param $user User |
| 96 | + * @param $output |
| 97 | + */ |
94 | 98 | protected function showLogFragment( $user, $output ) { |
95 | 99 | $pageTitle = Title::makeTitleSafe( NS_USER, $user->getName() ); |
96 | 100 | $output->addHTML( Xml::element( 'h2', null, LogPage::logName( 'gblrights' ) . "\n" ) ); |
97 | 101 | LogEventsList::showLogExtract( $output, 'gblrights', $pageTitle->getPrefixedText() ); |
98 | 102 | } |
99 | 103 | |
| 104 | + /** |
| 105 | + * @param $user User |
| 106 | + * @param $oldGroups |
| 107 | + * @param $newGroups |
| 108 | + * @param $reason |
| 109 | + */ |
100 | 110 | function addLogEntry( $user, $oldGroups, $newGroups, $reason ) { |
101 | 111 | $log = new LogPage( 'gblrights' ); |
102 | 112 | |
Index: trunk/extensions/CentralAuth/specials/SpecialMergeAccount.php |
— | — | @@ -105,6 +105,9 @@ |
106 | 106 | $this->mSessionKey = $key; |
107 | 107 | } |
108 | 108 | |
| 109 | + /** |
| 110 | + * @return array|mixed |
| 111 | + */ |
109 | 112 | private function getWorkingPasswords() { |
110 | 113 | wfSuppressWarnings(); |
111 | 114 | $passwords = unserialize( |
— | — | @@ -139,6 +142,11 @@ |
140 | 143 | unset( $_SESSION['wsCentralAuthMigration'][$this->mSessionToken] ); |
141 | 144 | } |
142 | 145 | |
| 146 | + /** |
| 147 | + * @param $text |
| 148 | + * @param $key |
| 149 | + * @return array |
| 150 | + */ |
143 | 151 | function xorString( $text, $key ) { |
144 | 152 | if ( $key != '' ) { |
145 | 153 | for ( $i = 0; $i < strlen( $text ); $i++ ) { |
Index: trunk/extensions/CentralAuth/specials/SpecialWikiSets.php |
— | — | @@ -156,6 +156,11 @@ |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
| 160 | + /** |
| 161 | + * @param $name |
| 162 | + * @param $value |
| 163 | + * @return string |
| 164 | + */ |
160 | 165 | function buildTypeSelector( $name, $value ) { |
161 | 166 | $select = new XmlSelect( $name, 'set-type', $value ); |
162 | 167 | foreach ( array( WikiSet::OPTIN, WikiSet::OPTOUT ) as $type ) { |
— | — | @@ -164,6 +169,10 @@ |
165 | 170 | return $select->getHTML(); |
166 | 171 | } |
167 | 172 | |
| 173 | + /** |
| 174 | + * @param $list array |
| 175 | + * @return string |
| 176 | + */ |
168 | 177 | function buildWikiList( $list ) { |
169 | 178 | sort( $list ); |
170 | 179 | $html = '<ul>'; |
— | — | @@ -278,6 +287,7 @@ |
279 | 288 | |
280 | 289 | $set = WikiSet::newFromID( $set ); |
281 | 290 | if ( !$set ) { |
| 291 | + // FIXME: $subpage is undefined |
282 | 292 | $this->buildMainView( '<strong class="error">' . wfMsgHtml( 'centralauth-editset-notfound', $subpage ) . '</strong>' ); |
283 | 293 | return; |
284 | 294 | } |
Index: trunk/extensions/CentralAuth/SuppressUserJob.php |
— | — | @@ -22,7 +22,11 @@ |
23 | 23 | * @return bool |
24 | 24 | */ |
25 | 25 | public function run() { |
26 | | - extract( $this->params ); |
| 26 | + $username = $this->params['username']; |
| 27 | + $by = $this->params['by']; |
| 28 | + $wikis = $this->params['wikis']; |
| 29 | + $suppress = $this->params['suppress']; |
| 30 | + $reason = $this->params['reason']; |
27 | 31 | $user = new CentralAuthUser( $username ); |
28 | 32 | if ( !$user->exists() ) { |
29 | 33 | wfDebugLog( 'suppressjob', "Requested to suppress non-existent user {$username} by {$by}." ); |
Index: trunk/extensions/CentralAuth/CentralAuthHooks.php |
— | — | @@ -18,6 +18,8 @@ |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Add a little pretty to the preferences user info section |
| 22 | + * |
| 23 | + * @param $user User |
22 | 24 | */ |
23 | 25 | static function onGetPreferences( $user, &$preferences ) { |
24 | 26 | global $wgUser, $wgLang; |
— | — | @@ -410,6 +412,8 @@ |
411 | 413 | |
412 | 414 | /** |
413 | 415 | * Helper function for onUserLoadFromSession |
| 416 | + * @param $user User |
| 417 | + * @param $token |
414 | 418 | */ |
415 | 419 | static function initSession( $user, $token ) { |
416 | 420 | $userName = $user->getName(); |
— | — | @@ -564,6 +568,11 @@ |
565 | 569 | return true; |
566 | 570 | } |
567 | 571 | |
| 572 | + /** |
| 573 | + * @param $user User |
| 574 | + * @param $rights |
| 575 | + * @return bool |
| 576 | + */ |
568 | 577 | static function onUserGetRights( $user, &$rights ) { |
569 | 578 | if ( !$user->isAnon() ) { |
570 | 579 | $centralUser = CentralAuthUser::getInstance( $user ); |
— | — | @@ -591,6 +600,10 @@ |
592 | 601 | |
593 | 602 | /** |
594 | 603 | * Destroy local login cookies so that remote logout works |
| 604 | + * @param $user User |
| 605 | + * @param $session |
| 606 | + * @param $cookies |
| 607 | + * @return bool |
595 | 608 | */ |
596 | 609 | static function onUserSetCookies( $user, &$session, &$cookies ) { |
597 | 610 | global $wgCentralAuthCookies; |
— | — | @@ -624,6 +637,13 @@ |
625 | 638 | return true; |
626 | 639 | } |
627 | 640 | |
| 641 | + /** |
| 642 | + * @param $title Title |
| 643 | + * @param $user User |
| 644 | + * @param $action |
| 645 | + * @param $result |
| 646 | + * @return bool |
| 647 | + */ |
628 | 648 | static function onGetUserPermissionsErrorsExpensive( $title, $user, $action, &$result ) { |
629 | 649 | global $wgCentralAuthLockedCanEdit; |
630 | 650 | |
— | — | @@ -644,6 +664,12 @@ |
645 | 665 | return true; |
646 | 666 | } |
647 | 667 | |
| 668 | + /** |
| 669 | + * @param $auth |
| 670 | + * @param $user User |
| 671 | + * @param $params |
| 672 | + * @return bool |
| 673 | + */ |
648 | 674 | static function onSecurePoll_GetUserParams( $auth, $user, &$params ) { |
649 | 675 | if ( $user->isAnon() ) { |
650 | 676 | return true; |
Index: trunk/extensions/CentralAuth/WikiSet.php |
— | — | @@ -27,19 +27,60 @@ |
28 | 28 | |
29 | 29 | protected static function memcKey( $k ) { return "wikiset:{$k}"; } |
30 | 30 | |
| 31 | + /** |
| 32 | + * @return int |
| 33 | + */ |
31 | 34 | public function getId() { return $this->mId; } |
| 35 | + |
| 36 | + /** |
| 37 | + * @return bool |
| 38 | + */ |
32 | 39 | public function exists() { return (bool)$this->getID(); } |
| 40 | + |
| 41 | + /** |
| 42 | + * @return string |
| 43 | + */ |
33 | 44 | public function getName() { return $this->mName; } |
| 45 | + |
| 46 | + /** |
| 47 | + * @param $n |
| 48 | + * @param $commit bool |
| 49 | + */ |
34 | 50 | public function setName( $n, $commit = false ) { return $this->setDbField( 'ws_name', $n, $commit ); } |
| 51 | + |
| 52 | + /** |
| 53 | + * @return array |
| 54 | + */ |
35 | 55 | public function getWikisRaw() { return $this->mWikis; } |
| 56 | + |
| 57 | + /** |
| 58 | + * @param $w |
| 59 | + * @param $commit bool |
| 60 | + */ |
36 | 61 | public function setWikisRaw( $w, $commit = false ) { return $this->setDbField( 'ws_wikis', $w, $commit ); } |
| 62 | + |
| 63 | + /** |
| 64 | + * @return string |
| 65 | + */ |
37 | 66 | public function getType() { return $this->mType; } |
| 67 | + |
| 68 | + /** |
| 69 | + * @param $t |
| 70 | + * @param bool $commit bool |
| 71 | + * @return bool |
| 72 | + */ |
38 | 73 | public function setType( $t, $commit = false ) { |
39 | 74 | if ( !in_array( $t, array( self::OPTIN, self::OPTOUT ) ) ) { |
40 | 75 | return false; |
41 | 76 | } |
42 | 77 | return $this->setDbField( 'ws_type', $t, $commit ); |
43 | 78 | } |
| 79 | + |
| 80 | + /** |
| 81 | + * @param $field |
| 82 | + * @param $value |
| 83 | + * @param $commit |
| 84 | + */ |
44 | 85 | protected function setDbField( $field, $value, $commit ) { |
45 | 86 | $map = array( 'ws_name' => 'mName', 'ws_type' => 'mType', 'ws_wikis' => 'mWikis' ); |
46 | 87 | $mname = $map[$field]; |
— | — | @@ -49,6 +90,10 @@ |
50 | 91 | } |
51 | 92 | } |
52 | 93 | |
| 94 | + /** |
| 95 | + * @param $row |
| 96 | + * @return null|WikiSet |
| 97 | + */ |
53 | 98 | public static function newFromRow( $row ) { |
54 | 99 | if ( !$row ) { |
55 | 100 | return null; |
— | — | @@ -61,6 +106,11 @@ |
62 | 107 | ); |
63 | 108 | } |
64 | 109 | |
| 110 | + /** |
| 111 | + * @param $name |
| 112 | + * @param $useCache bool |
| 113 | + * @return null|WikiSet |
| 114 | + */ |
65 | 115 | public static function newFromName( $name, $useCache = true ) { |
66 | 116 | if ( $useCache ) { |
67 | 117 | global $wgMemc; |
— | — | @@ -86,6 +136,11 @@ |
87 | 137 | return $ws; |
88 | 138 | } |
89 | 139 | |
| 140 | + /** |
| 141 | + * @param $id |
| 142 | + * @param $useCache bool |
| 143 | + * @return null|WikiSet |
| 144 | + */ |
90 | 145 | public static function newFromID( $id, $useCache = true ) { |
91 | 146 | if ( $useCache ) { |
92 | 147 | global $wgMemc; |
— | — | @@ -111,6 +166,9 @@ |
112 | 167 | return $ws; |
113 | 168 | } |
114 | 169 | |
| 170 | + /** |
| 171 | + * @return bool |
| 172 | + */ |
115 | 173 | public function commit() { |
116 | 174 | $dbw = CentralAuthUser::getCentralDB(); |
117 | 175 | $dbw->replace( 'wikiset', array( 'ws_id' ), |
— | — | @@ -129,6 +187,9 @@ |
130 | 188 | return (bool)$dbw->affectedRows(); |
131 | 189 | } |
132 | 190 | |
| 191 | + /** |
| 192 | + * @return bool |
| 193 | + */ |
133 | 194 | public function delete() { |
134 | 195 | $dbw = CentralAuthUser::getCentralDB(); |
135 | 196 | $dbw->delete( 'wikiset', array( 'ws_id' => $this->mId ), __METHOD__ ); |
— | — | @@ -152,14 +213,21 @@ |
153 | 214 | $wgMemc->set( self::memcKey( $this->mId ), $data ); |
154 | 215 | } |
155 | 216 | |
| 217 | + /** |
| 218 | + * @return array |
| 219 | + */ |
156 | 220 | public function getWikis() { |
157 | 221 | if ( $this->mType == self::OPTIN ) { |
158 | 222 | return $this->mWikis; |
| 223 | + } else { |
| 224 | + return array_diff( CentralAuthUser::getWikiList(), $this->mWikis ); |
159 | 225 | } |
160 | | - else |
161 | | - return array_diff( CentralAuthUser::getWikiList(), $this->mWikis ); |
162 | 226 | } |
163 | 227 | |
| 228 | + /** |
| 229 | + * @param $wiki string |
| 230 | + * @return bool |
| 231 | + */ |
164 | 232 | public function inSet( $wiki = '' ) { |
165 | 233 | if ( !$wiki ) { |
166 | 234 | $wiki = wfWikiID(); |
— | — | @@ -167,6 +235,9 @@ |
168 | 236 | return in_array( $wiki, $this->getWikis() ); |
169 | 237 | } |
170 | 238 | |
| 239 | + /** |
| 240 | + * @return array |
| 241 | + */ |
171 | 242 | public function getRestrictedGroups() { |
172 | 243 | $dbr = CentralAuthUser::getCentralSlaveDB(); |
173 | 244 | $r = $dbr->select( |
— | — | @@ -179,6 +250,9 @@ |
180 | 251 | return $result; |
181 | 252 | } |
182 | 253 | |
| 254 | + /** |
| 255 | + * @return array |
| 256 | + */ |
183 | 257 | public static function getAllWikiSets() { |
184 | 258 | $dbr = CentralAuthUser::getCentralSlaveDB(); |
185 | 259 | $res = $dbr->select( 'wikiset', '*', false, __METHOD__ ); |
— | — | @@ -189,12 +263,21 @@ |
190 | 264 | return $result; |
191 | 265 | } |
192 | 266 | |
| 267 | + /** |
| 268 | + * @param $group |
| 269 | + * @return int |
| 270 | + */ |
193 | 271 | public static function getWikiSetForGroup( $group ) { |
194 | 272 | $dbr = CentralAuthUser::getCentralSlaveDB(); |
195 | 273 | $res = $dbr->selectRow( 'global_group_restrictions', '*', array( 'ggr_group' => $group ), __METHOD__ ); |
196 | 274 | return $res ? $res->ggr_set : 0; |
197 | 275 | } |
198 | 276 | |
| 277 | + /** |
| 278 | + * @static |
| 279 | + * @param $type |
| 280 | + * @return string |
| 281 | + */ |
199 | 282 | public static function formatType( $type ) { |
200 | 283 | return wfMsgHtml( "centralauth-rightslog-set-{$type}" ); |
201 | 284 | } |