X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FBlock.php;h=79b31bbf5812676a8d4fdb612bd99ffb7f1e2a41;hb=b675be2083;hp=696a520ed89abe9fb6c7f35b3d3289223761ce50;hpb=58cb1f824ac75c3b58ba19d1e88c1b38f9dc1fab;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Block.php b/includes/Block.php index 696a520ed8..79b31bbf58 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -137,7 +137,7 @@ class Block { if ( $options['by'] ) { # Local user - $this->setBlocker( User::newFromID( $options['by'] ) ); + $this->setBlocker( User::newFromId( $options['by'] ) ); } else { # Foreign user $this->setBlocker( $options['byText'] ); @@ -457,6 +457,7 @@ class Block { * ('id' => block ID, 'autoIds' => array of autoblock IDs) */ public function insert( $dbw = null ) { + global $wgBlockDisablesLogin; wfDebug( "Block::insert; timestamp {$this->mTimestamp}\n" ); if ( $dbw === null ) { @@ -499,6 +500,13 @@ class Block { if ( $affected ) { $auto_ipd_ids = $this->doRetroactiveAutoblock(); + + if ( $wgBlockDisablesLogin && $this->target instanceof User ) { + // Change user login token to force them to be logged out. + $this->target->setToken(); + $this->target->saveSettings(); + } + return [ 'id' => $this->mId, 'autoIds' => $auto_ipd_ids ]; } @@ -568,7 +576,7 @@ class Block { if ( $this->forcedTargetID ) { $uid = $this->forcedTargetID; } else { - $uid = $this->target instanceof User ? $this->target->getID() : 0; + $uid = $this->target instanceof User ? $this->target->getId() : 0; } $a = [ @@ -844,7 +852,7 @@ class Block { 'ipb_expiry' => $dbw->timestamp( $this->mExpiry ), ], [ /* WHERE */ - 'ipb_address' => (string)$this->getTarget() + 'ipb_id' => $this->getId(), ], __METHOD__ ); @@ -961,28 +969,40 @@ class Block { /** * Get/set whether the Block prevents a given action - * @param string $action - * @param bool|null $x - * @return bool + * + * @param string $action Action to check + * @param bool|null $x Value for set, or null to just get value + * @return bool|null Null for unrecognized rights. */ public function prevents( $action, $x = null ) { + global $wgBlockDisablesLogin; + $res = null; switch ( $action ) { case 'edit': # For now... - return true; - + $res = true; + break; case 'createaccount': - return wfSetVar( $this->mCreateAccount, $x ); - + $res = wfSetVar( $this->mCreateAccount, $x ); + break; case 'sendemail': - return wfSetVar( $this->mBlockEmail, $x ); - + $res = wfSetVar( $this->mBlockEmail, $x ); + break; case 'editownusertalk': - return wfSetVar( $this->mDisableUsertalk, $x ); - - default: - return null; + $res = wfSetVar( $this->mDisableUsertalk, $x ); + break; + case 'read': + $res = false; + break; } + if ( !$res && $wgBlockDisablesLogin ) { + // If a block would disable login, then it should + // prevent any action that all users cannot do + $anon = new User; + $res = $anon->isAllowed( $action ) ? $res : true; + } + + return $res; } /** @@ -1307,8 +1327,7 @@ class Block { # but actually an old subpage (bug #29797) if ( strpos( $target, '/' ) !== false ) { # An old subpage, drill down to the user behind it - $parts = explode( '/', $target ); - $target = $parts[0]; + $target = explode( '/', $target )[0]; } $userObj = User::newFromName( $target );