X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FAction.php;h=951c74a3b5559ade1209b04446fe9bb2f7236cd7;hb=1ee019e728d5b7add2fc8352e6a8dce22d68161b;hp=d21cd6b8fb1f15a17fc50010140ef0a0282df780;hpb=2b3f7ae7b48781c15f6eab51e3faf8c6da2f8bff;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Action.php b/includes/Action.php index d21cd6b8fb..951c74a3b5 100644 --- a/includes/Action.php +++ b/includes/Action.php @@ -99,7 +99,7 @@ abstract class Action { * Get the IContextSource in use here * @return IContextSource */ - protected final function getContext() { + public final function getContext() { if ( $this->context instanceof IContextSource ) { return $this->context; } @@ -111,7 +111,7 @@ abstract class Action { * * @return WebRequest */ - protected final function getRequest() { + public final function getRequest() { return $this->getContext()->getRequest(); } @@ -120,7 +120,7 @@ abstract class Action { * * @return OutputPage */ - protected final function getOutput() { + public final function getOutput() { return $this->getContext()->getOutput(); } @@ -129,7 +129,7 @@ abstract class Action { * * @return User */ - protected final function getUser() { + public final function getUser() { return $this->getContext()->getUser(); } @@ -138,7 +138,7 @@ abstract class Action { * * @return Skin */ - protected final function getSkin() { + public final function getSkin() { return $this->getContext()->getSkin(); } @@ -147,15 +147,25 @@ abstract class Action { * * @return Skin */ - protected final function getLang() { - return $this->getContext()->getLang(); + 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->getLanguage(); } /** * Shortcut to get the Title object from the page * @return Title */ - protected final function getTitle() { + public final function getTitle() { return $this->page->getTitle(); } @@ -165,7 +175,7 @@ abstract class Action { * * @return Message object */ - protected final function msg() { + public final function msg() { $params = func_get_args(); return call_user_func_array( array( $this->getContext(), 'msg' ), $params ); } @@ -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 ''; } /**