r103181 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103180‎ | r103181 | r103182 >
Date:15:31, 15 November 2011
Author:reedy
Status:resolved
Tags:
Comment:
Fix missing parameter to implode in SpecialCentralAuth

Documentation to CentralAuthGroupMembershipProxy and SpecialCentralAuth
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuthGroupMembershipProxy.php (modified) (history)
  • /trunk/extensions/CentralAuth/specials/SpecialCentralAuth.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/CentralAuthGroupMembershipProxy.php
@@ -4,11 +4,25 @@
55 * user rights manipulation.
66 */
77 class CentralAuthGroupMembershipProxy {
 8+
 9+ /**
 10+ * @var CentralAuthUser
 11+ */
 12+ private $mGlobalUser;
 13+
 14+ /**
 15+ * @param $user User
 16+ */
817 private function __construct( $user ) {
918 $this->name = $user->getName();
1019 $this->mGlobalUser = $user;
1120 }
1221
 22+ /**
 23+ * @param $wikiID
 24+ * @param $id
 25+ * @return bool
 26+ */
1327 public static function whoIs( $wikiID, $id ) {
1428 $user = self::newFromId( $wikiID, $id );
1529 if ( $user ) {
@@ -18,48 +32,79 @@
1933 }
2034 }
2135
 36+ /**
 37+ * @param $name
 38+ * @return CentralAuthGroupMembershipProxy|null
 39+ */
2240 public static function newFromName( $name ) {
2341 $name = User::getCanonicalName( $name );
2442 $globalUser = new CentralAuthUser( $name );
2543 return $globalUser->exists() ? new CentralAuthGroupMembershipProxy( $globalUser ) : null;
2644 }
2745
 46+ /**
 47+ * @return Int
 48+ */
2849 public function getId() {
2950 return $this->mGlobalUser->getId();
3051 }
3152
 53+ /**
 54+ * @return bool
 55+ */
3256 public function isAnon() {
3357 return $this->getId() == 0;
3458 }
3559
 60+ /**
 61+ * @return String
 62+ */
3663 public function getName() {
3764 return $this->name;
3865 }
3966
 67+ /**
 68+ * @return Title
 69+ */
4070 public function getUserPage() {
4171 return Title::makeTitle( NS_USER, $this->getName() );
4272 }
4373
44 - // Replaces getUserGroups()
 74+ /**
 75+ * Replaces getUserGroups()
 76+ * @return mixed
 77+ */
4578 function getGroups() {
4679 return $this->mGlobalUser->getGlobalGroups();
4780 }
4881
49 - // replaces addUserGroup
 82+ /**
 83+ * replaces addUserGroup
 84+ * @param $group
 85+ */
5086 function addGroup( $group ) {
5187 $this->mGlobalUser->addToGlobalGroups( $group );
5288 }
5389
54 - // replaces removeUserGroup
 90+ /**
 91+ * replaces removeUserGroup
 92+ * @param $group
 93+ */
5594 function removeGroup( $group ) {
5695 $this->mGlobalUser->removeFromGlobalGroups( $group );
5796 }
5897
59 - // replaces touchUser
 98+ /**
 99+ * replaces touchUser
 100+ */
60101 function invalidateCache() {
61102 $this->mGlobalUser->invalidateCache();
62103 }
63 -
 104+
 105+ /**
 106+ * @param $wiki string
 107+ * @return Bool
 108+ */
64109 function attachedOn( $wiki ) {
65110 return $this->mGlobalUser->attachedOn( $wiki );
66111 }
Index: trunk/extensions/CentralAuth/specials/SpecialCentralAuth.php
@@ -9,6 +9,8 @@
1010
1111 var $mAttachedLocalAccounts, $mUnattachedLocalAccounts;
1212
 13+ var $mMethod, $mPosted, $mWikis;
 14+
1315 function __construct() {
1416 parent::__construct( 'CentralAuth' );
1517 }
@@ -92,7 +94,9 @@
9395 }
9496 }
9597
96 - /** Returns true if the normal form should be displayed */
 98+ /**
 99+ * @return bool Returns true if the normal form should be displayed
 100+ */
97101 function doSubmit() {
98102 $deleted = false;
99103 $globalUser = $this->mGlobalUser;
@@ -210,6 +214,9 @@
211215 return !$deleted;
212216 }
213217
 218+ /**
 219+ * @param $wikitext string
 220+ */
214221 function showStatusError( $wikitext ) {
215222 global $wgOut;
216223 $wrap = Xml::tags( 'div', array( 'class' => 'error' ), $wikitext );
@@ -222,7 +229,6 @@
223230 $wgOut->wrapWikiMsg( '<div class="error">$1</div>', $args );
224231 }
225232
226 -
227233 function showSuccess( /* varargs */ ) {
228234 global $wgOut;
229235 $args = func_get_args();
@@ -253,6 +259,10 @@
254260 );
255261 }
256262
 263+ /**
 264+ * @param $span
 265+ * @return String
 266+ */
