Kill some more mysql 4 related things from the installer
[lhc/web/wiklou.git] / includes / Action.php
index 9958be9..951c74a 100644 (file)
@@ -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 ''; }
 
        /**