Allow customizing the minimum per-namespace protection level via $wgNamespaceProtection.
authorIlmari Karonen <vyznev@users.mediawiki.org>
Thu, 11 Jan 2007 04:11:26 +0000 (04:11 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Thu, 11 Jan 2007 04:11:26 +0000 (04:11 +0000)
By default, editing NS_MEDIAWIKI requires "editinterface" permission, just as before.

RELEASE-NOTES
includes/DefaultSettings.php
includes/Title.php

index ce97c34..5d0e00d 100644 (file)
@@ -43,9 +43,14 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
    feature, which automagically disallows edits to pages transcluded into a page protected with
    this new option. Various other code tidiness fixes and refactoring in the log messages of
    branches/werdna/restrictions-separation.
+* The minimum permissions needed to edit a page in each namespace can
+  now be customized via the $wgNamespaceProtection array.  By default,
+  editing pages in the MediaWiki namespace requires "editinterface"
+  permissions, just as before.
 
 == Languages updated ==
 
+* Finnish (fi)
 * Hebrew (he)
 * Indonesian (id)
 * Lithuanian (lt)
index ed72d25..14d5cbf 100644 (file)
@@ -988,7 +988,7 @@ $wgGroupPermissions['sysop']['import']          = true;
 $wgGroupPermissions['sysop']['importupload']    = true;
 $wgGroupPermissions['sysop']['move']            = true;
 $wgGroupPermissions['sysop']['patrol']          = true;
-$wgGroupPermissions['sysop']['autopatrol']             = true;
+$wgGroupPermissions['sysop']['autopatrol']     = true;
 $wgGroupPermissions['sysop']['protect']         = true;
 $wgGroupPermissions['sysop']['proxyunbannable'] = true;
 $wgGroupPermissions['sysop']['rollback']        = true;
@@ -1029,6 +1029,14 @@ $wgRestrictionTypes = array( 'edit', 'move' );
  */
 $wgRestrictionLevels = array( '', 'autoconfirmed', 'sysop' );
 
+/**
+ * Set the minimum permissions required to edit pages in each
+ * namespace.  If you list more than one permission, a user must
+ * have all of them to edit pages in that namespace.
+ */
+$wgNamespaceProtection = array();
+$wgNamespaceProtection[ NS_MEDIAWIKI ] = array( 'editinterface' );
+
 
 /**
  * Number of seconds an account is required to age before
index 191d77e..1c28a9b 100644 (file)
@@ -1081,7 +1081,7 @@ class Title {
                $fname = 'Title::userCan';
                wfProfileIn( $fname );
 
-               global $wgUser;
+               global $wgUser, $wgNamespaceProtection;
 
                $result = null;
                wfRunHooks( 'userCan', array( &$this, &$wgUser, $action, &$result ) );
@@ -1094,12 +1094,15 @@ class Title {
                        wfProfileOut( $fname );
                        return false;
                }
-               // XXX: This is the code that prevents unprotecting a page in NS_MEDIAWIKI
-               // from taking effect -ævar
-               if( NS_MEDIAWIKI == $this->mNamespace &&
-                   !$wgUser->isAllowed('editinterface') ) {
-                       wfProfileOut( $fname );
-                       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->mDbkeyform == '_' ) {