X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fuser%2FUser.php;h=9cd3ea1611d8d84ee2e65751d5347978c14e3cc3;hb=cb4d4c4d8f4884bfe18b1e69c0d1bc2d8d567d5c;hp=24de04a6e295890b93a4abd2724030eab61ff856;hpb=390fce6db1e008c53580cedbdfe18dff3de9c766;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/user/User.php b/includes/user/User.php index 24de04a6e2..9cd3ea1611 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -1817,11 +1817,7 @@ class User implements IDBAccessObject, UserIdentity { */ public static function getDefaultOption( $opt ) { $defOpts = self::getDefaultOptions(); - if ( isset( $defOpts[$opt] ) ) { - return $defOpts[$opt]; - } else { - return null; - } + return $defOpts[$opt] ?? null; } /** @@ -2297,21 +2293,22 @@ class User implements IDBAccessObject, UserIdentity { * Check if user is blocked from editing a particular article * * @param Title $title Title to check - * @param bool $bFromSlave Whether to check the replica DB instead of the master + * @param bool $fromSlave Whether to check the replica DB instead of the master * @return bool */ - public function isBlockedFrom( $title, $bFromSlave = false ) { - global $wgBlockAllowsUTEdit; + public function isBlockedFrom( $title, $fromSlave = false ) { + $blocked = $this->isHidden(); - $blocked = $this->isBlocked( $bFromSlave ); - $allowUsertalk = ( $wgBlockAllowsUTEdit ? $this->mAllowUsertalk : false ); - // If a user's name is suppressed, they cannot make edits anywhere - if ( !$this->mHideName && $allowUsertalk && $title->getText() === $this->getName() - && $title->getNamespace() == NS_USER_TALK ) { - $blocked = false; - wfDebug( __METHOD__ . ": self-talk page, ignoring any blocks\n" ); + if ( !$blocked ) { + $block = $this->getBlock( $fromSlave ); + if ( $block ) { + $blocked = $block->preventsEdit( $title ); + } } + // only for the purpose of the hook. We really don't need this here. + $allowUsertalk = $this->mAllowUsertalk; + Hooks::run( 'UserIsBlockedFrom', [ $this, $title, &$blocked, &$allowUsertalk ] ); return $blocked; @@ -2418,7 +2415,7 @@ class User implements IDBAccessObject, UserIdentity { */ public function isHidden() { if ( $this->mHideName !== null ) { - return $this->mHideName; + return (bool)$this->mHideName; } $this->getBlockedStatus(); if ( !$this->mHideName ) { @@ -2428,7 +2425,7 @@ class User implements IDBAccessObject, UserIdentity { $this->mHideName = $authUser && $authUser->isHidden(); Hooks::run( 'UserIsHidden', [ $this, &$this->mHideName ] ); } - return $this->mHideName; + return (bool)$this->mHideName; } /** @@ -4518,6 +4515,16 @@ class User implements IDBAccessObject, UserIdentity { return $this->mBlock && $this->mBlock->prevents( 'sendemail' ); } + /** + * Get whether the user is blocked from using Special:Upload + * + * @return bool + */ + public function isBlockedFromUpload() { + $this->getBlockedStatus(); + return $this->mBlock && $this->mBlock->prevents( 'upload' ); + } + /** * Get whether the user is allowed to create an account. * @return bool