257267 function prettyTimespan( $span ) {
258268 global $wgLang;
259269 $units = array(
@@ -309,8 +319,9 @@
310320 $wgOut->addHTML( "<fieldset><legend>{$legend}</legend>" );
311321 $wgOut->addHTML( $this->listHeader() );
312322 $wgOut->addHTML( $this->listMerged( $merged ) );
313 - if ( $remainder )
 323+ if ( $remainder ) {
314324 $wgOut->addHTML( $this->listRemainder( $remainder ) );
 325+ }
315326 $wgOut->addHTML( $this->listFooter() );
316327 $wgOut->addHTML( '</fieldset>' );
317328 }
@@ -352,11 +363,19 @@
353364 return $footer;
354365 }
355366
 367+ /**
 368+ * @param $list
 369+ * @return string
 370+ */
356371 function listMerged( $list ) {
357372 ksort( $list );
358373 return implode( "\n", array_map( array( $this, 'listMergedWikiItem' ), $list ) );
359374 }
360375
 376+ /**
 377+ * @param $list
 378+ * @return string
 379+ */
361380 function listRemainder( $list ) {
362381 ksort( $list );
363382 $notMerged = wfMsgExt( 'centralauth-admin-unattached', array( 'parseinline' ) );
@@ -367,9 +386,13 @@
368387 $this->foreignUserLink( $row['wiki'] ) .
369388 "</td><td colspan='4'>{$notMerged}</td></tr>\n";
370389 }
371 - return implode( $rows );
 390+ return implode( '\n', $rows );
372391 }
373392
 393+ /**
 394+ * @param $row
 395+ * @return string
 396+ */
374397 function listMergedWikiItem( $row ) {
375398 global $wgLang;
376399 if ( $row === null ) {
@@ -393,6 +416,10 @@
394417 '</tr>';
395418 }
396419
 420+ /**
 421+ * @param $method
 422+ * @return string
 423+ */
397424 function formatMergeMethod( $method ) {
398425 global $wgExtensionAssetsPath;
399426
@@ -402,6 +429,10 @@
403430 "<span class=\"merge-method-help\" title=\"{$brief}\" onclick=\"showMethodHint('{$method}')\">(?)</span>";
404431 }
405432
 433+ /**
 434+ * @param $row
 435+ * @return String
 436+ */
406437 function formatBlockStatus( $row ) {
407438 if ( $row['blocked'] ) {
408439 if ( $row['block-expiry'] == 'infinity' ) {
@@ -428,6 +459,11 @@
429460 'page=User:' . urlencode( $this->mUserName ) );
430461 }
431462
 463+ /**
 464+ * @param $row
 465+ * @return string
 466+ * @throws MWException
 467+ */
432468 function formatEditcount( $row ) {
433469 $wiki = WikiMap::getWiki( $row['wiki'] );
434470 if ( !$wiki ) {
@@ -444,6 +480,10 @@
445481 );
446482 }
447483
 484+ /**
 485+ * @param $level
 486+ * @return String
 487+ */
448488 function formatHiddenLevel( $level ) {
449489 switch( $level ) {
450490 case CentralAuthUser::HIDDEN_NONE:
@@ -455,12 +495,26 @@
456496 }
457497 }
458498
 499+ /**
 500+ * @param $element
 501+ * @param $cols
 502+ * @return string
 503+ */
459504 function tableRow( $element, $cols ) {
460505 return "<tr><$element>" .
461506 implode( "</$element><$element>", $cols ) .
462507 "</$element></tr>";
463508 }
464509
 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+ */
465519 function foreignLink( $wikiID, $title, $text, $hint = '', $params = '' ) {
466520 if ( $wikiID instanceof WikiReference ) {
467521 $wiki = $wikiID;
@@ -483,6 +537,11 @@
484538 $text );
485539 }
486540
 541+ /**
 542+ * @param $wikiID
 543+ * @return string
 544+ * @throws MWException
 545+ */
487546 function foreignUserLink( $wikiID ) {
488547 $wiki = WikiMap::getWiki( $wikiID );
489548 if ( !$wiki ) {
@@ -497,9 +556,12 @@
498557 wfMsg( 'centralauth-foreign-link', $this->mUserName, $wikiname ) );
499558 }
500559
 560+ /**
 561+ * @param $wikiID
 562+ * @return string
 563+ */
501564 function adminCheck( $wikiID ) {
502 - return
503 - Xml::check( 'wpWikis[]', false, array( 'value' => $wikiID ) );
 565+ return Xml::check( 'wpWikis[]', false, array( 'value' => $wikiID ) );
504566 }
505567
506568 function showActionForm( $action ) {
@@ -601,6 +663,9 @@
602664 $wgOut->addHTML( $form );
603665 }
604666
 667+ /**
 668+ *
 669+ */
605670 function showLogExtract() {
606671 global $wgOut;
607672 $user = $this->mGlobalUser->getName();
@@ -616,6 +681,9 @@
617682 }
618683 }
619684
 685+ /**
 686+ * @return int|string
 687+ */
620688 function determineHomeWiki() {
621689 foreach ( $this->mAttachedLocalAccounts as $wiki => $acc ) {
622690 if ( $acc['attachedMethod'] == 'primary' || $acc['attachedMethod'] == 'new' ) {
@@ -627,6 +695,9 @@
628696 return wfMsgHtml( 'centralauth-admin-nohome' );
629697 }
630698
 699+ /**
 700+ * @return int
 701+ */
631702 function evaluateTotalEditcount() {
632703 $total = 0;
633704 foreach ( $this->mAttachedLocalAccounts as $acc ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r112628(Bug 34776) Unattached accounts add literal \n on Special:CentralAuth...platonides19:14, 28 February 2012

Status & tagging log