From: Ilmari Karonen Date: Thu, 11 Jan 2007 04:11:26 +0000 (+0000) Subject: Allow customizing the minimum per-namespace protection level via $wgNamespaceProtection. X-Git-Tag: 1.31.0-rc.0~54511 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=9cf19005396d3b3e03b0916684a724eb165c4497;p=lhc%2Fweb%2Fwiklou.git Allow customizing the minimum per-namespace protection level via $wgNamespaceProtection. By default, editing NS_MEDIAWIKI requires "editinterface" permission, just as before. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ce97c3498a..5d0e00d7ab 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ed72d25899..14d5cbf787 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 diff --git a/includes/Title.php b/includes/Title.php index 191d77e638..1c28a9b489 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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 == '_' ) {