From: Chad Horohoe Date: Tue, 19 May 2009 16:08:53 +0000 (+0000) Subject: Followup to 50635: Consolidate all of these hacky global checks into a clean method... X-Git-Tag: 1.31.0-rc.0~41744 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=e3a4b98ceb25bcbdddf387e71960190bdea162fd;p=lhc%2Fweb%2Fwiklou.git Followup to 50635: Consolidate all of these hacky global checks into a clean method. Also move a global and document it. --- diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index 5c15fee2ed..00c2e18f9d 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -62,7 +62,7 @@ class IPBlockForm { $this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', $byDefault ); $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', $byDefault ); $this->BlockEmail = false; - if( $wgEnableUserEmail && $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) { + if( self::canBlockEmail( $wgUser ) ) { $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false ); } $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false ); @@ -233,8 +233,7 @@ class IPBlockForm { " ); - global $wgSysopEmailBans, $wgBlockAllowsUTEdit, $wgEnableUserEmail; - if( $wgEnableUserEmail && $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) { + if( self::canBlockEmail( $wgUser ) ) { $wgOut->addHTML("   @@ -272,6 +271,9 @@ class IPBlockForm { " ); + + # Can we explicitly disallow the use of user_talk? + global $wgBlockAllowsUTEdit; if( $wgBlockAllowsUTEdit ){ $wgOut->addHTML(" @@ -311,6 +313,16 @@ class IPBlockForm { $this->showLogFragment( $wgOut, Title::makeTitle( NS_USER, $this->BlockAddress ) ); } } + + /** + * Can we do an email block? + * @param User $user The sysop wanting to make a block + * @return boolean + */ + protected function canBlockEmail( $user ) { + global $wgEnableUserEmail, $wgSysopEmailBans; + return ($wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' )); + } /** * Backend block code.