r50774 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50773‎ | r50774 | r50775 >
Date:16:08, 19 May 2009
Author:demon
Status:ok
Tags:
Comment:
Followup to 50635: Consolidate all of these hacky global checks into a clean method. Also move a global and document it.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialBlockip.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialBlockip.php
@@ -62,7 +62,7 @@
6363 $this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', $byDefault );
6464 $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', $byDefault );
6565 $this->BlockEmail = false;
66 - if( $wgEnableUserEmail && $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) {
 66+ if( self::canBlockEmail( $wgUser ) ) {
6767 $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false );
6868 }
6969 $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false );
@@ -233,8 +233,7 @@
234234 </tr>"
235235 );
236236
237 - global $wgSysopEmailBans, $wgBlockAllowsUTEdit, $wgEnableUserEmail;
238 - if( $wgEnableUserEmail && $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) {
 237+ if( self::canBlockEmail( $wgUser ) ) {
239238 $wgOut->addHTML("
240239 <tr id='wpEnableEmailBan'>
241240 <td>&nbsp;</td>
@@ -272,6 +271,9 @@
273272 </td>
274273 </tr>"
275274 );
 275+
 276+ # Can we explicitly disallow the use of user_talk?
 277+ global $wgBlockAllowsUTEdit;
276278 if( $wgBlockAllowsUTEdit ){
277279 $wgOut->addHTML("
278280 <tr id='wpAllowUsertalkRow'>
@@ -311,6 +313,16 @@
312314 $this->showLogFragment( $wgOut, Title::makeTitle( NS_USER, $this->BlockAddress ) );
313315 }
314316 }
 317+
 318+ /**
 319+ * Can we do an email block?
 320+ * @param User $user The sysop wanting to make a block
 321+ * @return boolean
 322+ */
 323+ protected function canBlockEmail( $user ) {
 324+ global $wgEnableUserEmail, $wgSysopEmailBans;
 325+ return ($wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ));
 326+ }
315327
316328 /**
317329 * Backend block code.

Status & tagging log