Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -979,6 +979,15 @@ |
980 | 980 | $notice = wfMsgExt( 'cascadeprotected', array('parsemag'), count($cascadeSources) ) . "\n$titles"; |
981 | 981 | |
982 | 982 | $this->addWikiText( $notice ); |
| 983 | + } else if ( $wgTitle->isNamespaceProtected() ) { |
| 984 | + global $wgNamespaceProtection; |
| 985 | + |
| 986 | + $ns = ($wgTitle->getNamespace() == NS_MAIN) |
| 987 | + ?wfMsg('nstab-main') |
| 988 | + :$wgTitle->getNsText(); |
| 989 | + |
| 990 | + $this->addWikiText( wfMsg( 'namespaceprotectedtext', $ns, |
| 991 | + implode( ',', $wgNamespaceProtection[$wgTitle->getNamespace()] ) ) ); |
983 | 992 | } else { |
984 | 993 | $this->addWikiText( wfMsg( 'protectedpagetext' ) ); |
985 | 994 | } |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -995,6 +995,31 @@ |
996 | 996 | return $this->userCan( $action, false ); |
997 | 997 | } |
998 | 998 | |
| 999 | + /** |
| 1000 | + * Determines if $wgUser is unable to edit this page because it has been protected |
| 1001 | + * by $wgNamespaceProtection. |
| 1002 | + * |
| 1003 | + * @return boolean |
| 1004 | + */ |
| 1005 | + public function isNamespaceProtected( ) { |
| 1006 | + global $wgNamespaceProtection, $wgUser; |
| 1007 | + |
| 1008 | + $fname = 'Title::isNamespaceProtected'; |
| 1009 | + |
| 1010 | + if ( array_key_exists( $this->mNamespace, $wgNamespaceProtection ) ) { |
| 1011 | + $nsProt = $wgNamespaceProtection[ $this->mNamespace ]; |
| 1012 | + if ( !is_array($nsProt) ) $nsProt = array($nsProt); |
| 1013 | + foreach( $nsProt as $right ) { |
| 1014 | + if( '' != $right && !$wgUser->isAllowed( $right ) ) { |
| 1015 | + wfProfileOut( $fname ); |
| 1016 | + return true; |
| 1017 | + } |
| 1018 | + } |
| 1019 | + } |
| 1020 | + |
| 1021 | + return false; |
| 1022 | + } |
| 1023 | + |
999 | 1024 | /** |
1000 | 1025 | * Can $wgUser perform $action on this page? |
1001 | 1026 | * @param string $action action that permission needs to be checked for |
— | — | @@ -1005,7 +1030,7 @@ |
1006 | 1031 | $fname = 'Title::userCan'; |
1007 | 1032 | wfProfileIn( $fname ); |
1008 | 1033 | |
1009 | | - global $wgUser, $wgNamespaceProtection; |
| 1034 | + global $wgUser; |
1010 | 1035 | |
1011 | 1036 | $result = null; |
1012 | 1037 | wfRunHooks( 'userCan', array( &$this, &$wgUser, $action, &$result ) ); |
— | — | @@ -1019,15 +1044,8 @@ |
1020 | 1045 | return false; |
1021 | 1046 | } |
1022 | 1047 | |
1023 | | - if ( array_key_exists( $this->mNamespace, $wgNamespaceProtection ) ) { |
1024 | | - $nsProt = $wgNamespaceProtection[ $this->mNamespace ]; |
1025 | | - if ( !is_array($nsProt) ) $nsProt = array($nsProt); |
1026 | | - foreach( $nsProt as $right ) { |
1027 | | - if( '' != $right && !$wgUser->isAllowed( $right ) ) { |
1028 | | - wfProfileOut( $fname ); |
1029 | | - return false; |
1030 | | - } |
1031 | | - } |
| 1048 | + if ( $this->isNamespaceProtected() ) { |
| 1049 | + return false; |
1032 | 1050 | } |
1033 | 1051 | |
1034 | 1052 | if( $this->mDbkeyform == '_' ) { |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -785,6 +785,7 @@ |
786 | 786 | '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.", |
787 | 787 | 'sqlhidden' => '(SQL query hidden)', |
788 | 788 | '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:', |
| 789 | +'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.', |
789 | 790 | |
790 | 791 | # Login and logout pages |
791 | 792 | 'logouttitle' => 'User logout', |
— | — | @@ -2913,4 +2914,4 @@ |
2914 | 2915 | 'watchlistedit-raw-added' => '{{PLURAL:$1|1 title was|$1 titles were}} added:', |
2915 | 2916 | 'watchlistedit-raw-removed' => '{{PLURAL:$1|1 title was|$1 titles were}} removed:', |
2916 | 2917 | |
2917 | | -); |
\ No newline at end of file |
| 2918 | +); |