X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FAction.php;h=951c74a3b5559ade1209b04446fe9bb2f7236cd7;hb=1ee019e728d5b7add2fc8352e6a8dce22d68161b;hp=9958be9d04228b9335e319509061bf9c443f0f90;hpb=9e230f3076219d08ff422149d9b9bfe70989d1b2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Action.php b/includes/Action.php index 9958be9d04..951c74a3b5 100644 --- a/includes/Action.php +++ b/includes/Action.php @@ -147,8 +147,18 @@ abstract class Action { * * @return Skin */ + public final function getLanguage() { + return $this->getContext()->getLanguage(); + } + + /** + * Shortcut to get the user Language being used for this instance + * + * @deprecated 1.19 Use getLanguage instead + * @return Skin + */ public final function getLang() { - return $this->getContext()->getLang(); + return $this->getLanguage(); } /** @@ -200,18 +210,25 @@ abstract class Action { * @throws ErrorPageError */ protected function checkCanExecute( User $user ) { - if ( $this->requiresWrite() && wfReadOnly() ) { - throw new ReadOnlyError(); - } - - if ( $this->getRestriction() !== null && !$user->isAllowed( $this->getRestriction() ) ) { - throw new PermissionsError( $this->getRestriction() ); + $right = $this->getRestriction(); + if ( $right !== null ) { + $errors = $this->getTitle()->getUserPermissionsErrors( $right, $user ); + if ( count( $errors ) ) { + throw new PermissionsError( $right, $errors ); + } } if ( $this->requiresUnblock() && $user->isBlocked() ) { $block = $user->mBlock; throw new UserBlockedError( $block ); } + + // This should be checked at the end so that the user won't think the + // error is only temporary when he also don't have the rights to execute + // this action + if ( $this->requiresWrite() && wfReadOnly() ) { + throw new ReadOnlyError(); + } } /** @@ -290,6 +307,10 @@ abstract class FormAction extends Action { * @return String HTML which will be sent to $form->addPreText() */ protected function preText() { return ''; } + + /** + * @return string + */ protected function postText() { return ''; } /**