From fdc01ccef22f7cc9c26d0a1251095124793cea69 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Thu, 2 Oct 2008 09:34:29 +0000 Subject: [PATCH] (bug 8440) Add API support for new blocking flag, also fix defaults so anywhere else we use an IPBlockForm it'll use a more sensible default. --- includes/api/ApiBlock.php | 10 ++++++++-- includes/specials/SpecialBlockip.php | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index d6ef542509..7dd658ff90 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -49,7 +49,7 @@ class ApiBlock extends ApiBase { * of success. If it fails, the result will specify the nature of the error. */ public function execute() { - global $wgUser; + global $wgUser, $wgBlockAllowsUTEdit; $this->getMain()->requestWriteMode(); $params = $this->extractRequestParams(); @@ -84,6 +84,7 @@ class ApiBlock extends ApiBase { $form->BlockEnableAutoblock = $params['autoblock']; $form->BlockEmail = $params['noemail']; $form->BlockHideName = $params['hidename']; + $form->BlockAllowUsertalk = $params['allowusertalk'] && $wgBlockAllowsUTEdit; $userID = $expiry = null; $retval = $form->doBlock($userID, $expiry); @@ -105,6 +106,8 @@ class ApiBlock extends ApiBase { $res['noemail'] = ''; if($params['hidename']) $res['hidename'] = ''; + if($params['allowusertalk']) + $res['allowusertalk'] = ''; $this->getResult()->addValue(null, $this->getModuleName(), $res); } @@ -112,6 +115,7 @@ class ApiBlock extends ApiBase { public function mustBePosted() { return true; } public function getAllowedParams() { + global $wgBlockAllowsUTEdit; return array ( 'user' => null, 'token' => null, @@ -123,6 +127,7 @@ class ApiBlock extends ApiBase { 'autoblock' => false, 'noemail' => false, 'hidename' => false, + 'allowusertalk' => $wgBlockAllowsUTEdit, ); } @@ -137,7 +142,8 @@ class ApiBlock extends ApiBase { 'nocreate' => 'Prevent account creation', 'autoblock' => 'Automatically block the last used IP address, and any subsequent IP addresses they try to login from', 'noemail' => 'Prevent user from sending e-mail through the wiki. (Requires the "blockemail" right.)', - 'hidename' => 'Hide the username from the block log. (Requires the "hideuser" right.)' + 'hidename' => 'Hide the username from the block log. (Requires the "hideuser" right.)', + 'allowusertalk' => 'Whether to allow the user to edit their own talk page (Dependent on $wgBlockAllowsUTEdit)' ); } diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index eb84e41bd5..34683a52b0 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -287,7 +287,7 @@ class IPBlockForm { * @return array(message key, arguments) on failure, empty array on success */ function doBlock( &$userId = null, &$expiry = null ) { - global $wgUser, $wgSysopUserBans, $wgSysopRangeBans; + global $wgUser, $wgSysopUserBans, $wgSysopRangeBans, $wgBlockAllowsUTEdit; $userId = 0; # Expand valid IPv6 addresses, usernames are left as is @@ -374,7 +374,7 @@ class IPBlockForm { $block = new Block( $this->BlockAddress, $userId, $wgUser->getId(), $reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly, $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName, - $this->BlockEmail, $this->BlockAllowUsertalk ); + $this->BlockEmail, isset( $this->BlockAllowUsertalk ) ? $this->BlockAllowUsertalk : $wgBlockAllowsUTEdit ); if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) { -- 2.20.1