X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Factions%2FCreditsAction.php;h=e064aab4e6e260da3a15ff5050494df887c3bb3d;hb=d98adbae4928590c78ba872efb33b08b906d105d;hp=2bb1be44c5a71ef85f2a9a684f1cf42f2b53cfd2;hpb=63ba8bca85ccb953fccfc5cb54c68df83793654d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/CreditsAction.php b/includes/actions/CreditsAction.php index 2bb1be44c5..e064aab4e6 100644 --- a/includes/actions/CreditsAction.php +++ b/includes/actions/CreditsAction.php @@ -60,7 +60,7 @@ class CreditsAction extends FormlessAction { * * @param int $cnt Maximum list of contributors to show * @param bool $showIfMax Whether to contributors if there more than $cnt - * @return string html + * @return string Html */ public function getCredits( $cnt, $showIfMax = true ) { wfProfileIn( __METHOD__ ); @@ -100,15 +100,24 @@ class CreditsAction extends FormlessAction { $this->userLink( $user ) )->params( $user->getName() )->escaped(); } + /** + * Whether we can display the user's real name (not a hidden pref) + * + * @since 1.24 + * @return bool + */ + protected function canShowRealUserName() { + $hiddenPrefs = $this->context->getConfig()->get( 'HiddenPrefs' ); + return !in_array( 'realname', $hiddenPrefs ); + } + /** * Get a list of contributors of $article * @param int $cnt Maximum list of contributors to show * @param bool $showIfMax Whether to contributors if there more than $cnt - * @return string html + * @return string Html */ protected function getContributors( $cnt, $showIfMax ) { - global $wgHiddenPrefs; - $contributors = $this->page->getContributors(); $others_link = false; @@ -132,7 +141,7 @@ class CreditsAction extends FormlessAction { $cnt--; if ( $user->isLoggedIn() ) { $link = $this->link( $user ); - if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) { + if ( $this->canShowRealUserName() && $user->getRealName() ) { $real_names[] = $link; } else { $user_names[] = $link; @@ -192,8 +201,7 @@ class CreditsAction extends FormlessAction { * @return string Html */ protected function link( User $user ) { - global $wgHiddenPrefs; - if ( !in_array( 'realname', $wgHiddenPrefs ) && !$user->isAnon() ) { + if ( $this->canShowRealUserName() && !$user->isAnon() ) { $real = $user->getRealName(); } else { $real = false; @@ -216,8 +224,7 @@ class CreditsAction extends FormlessAction { if ( $user->isAnon() ) { return $this->msg( 'anonuser' )->rawParams( $link )->parse(); } else { - global $wgHiddenPrefs; - if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) { + if ( $this->canShowRealUserName() && $user->getRealName() ) { return $link; } else { return $this->msg( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped();