http://www.mediawiki.org/wiki/Special:Code/MediaWiki/61852
Revision: 61852 Author: raymond Date: 2010-02-02 12:56:19 +0000 (Tue, 02 Feb 2010) Log Message: ----------- * 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 trunk/extensions/GlobalBlocking/GlobalBlocking.i18n.php trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php Modified: trunk/extensions/GlobalBlocking/GlobalBlocking.class.php =================================================================== --- trunk/extensions/GlobalBlocking/GlobalBlocking.class.php 2010-02-02 10:26:29 UTC (rev 61851) +++ trunk/extensions/GlobalBlocking/GlobalBlocking.class.php 2010-02-02 12:56:19 UTC (rev 61852) @@ -349,6 +349,10 @@ $title = SpecialPage::getTitleFor( 'GlobalBlockStatus' ); $links[] = $sk->linkKnown( $title, wfMsg( 'globalblocking-goto-status' ) ); } + if( $pagetype == 'GlobalBlock' && $wgUser->isAllowed( 'editinterface' ) ) { + $title = Title::makeTitle( NS_MEDIAWIKI, 'Globalblocking-block-reason-dropdown' ); + $links[] = $sk->linkKnown( $title, wfMsg( 'globalblocking-block-edit-dropdown' ), array(), array( 'action' => 'edit' ) ); + } $linkItems = count( $links ) ? wfMsg( 'parentheses', $wgLang->pipeList( $links ) ) : ''; return $linkItems; } Modified: trunk/extensions/GlobalBlocking/GlobalBlocking.i18n.php =================================================================== --- trunk/extensions/GlobalBlocking/GlobalBlocking.i18n.php 2010-02-02 10:26:29 UTC (rev 61851) +++ trunk/extensions/GlobalBlocking/GlobalBlocking.i18n.php 2010-02-02 12:56:19 UTC (rev 61852) @@ -16,8 +16,15 @@ 'globalblocking-expiry-options' => '-', # do not translate or duplicate this message to other languages 'globalblocking-modify-intro' => 'You can use this form to change the settings of a global block.', 'globalblocking-block-intro' => 'You can use this page to block an IP address on all wikis.', - 'globalblocking-block-reason' => 'Reason for this block:', - 'globalblocking-block-expiry' => 'Block expiry:', + 'globalblocking-block-reason' => 'Reason:', + 'globalblocking-block-otherreason' => 'Other/additional reason:', + 'globalblocking-block-reasonotherlist' => 'Other reason', + 'globalblocking-block-reason-dropdown' => '* Common block reasons +** Crosswiki spamming +** Crosswiki abuse +** Vandalism', + 'globalblocking-block-edit-dropdown' => 'Edit block reasons', + 'globalblocking-block-expiry' => 'Expiry:', 'globalblocking-block-expiry-other' => 'Other expiry time', 'globalblocking-block-expiry-otherfield' => 'Other time:', 'globalblocking-block-legend' => 'Block an IP address globally', Modified: trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php =================================================================== --- trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php 2010-02-02 10:26:29 UTC (rev 61851) +++ trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php 2010-02-02 12:56:19 UTC (rev 61852) @@ -104,6 +104,7 @@ $this->mAddress = $par; $this->mReason = $wgRequest->getText( 'wpReason' ); + $this->mReasonList = $wgRequest->getText( 'wpBlockReasonList' ); $this->mExpiry = $this->mExpirySelection = $wgRequest->getText( 'wpExpiry' ); if ($this->mExpiry == 'other') { $this->mExpiry = $wgRequest->getText( 'wpExpiryOther' ); @@ -123,7 +124,15 @@ if ($this->mModify) $options[] = 'modify'; - $errors = GlobalBlocking::block( $this->mAddress, $this->mReason, $this->mExpiry, $options ); + $reasonstr = $this->mReasonList; + if( $reasonstr != 'other' && $this->mReason != '' ) { + // Entry from drop down menu + additional comment + $reasonstr .= wfMsgForContent( 'colon-separator' ) . $this->mReason; + } elseif( $reasonstr == 'other' ) { + $reasonstr = $this->mReason; + } + + $errors = GlobalBlocking::block( $this->mAddress, $reasonstr, $this->mExpiry, $options ); if ( count($errors) ) { return $errors; @@ -181,12 +190,15 @@ ); // How long to block them for - if ( ( $dropdown = wfMsgNoTrans( 'globalblocking-expiry-options' ) ) != '-') { - # Drop-down list - } elseif ( ( $dropdown = wfMsgNoTrans( 'ipboptions' ) ) != '-' ) { - # Also a drop-down list - } else { - $dropdown = false; + $dropdown = wfMsgForContentNoTrans( 'globalblocking-expiry-options' ); + if ( $dropdown === '' || $dropdown == '-' ) { + // 'globalblocking-expiry-options' is empty, try the message from core + $dropdown = wfMsgForContentNoTrans( 'ipboptions' ); + if ( wfEmptyMsg( 'ipboptions', $dropdown ) || $dropdown === '' || $dropdown == '-' ) { + // 'ipboptions' is empty too. Do not show a dropdown + // Do not assume that 'ipboptions' exists forever, therefore check with wfEmptyMsg too + $dropdown = false; + } } if ($dropdown == false ) { @@ -216,6 +228,15 @@ // Why to block them $fields['globalblocking-block-reason'] = + Xml::listDropDown( + 'wpBlockReasonList', + wfMsgForContent( 'globalblocking-block-reason-dropdown' ), + wfMsgForContent( 'globalblocking-block-reasonotherlist' ), + $this->mReasonList, + 'mw-globalblock-reasonlist' + ); + + $fields['globalblocking-block-otherreason'] = Xml::input( 'wpReason', 45, _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs