r61852 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61851‎ | r61852 | r61853 >
Date:12:56, 2 February 2010
Author:raymond
Status:ok
Tags:
Comment:
* Bug 18413 Add a dropdown for pre-defined block reasons on GlobalBlocking form
* Reword 'globalblocking-block-reason' and 'globalblocking-block-expiry' to make them consistent with Special:block
* Rewrite declaration of $dropdown:
** Do not assign value in an if() clause
** Get the value from the content language
Modified paths:
  • /trunk/extensions/GlobalBlocking/GlobalBlocking.class.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/GlobalBlocking.i18n.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php
@@ -104,6 +104,7 @@
105105 $this->mAddress = $par;
106106
107107 $this->mReason = $wgRequest->getText( 'wpReason' );
 108+ $this->mReasonList = $wgRequest->getText( 'wpBlockReasonList' );
108109 $this->mExpiry = $this->mExpirySelection = $wgRequest->getText( 'wpExpiry' );
109110 if ($this->mExpiry == 'other') {
110111 $this->mExpiry = $wgRequest->getText( 'wpExpiryOther' );
@@ -123,7 +124,15 @@
124125 if ($this->mModify)
125126 $options[] = 'modify';
126127
127 - $errors = GlobalBlocking::block( $this->mAddress, $this->mReason, $this->mExpiry, $options );
 128+ $reasonstr = $this->mReasonList;
 129+ if( $reasonstr != 'other' && $this->mReason != '' ) {
 130+ // Entry from drop down menu + additional comment
 131+ $reasonstr .= wfMsgForContent( 'colon-separator' ) . $this->mReason;
 132+ } elseif( $reasonstr == 'other' ) {
 133+ $reasonstr = $this->mReason;
 134+ }
 135+
 136+ $errors = GlobalBlocking::block( $this->mAddress, $reasonstr, $this->mExpiry, $options );
128137
129138 if ( count($errors) ) {
130139 return $errors;
@@ -181,12 +190,15 @@
182191 );
183192
184193 // How long to block them for
185 - if ( ( $dropdown = wfMsgNoTrans( 'globalblocking-expiry-options' ) ) != '-') {
186 - # Drop-down list
187 - } elseif ( ( $dropdown = wfMsgNoTrans( 'ipboptions' ) ) != '-' ) {
188 - # Also a drop-down list
189 - } else {
190 - $dropdown = false;
 194+ $dropdown = wfMsgForContentNoTrans( 'globalblocking-expiry-options' );
 195+ if ( $dropdown === '' || $dropdown == '-' ) {
 196+ // 'globalblocking-expiry-options' is empty, try the message from core
 197+ $dropdown = wfMsgForContentNoTrans( 'ipboptions' );
 198+ if ( wfEmptyMsg( 'ipboptions', $dropdown ) || $dropdown === '' || $dropdown == '-' ) {
 199+ // 'ipboptions' is empty too. Do not show a dropdown
 200+ // Do not assume that 'ipboptions' exists forever, therefore check with wfEmptyMsg too
 201+ $dropdown = false;
 202+ }
191203 }
192204
193205 if ($dropdown == false ) {
@@ -216,6 +228,15 @@
217229
218230 // Why to block them
219231 $fields['globalblocking-block-reason'] =
 232+ Xml::listDropDown(
 233+ 'wpBlockReasonList',
 234+ wfMsgForContent( 'globalblocking-block-reason-dropdown' ),
 235+ wfMsgForContent( 'globalblocking-block-reasonotherlist' ),
 236+ $this->mReasonList,
 237+ 'mw-globalblock-reasonlist'
 238+ );
 239+
 240+ $fields['globalblocking-block-otherreason'] =
220241 Xml::input(
221242 'wpReason',
222243 45,
Index: trunk/extensions/GlobalBlocking/GlobalBlocking.class.php
@@ -349,6 +349,10 @@
350350 $title = SpecialPage::getTitleFor( 'GlobalBlockStatus' );
351351 $links[] = $sk->linkKnown( $title, wfMsg( 'globalblocking-goto-status' ) );
352352 }
 353+ if( $pagetype == 'GlobalBlock' && $wgUser->isAllowed( 'editinterface' ) ) {
 354+ $title = Title::makeTitle( NS_MEDIAWIKI, 'Globalblocking-block-reason-dropdown' );
 355+ $links[] = $sk->linkKnown( $title, wfMsg( 'globalblocking-block-edit-dropdown' ), array(), array( 'action' => 'edit' ) );
 356+ }
353357 $linkItems = count( $links ) ? wfMsg( 'parentheses', $wgLang->pipeList( $links ) ) : '';
354358 return $linkItems;
355359 }
Index: trunk/extensions/GlobalBlocking/GlobalBlocking.i18n.php
@@ -16,8 +16,15 @@
1717 'globalblocking-expiry-options' => '-', # do not translate or duplicate this message to other languages
1818 'globalblocking-modify-intro' => 'You can use this form to change the settings of a global block.',
1919 'globalblocking-block-intro' => 'You can use this page to block an IP address on all wikis.',
20 - 'globalblocking-block-reason' => 'Reason for this block:',
21 - 'globalblocking-block-expiry' => 'Block expiry:',
 20+ 'globalblocking-block-reason' => 'Reason:',
 21+ 'globalblocking-block-otherreason' => 'Other/additional reason:',
 22+ 'globalblocking-block-reasonotherlist' => 'Other reason',
 23+ 'globalblocking-block-reason-dropdown' => '* Common block reasons
 24+** Crosswiki spamming
 25+** Crosswiki abuse
 26+** Vandalism',
 27+ 'globalblocking-block-edit-dropdown' => 'Edit block reasons',
 28+ 'globalblocking-block-expiry' => 'Expiry:',
2229 'globalblocking-block-expiry-other' => 'Other expiry time',
2330 'globalblocking-block-expiry-otherfield' => 'Other time:',
2431 'globalblocking-block-legend' => 'Block an IP address globally',

Status & tagging log