r19110 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r19109 | r19110 (on ViewVC) | r19111 >
Date:04:11, 11 January 2007
Author:vyznev
Status:new
Tags:
Comment:Allow customizing the minimum per-namespace protection level via $wgNamespaceProtection.
By default, editing NS_MEDIAWIKI requires "editinterface" permission, just as before.
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php	(revision 19109)
+++ trunk/phase3/includes/Title.php	(revision 19110)
@@ -1081,7 +1081,7 @@
 		$fname = 'Title::userCan';
 		wfProfileIn( $fname );
 
-		global $wgUser;
+		global $wgUser, $wgNamespaceProtection;
 
 		$result = null;
 		wfRunHooks( 'userCan', array( &$this, &$wgUser, $action, &$result ) );
@@ -1094,12 +1094,15 @@
 			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 == '_' ) {
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 19109)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 19110)
@@ -988,7 +988,7 @@
 $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,7 +1029,15 @@
  */
 $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
  * it's given the implicit 'autoconfirm' group membership.
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 19109)
+++ trunk/phase3/RELEASE-NOTES	(revision 19110)
@@ -43,9 +43,14 @@
    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)
Views
Toolbox