$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' ) );
}
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
$fname = 'Title::userCan';
wfProfileIn( $fname );
- global $wgUser, $wgNamespaceProtection;
+ global $wgUser;
$result = null;
wfRunHooks( 'userCan', array( &$this, &$wgUser, $action, &$result ) );
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 == '_' ) {
'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',
'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
+);