From: Alexandre Emsenhuber Date: Sat, 16 Jul 2011 19:31:18 +0000 (+0000) Subject: * Use standard method to check user permissions X-Git-Tag: 1.31.0-rc.0~28795 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=1e253f81c6fd03787816946351b1ed3f858b73a5;p=lhc%2Fweb%2Fwiklou.git * Use standard method to check user permissions * Directly throw an ReadOnlyError instead of calling OutputPage::readOnlyPage() * In Special:Block: don't let user think the error is temporary if he doesn't have right and the database is locked, instead check permissions first and then the database lock --- diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index f95d61af32..a98b1b6a73 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -59,17 +59,17 @@ class SpecialBlock extends SpecialPage { public function execute( $par ) { global $wgUser, $wgOut, $wgRequest; - # Can't block when the database is locked - if( wfReadOnly() ) { - $wgOut->readOnlyPage(); - return; - } # Permission check if( !$this->userCanExecute( $wgUser ) ) { - $wgOut->permissionRequired( 'block' ); + $this->displayRestrictionError(); return; } + # Can't block when the database is locked + if( wfReadOnly() ) { + throw new ReadOnlyError; + } + # Extract variables from the request. Try not to get into a situation where we # need to extract *every* variable from the form just for processing here, but # there are legitimate uses for some variables diff --git a/includes/specials/SpecialLockdb.php b/includes/specials/SpecialLockdb.php index 897a9b6e7a..4c70df23f4 100644 --- a/includes/specials/SpecialLockdb.php +++ b/includes/specials/SpecialLockdb.php @@ -38,8 +38,9 @@ class SpecialLockdb extends SpecialPage { $this->setHeaders(); - if( !$wgUser->isAllowed( 'siteadmin' ) ) { - $wgOut->permissionRequired( 'siteadmin' ); + # Permission check + if( !$this->userCanExecute( $wgUser ) ) { + $this->displayRestrictionError(); return; } diff --git a/includes/specials/SpecialUnblock.php b/includes/specials/SpecialUnblock.php index 8974c5d18d..0d93958393 100644 --- a/includes/specials/SpecialUnblock.php +++ b/includes/specials/SpecialUnblock.php @@ -38,13 +38,14 @@ class SpecialUnblock extends SpecialPage { global $wgUser, $wgOut, $wgRequest; # Check permissions - if( !$wgUser->isAllowed( 'block' ) ) { - $wgOut->permissionRequired( 'block' ); + if( !$this->userCanExecute( $wgUser ) ) { + $this->displayRestrictionError(); return; } + # Check for database lock if( wfReadOnly() ) { - $wgOut->readOnlyPage(); + throw new ReadOnlyError; return; } diff --git a/includes/specials/SpecialUnlockdb.php b/includes/specials/SpecialUnlockdb.php index 5fbf38aa2d..95ad0bf550 100644 --- a/includes/specials/SpecialUnlockdb.php +++ b/includes/specials/SpecialUnlockdb.php @@ -33,12 +33,13 @@ class SpecialUnlockdb extends SpecialPage { } public function execute( $par ) { - global $wgUser, $wgOut, $wgRequest; + global $wgUser, $wgRequest; $this->setHeaders(); - if( !$wgUser->isAllowed( 'siteadmin' ) ) { - $wgOut->permissionRequired( 'siteadmin' ); + # Permission check + if( !$this->userCanExecute( $wgUser ) ) { + $this->displayRestrictionError(); return; }