If the user is unable to edit a page because the namespace is protected, rather than...
authorDaniel Cannon <amidaniel@users.mediawiki.org>
Sat, 7 Jul 2007 04:18:44 +0000 (04:18 +0000)
committerDaniel Cannon <amidaniel@users.mediawiki.org>
Sat, 7 Jul 2007 04:18:44 +0000 (04:18 +0000)
includes/OutputPage.php
includes/Title.php
languages/messages/MessagesEn.php

index 3ea6e33..0ca713b 100644 (file)
@@ -979,6 +979,15 @@ class OutputPage {
                                $notice = wfMsgExt( 'cascadeprotected', array('parsemag'), count($cascadeSources) ) . "\n$titles";
 
                                $this->addWikiText( $notice );
+                       } else if ( $wgTitle->isNamespaceProtected() ) {
+                               global $wgNamespaceProtection;
+
+                               $ns = ($wgTitle->getNamespace() == NS_MAIN)
+                                               ?wfMsg('nstab-main')
+                                               :$wgTitle->getNsText();
+
+                               $this->addWikiText( wfMsg( 'namespaceprotectedtext', $ns,
+                                       implode( ',', $wgNamespaceProtection[$wgTitle->getNamespace()] ) ) );
                        } else {
                                $this->addWikiText( wfMsg( 'protectedpagetext' ) );
                        }
index d089d8a..37815eb 100644 (file)
@@ -995,6 +995,31 @@ class Title {
                return $this->userCan( $action, false );
        }
 
+       /**
+        * Determines if $wgUser is unable to edit this page because it has been protected
+        * by $wgNamespaceProtection.
+        * 
+        * @return boolean
+        */
+       public function isNamespaceProtected( ) {
+               global $wgNamespaceProtection, $wgUser;
+               
+               $fname = 'Title::isNamespaceProtected';
+               
+               if ( array_key_exists( $this->mNamespace, $wgNamespaceProtection ) ) {
+                       $nsProt = $wgNamespaceProtection[ $this->mNamespace ];
+                       if ( !is_array($nsProt) ) $nsProt = array($nsProt);
+                       foreach( $nsProt as $right ) {
+                               if( '' != $right && !$wgUser->isAllowed( $right ) ) {
+                                       wfProfileOut( $fname );
+                                       return true;
+                               }
+                       }
+               }
+
+               return false;
+       }
+       
        /**
         * Can $wgUser perform $action on this page?
         * @param string $action action that permission needs to be checked for
@@ -1005,7 +1030,7 @@ class Title {
                $fname = 'Title::userCan';
                wfProfileIn( $fname );
 
-               global $wgUser, $wgNamespaceProtection;
+               global $wgUser;
 
                $result = null;
                wfRunHooks( 'userCan', array( &$this, &$wgUser, $action, &$result ) );
@@ -1019,15 +1044,8 @@ class Title {
                        return false;
                }
                
-               if ( array_key_exists( $this->mNamespace, $wgNamespaceProtection ) ) {
-                       $nsProt = $wgNamespaceProtection[ $this->mNamespace ];
-                       if ( !is_array($nsProt) ) $nsProt = array($nsProt);
-                       foreach( $nsProt as $right ) {
-                               if( '' != $right && !$wgUser->isAllowed( $right ) ) {
-                                       wfProfileOut( $fname );
-                                       return false;
-                               }
-                       }
+               if ( $this->isNamespaceProtected() ) {
+                       return false;
                }
 
                if( $this->mDbkeyform == '_' ) {
index 89f70fa..18b4d5e 100644 (file)
@@ -785,6 +785,7 @@ Query: $2',
 'editinginterface'     => "'''Warning:''' You are editing a page which is used to provide interface text for the software. Changes to this page will affect the appearance of the user interface for other users.",
 'sqlhidden'            => '(SQL query hidden)',
 'cascadeprotected'     => 'This page has been protected from editing, because it is included in the following {{PLURAL:$1|page|pages}}, which are protected with the "cascading" option turned on:',
+'namespaceprotectedtext'=>'Because this page resides in the $1 namespace, editing of it has been restricted to users with the rights "$2". Please [[Special:Userlogin|log-in]] or contact an administrator to request permission to edit it.',
 
 # Login and logout pages
 'logouttitle'                => 'User logout',
@@ -2913,4 +2914,4 @@ $1',
 'watchlistedit-raw-added' => '{{PLURAL:$1|1 title was|$1 titles were}} added:',
 'watchlistedit-raw-removed' => '{{PLURAL:$1|1 title was|$1 titles were}} removed:',
 
-);
\ No newline at end of file
+);