r41536 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41535‎ | r41536 | r41537 >
Date:09:34, 2 October 2008
Author:mattj
Status:old
Tags:
Comment:
(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.
Modified paths:
  • /trunk/phase3/includes/api/ApiBlock.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialBlockip.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiBlock.php
@@ -49,7 +49,7 @@
5050 * of success. If it fails, the result will specify the nature of the error.
5151 */
5252 public function execute() {
53 - global $wgUser;
 53+ global $wgUser, $wgBlockAllowsUTEdit;
5454 $this->getMain()->requestWriteMode();
5555 $params = $this->extractRequestParams();
5656
@@ -84,6 +84,7 @@
8585 $form->BlockEnableAutoblock = $params['autoblock'];
8686 $form->BlockEmail = $params['noemail'];
8787 $form->BlockHideName = $params['hidename'];
 88+ $form->BlockAllowUsertalk = $params['allowusertalk'] && $wgBlockAllowsUTEdit;
8889
8990 $userID = $expiry = null;
9091 $retval = $form->doBlock($userID, $expiry);
@@ -105,6 +106,8 @@
106107 $res['noemail'] = '';
107108 if($params['hidename'])
108109 $res['hidename'] = '';
 110+ if($params['allowusertalk'])
 111+ $res['allowusertalk'] = '';
109112
110113 $this->getResult()->addValue(null, $this->getModuleName(), $res);
111114 }
@@ -112,6 +115,7 @@
113116 public function mustBePosted() { return true; }
114117
115118 public function getAllowedParams() {
 119+ global $wgBlockAllowsUTEdit;
116120 return array (
117121 'user' => null,
118122 'token' => null,
@@ -123,6 +127,7 @@
124128 'autoblock' => false,
125129 'noemail' => false,
126130 'hidename' => false,
 131+ 'allowusertalk' => $wgBlockAllowsUTEdit,
127132 );
128133 }
129134
@@ -137,7 +142,8 @@
138143 'nocreate' => 'Prevent account creation',
139144 'autoblock' => 'Automatically block the last used IP address, and any subsequent IP addresses they try to login from',
140145 'noemail' => 'Prevent user from sending e-mail through the wiki. (Requires the "blockemail" right.)',
141 - 'hidename' => 'Hide the username from the block log. (Requires the "hideuser" right.)'
 146+ 'hidename' => 'Hide the username from the block log. (Requires the "hideuser" right.)',
 147+ 'allowusertalk' => 'Whether to allow the user to edit their own talk page (Dependent on $wgBlockAllowsUTEdit)'
142148 );
143149 }
144150
Index: trunk/phase3/includes/specials/SpecialBlockip.php
@@ -287,7 +287,7 @@
288288 * @return array(message key, arguments) on failure, empty array on success
289289 */
290290 function doBlock( &$userId = null, &$expiry = null ) {
291 - global $wgUser, $wgSysopUserBans, $wgSysopRangeBans;
 291+ global $wgUser, $wgSysopUserBans, $wgSysopRangeBans, $wgBlockAllowsUTEdit;
292292
293293 $userId = 0;
294294 # Expand valid IPv6 addresses, usernames are left as is
@@ -374,7 +374,7 @@
375375 $block = new Block( $this->BlockAddress, $userId, $wgUser->getId(),
376376 $reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly,
377377 $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName,
378 - $this->BlockEmail, $this->BlockAllowUsertalk );
 378+ $this->BlockEmail, isset( $this->BlockAllowUsertalk ) ? $this->BlockAllowUsertalk : $wgBlockAllowsUTEdit );
379379
380380 if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) {
381381

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41248(bug 8440) Allow preventing blocked users from editing their talk pages...mattj11:45, 25 September 2008
r41403Fix r41248 (bug 8440) - Default should be 1 to allow for previous behaviour t...mattj23:16, 29 September 2008
r41533(bug 8440) Fix ipblocklist to show new allow usertalk flag.mattj08:41, 2 October 2008

Status & tagging log