Index: trunk/extensions/CentralAuth/CentralAuthGroupMembershipProxy.php |
— | — | @@ -4,11 +4,25 @@ |
5 | 5 | * user rights manipulation. |
6 | 6 | */ |
7 | 7 | class CentralAuthGroupMembershipProxy { |
| 8 | + |
| 9 | + /** |
| 10 | + * @var CentralAuthUser |
| 11 | + */ |
| 12 | + private $mGlobalUser; |
| 13 | + |
| 14 | + /** |
| 15 | + * @param $user User |
| 16 | + */ |
8 | 17 | private function __construct( $user ) { |
9 | 18 | $this->name = $user->getName(); |
10 | 19 | $this->mGlobalUser = $user; |
11 | 20 | } |
12 | 21 | |
| 22 | + /** |
| 23 | + * @param $wikiID |
| 24 | + * @param $id |
| 25 | + * @return bool |
| 26 | + */ |
13 | 27 | public static function whoIs( $wikiID, $id ) { |
14 | 28 | $user = self::newFromId( $wikiID, $id ); |
15 | 29 | if ( $user ) { |
— | — | @@ -18,48 +32,79 @@ |
19 | 33 | } |
20 | 34 | } |
21 | 35 | |
| 36 | + /** |
| 37 | + * @param $name |
| 38 | + * @return CentralAuthGroupMembershipProxy|null |
| 39 | + */ |
22 | 40 | public static function newFromName( $name ) { |
23 | 41 | $name = User::getCanonicalName( $name ); |
24 | 42 | $globalUser = new CentralAuthUser( $name ); |
25 | 43 | return $globalUser->exists() ? new CentralAuthGroupMembershipProxy( $globalUser ) : null; |
26 | 44 | } |
27 | 45 | |
| 46 | + /** |
| 47 | + * @return Int |
| 48 | + */ |
28 | 49 | public function getId() { |
29 | 50 | return $this->mGlobalUser->getId(); |
30 | 51 | } |
31 | 52 | |
| 53 | + /** |
| 54 | + * @return bool |
| 55 | + */ |
32 | 56 | public function isAnon() { |
33 | 57 | return $this->getId() == 0; |
34 | 58 | } |
35 | 59 | |
| 60 | + /** |
| 61 | + * @return String |
| 62 | + */ |
36 | 63 | public function getName() { |
37 | 64 | return $this->name; |
38 | 65 | } |
39 | 66 | |
| 67 | + /** |
| 68 | + * @return Title |
| 69 | + */ |
40 | 70 | public function getUserPage() { |
41 | 71 | return Title::makeTitle( NS_USER, $this->getName() ); |
42 | 72 | } |
43 | 73 | |
44 | | - // Replaces getUserGroups() |
| 74 | + /** |
| 75 | + * Replaces getUserGroups() |
| 76 | + * @return mixed |
| 77 | + */ |
45 | 78 | function getGroups() { |
46 | 79 | return $this->mGlobalUser->getGlobalGroups(); |
47 | 80 | } |
48 | 81 | |
49 | | - // replaces addUserGroup |
| 82 | + /** |
| 83 | + * replaces addUserGroup |
| 84 | + * @param $group |
| 85 | + */ |
50 | 86 | function addGroup( $group ) { |
51 | 87 | $this->mGlobalUser->addToGlobalGroups( $group ); |
52 | 88 | } |
53 | 89 | |
54 | | - // replaces removeUserGroup |
| 90 | + /** |
| 91 | + * replaces removeUserGroup |
| 92 | + * @param $group |
| 93 | + */ |
55 | 94 | function removeGroup( $group ) { |
56 | 95 | $this->mGlobalUser->removeFromGlobalGroups( $group ); |
57 | 96 | } |
58 | 97 | |
59 | | - // replaces touchUser |
| 98 | + /** |
| 99 | + * replaces touchUser |
| 100 | + */ |
60 | 101 | function invalidateCache() { |
61 | 102 | $this->mGlobalUser->invalidateCache(); |
62 | 103 | } |
63 | | - |
| 104 | + |
| 105 | + /** |
| 106 | + * @param $wiki string |
| 107 | + * @return Bool |
| 108 | + */ |
64 | 109 | function attachedOn( $wiki ) { |
65 | 110 | return $this->mGlobalUser->attachedOn( $wiki ); |
66 | 111 | } |
Index: trunk/extensions/CentralAuth/specials/SpecialCentralAuth.php |
— | — | @@ -9,6 +9,8 @@ |
10 | 10 | |
11 | 11 | var $mAttachedLocalAccounts, $mUnattachedLocalAccounts; |
12 | 12 | |
| 13 | + var $mMethod, $mPosted, $mWikis; |
| 14 | + |
13 | 15 | function __construct() { |
14 | 16 | parent::__construct( 'CentralAuth' ); |
15 | 17 | } |
— | — | @@ -92,7 +94,9 @@ |
93 | 95 | } |
94 | 96 | } |
95 | 97 | |
96 | | - /** Returns true if the normal form should be displayed */ |
| 98 | + /** |
| 99 | + * @return bool Returns true if the normal form should be displayed |
| 100 | + */ |
97 | 101 | function doSubmit() { |
98 | 102 | $deleted = false; |
99 | 103 | $globalUser = $this->mGlobalUser; |
— | — | @@ -210,6 +214,9 @@ |
211 | 215 | return !$deleted; |
212 | 216 | } |
213 | 217 | |
| 218 | + /** |
| 219 | + * @param $wikitext string |
| 220 | + */ |
214 | 221 | function showStatusError( $wikitext ) { |
215 | 222 | global $wgOut; |
216 | 223 | $wrap = Xml::tags( 'div', array( 'class' => 'error' ), $wikitext ); |
— | — | @@ -222,7 +229,6 @@ |
223 | 230 | $wgOut->wrapWikiMsg( '<div class="error">$1</div>', $args ); |
224 | 231 | } |
225 | 232 | |
226 | | - |
227 | 233 | function showSuccess( /* varargs */ ) { |
228 | 234 | global $wgOut; |
229 | 235 | $args = func_get_args(); |
— | — | @@ -253,6 +259,10 @@ |
254 | 260 | ); |
255 | 261 | } |
256 | 262 | |
| 263 | + /** |
| 264 | + * @param $span |
| 265 | + * @return String |
| 266 | + */ |
257 | 267 | function prettyTimespan( $span ) { |
258 | 268 | global $wgLang; |
259 | 269 | $units = array( |
— | — | @@ -309,8 +319,9 @@ |
310 | 320 | $wgOut->addHTML( "<fieldset><legend>{$legend}</legend>" ); |
311 | 321 | $wgOut->addHTML( $this->listHeader() ); |
312 | 322 | $wgOut->addHTML( $this->listMerged( $merged ) ); |
313 | | - if ( $remainder ) |
| 323 | + if ( $remainder ) { |
314 | 324 | $wgOut->addHTML( $this->listRemainder( $remainder ) ); |
| 325 | + } |
315 | 326 | $wgOut->addHTML( $this->listFooter() ); |
316 | 327 | $wgOut->addHTML( '</fieldset>' ); |
317 | 328 | } |
— | — | @@ -352,11 +363,19 @@ |
353 | 364 | return $footer; |
354 | 365 | } |
355 | 366 | |
| 367 | + /** |
| 368 | + * @param $list |
| 369 | + * @return string |
| 370 | + */ |
356 | 371 | function listMerged( $list ) { |
357 | 372 | ksort( $list ); |
358 | 373 | return implode( "\n", array_map( array( $this, 'listMergedWikiItem' ), $list ) ); |
359 | 374 | } |
360 | 375 | |
| 376 | + /** |
| 377 | + * @param $list |
| 378 | + * @return string |
| 379 | + */ |
361 | 380 | function listRemainder( $list ) { |
362 | 381 | ksort( $list ); |
363 | 382 | $notMerged = wfMsgExt( 'centralauth-admin-unattached', array( 'parseinline' ) ); |
— | — | @@ -367,9 +386,13 @@ |
368 | 387 | $this->foreignUserLink( $row['wiki'] ) . |
369 | 388 | "</td><td colspan='4'>{$notMerged}</td></tr>\n"; |
370 | 389 | } |
371 | | - return implode( $rows ); |
| 390 | + return implode( '\n', $rows ); |
372 | 391 | } |
373 | 392 | |
| 393 | + /** |
| 394 | + * @param $row |
| 395 | + * @return string |
| 396 | + */ |
374 | 397 | function listMergedWikiItem( $row ) { |
375 | 398 | global $wgLang; |
376 | 399 | if ( $row === null ) { |
— | — | @@ -393,6 +416,10 @@ |
394 | 417 | '</tr>'; |
395 | 418 | } |
396 | 419 | |
| 420 | + /** |
| 421 | + * @param $method |
| 422 | + * @return string |
| 423 | + */ |
397 | 424 | function formatMergeMethod( $method ) { |
398 | 425 | global $wgExtensionAssetsPath; |
399 | 426 | |
— | — | @@ -402,6 +429,10 @@ |
403 | 430 | "<span class=\"merge-method-help\" title=\"{$brief}\" onclick=\"showMethodHint('{$method}')\">(?)</span>"; |
404 | 431 | } |
405 | 432 | |
| 433 | + /** |
| 434 | + * @param $row |
| 435 | + * @return String |
| 436 | + */ |
406 | 437 | function formatBlockStatus( $row ) { |
407 | 438 | if ( $row['blocked'] ) { |
408 | 439 | if ( $row['block-expiry'] == 'infinity' ) { |
— | — | @@ -428,6 +459,11 @@ |
429 | 460 | 'page=User:' . urlencode( $this->mUserName ) ); |
430 | 461 | } |
431 | 462 | |
| 463 | + /** |
| 464 | + * @param $row |
| 465 | + * @return string |
| 466 | + * @throws MWException |
| 467 | + */ |
432 | 468 | function formatEditcount( $row ) { |
433 | 469 | $wiki = WikiMap::getWiki( $row['wiki'] ); |
434 | 470 | if ( !$wiki ) { |
— | — | @@ -444,6 +480,10 @@ |
445 | 481 | ); |
446 | 482 | } |
447 | 483 | |
| 484 | + /** |
| 485 | + * @param $level |
| 486 | + * @return String |
| 487 | + */ |
448 | 488 | function formatHiddenLevel( $level ) { |
449 | 489 | switch( $level ) { |
450 | 490 | case CentralAuthUser::HIDDEN_NONE: |
— | — | @@ -455,12 +495,26 @@ |
456 | 496 | } |
457 | 497 | } |
458 | 498 | |
| 499 | + /** |
| 500 | + * @param $element |
| 501 | + * @param $cols |
| 502 | + * @return string |
| 503 | + */ |
459 | 504 | function tableRow( $element, $cols ) { |
460 | 505 | return "<tr><$element>" . |
461 | 506 | implode( "</$element><$element>", $cols ) . |
462 | 507 | "</$element></tr>"; |
463 | 508 | } |
464 | 509 | |
| 510 | + /** |
| 511 | + * @param $wikiID |
| 512 | + * @param $title |
| 513 | + * @param $text |
| 514 | + * @param string $hint |
| 515 | + * @param string $params |
| 516 | + * @return string |
| 517 | + * @throws MWException |
| 518 | + */ |
465 | 519 | function foreignLink( $wikiID, $title, $text, $hint = '', $params = '' ) { |
466 | 520 | if ( $wikiID instanceof WikiReference ) { |
467 | 521 | $wiki = $wikiID; |
— | — | @@ -483,6 +537,11 @@ |
484 | 538 | $text ); |
485 | 539 | } |
486 | 540 | |
| 541 | + /** |
| 542 | + * @param $wikiID |
| 543 | + * @return string |
| 544 | + * @throws MWException |
| 545 | + */ |
487 | 546 | function foreignUserLink( $wikiID ) { |
488 | 547 | $wiki = WikiMap::getWiki( $wikiID ); |
489 | 548 | if ( !$wiki ) { |
— | — | @@ -497,9 +556,12 @@ |
498 | 557 | wfMsg( 'centralauth-foreign-link', $this->mUserName, $wikiname ) ); |
499 | 558 | } |
500 | 559 | |
| 560 | + /** |
| 561 | + * @param $wikiID |
| 562 | + * @return string |
| 563 | + */ |
501 | 564 | function adminCheck( $wikiID ) { |
502 | | - return |
503 | | - Xml::check( 'wpWikis[]', false, array( 'value' => $wikiID ) ); |
| 565 | + return Xml::check( 'wpWikis[]', false, array( 'value' => $wikiID ) ); |
504 | 566 | } |
505 | 567 | |
506 | 568 | function showActionForm( $action ) { |
— | — | @@ -601,6 +663,9 @@ |
602 | 664 | $wgOut->addHTML( $form ); |
603 | 665 | } |
604 | 666 | |
| 667 | + /** |
| 668 | + * |
| 669 | + */ |
605 | 670 | function showLogExtract() { |
606 | 671 | global $wgOut; |
607 | 672 | $user = $this->mGlobalUser->getName(); |
— | — | @@ -616,6 +681,9 @@ |
617 | 682 | } |
618 | 683 | } |
619 | 684 | |
| 685 | + /** |
| 686 | + * @return int|string |
| 687 | + */ |
620 | 688 | function determineHomeWiki() { |
621 | 689 | foreach ( $this->mAttachedLocalAccounts as $wiki => $acc ) { |
622 | 690 | if ( $acc['attachedMethod'] == 'primary' || $acc['attachedMethod'] == 'new' ) { |
— | — | @@ -627,6 +695,9 @@ |
628 | 696 | return wfMsgHtml( 'centralauth-admin-nohome' ); |
629 | 697 | } |
630 | 698 | |
| 699 | + /** |
| 700 | + * @return int |
| 701 | + */ |
631 | 702 | function evaluateTotalEditcount() { |
632 | 703 | $total = 0; |
633 | 704 | foreach ( $this->mAttachedLocalAccounts as $acc ) { |