Manual talk:$wgNamespaceProtection

From MediaWiki.org
Jump to: navigation, search

2007[edit | edit source]

prevent editing of a custom namespace[edit | edit source]

How would one use $wgNamespaceProtection to prevent editing of a custom namespace? Say one's got:

$wgGroupPermissions['comics']['read'] = true;

$wgExtraNamespaces = array(100 => "Comics",
                           101 => "Comics_talk"
                           );

...and I wanted only folks in the 'comics' group to be able to edit the Comics (100) namespace? --18 May 2007

You'd need something like:
   $wgGroupPermissions['comics']['editcomics'] = true;
   $wgNamespaceProtection[ 100 ] = array( 'editcomics' );
--Ilmari Karonen 04:31, 21 May 2007 (UTC)

Restrict editing in the main namespace[edit | edit source]

The example above restricts editing of the comics namespace.

It is also possible to restrict editing of the main namespace but to keep the comics namespace editing enabled for the group 'comics'.

Use the following additional lines in LocalSettings.php:

$wgGroupPermissions['main']['editmain'] = true;
$wgNamespaceProtection[NS_MAIN] = array( 'editmain' );

--C.mackinlay 2 June 2007

What File[edit | edit source]

I can't seem to get this to work. What file is this variable used in? -- Egingell 18:18, 17 August 2007 (UTC)

LocalSettings.php[edit | edit source]

Example settings in LocalSettings.php. These settings restrict all pages in the 'main' namespace to be "read-only" for users who have not logged in and enable pages in the 'enrichment' namespace to be edited by 'studenteditors'.

# Prevent new user registrations except by sysops
$wgGroupPermissions['*']['createaccount'] = false;

# Disable anonymous editing
// Implicit group for all anonymous
$wgGroupPermissions['*'    ]['createaccount']   = false;
$wgGroupPermissions['*'    ]['read']            = true;
$wgGroupPermissions['*'    ]['edit']            = false;
$wgGroupPermissions['*'    ]['createpage']      = false;
$wgGroupPermissions['*'    ]['createtalk']      = false;

// Implicit group for all logged-in accounts
$wgGroupPermissions['user' ]['move']            = false;
$wgGroupPermissions['user' ]['read']            = true;
$wgGroupPermissions['user' ]['edit']            = false;
$wgGroupPermissions['user' ]['createpage']      = false;
$wgGroupPermissions['user' ]['createtalk']      = false;
$wgGroupPermissions['user' ]['upload']          = false;
$wgGroupPermissions['user' ]['reupload']        = false;
$wgGroupPermissions['user' ]['reupload-shared'] = false;
$wgGroupPermissions['user' ]['minoredit']       = false;

$wgGroupPermissions['studenteditor']['edit'] = true;

$wgGroupPermissions['enrichment']['read'] = true;
$wgGroupPermissions['enrichment']['edit'] = true;
$wgGroupPermissions['enrichment' ]['createpage']      = true;
$wgGroupPermissions['enrichment' ]['upload']          = true;
$wgExtraNamespaces = array(100 => "Enrichment_Week",
                           101 => "Enrichment_Week_talk"
                           );

$wgGroupPermissions['root']['editroot'] = true;

$wgNamespaceProtection[NS_MAIN]     = $wgNamespaceProtection[NS_USER]  =
$wgNamespaceProtection[NS_PROJECT]  = $wgNamespaceProtection[NS_IMAGE] =
$wgNamespaceProtection[NS_TEMPLATE] = $wgNamespaceProtection[NS_HELP]  =
$wgNamespaceProtection[NS_CATEGORY] = array( 'editroot' );

$wgGroupPermissions['enrichment']['editenrichment'] = true;
$wgNamespaceProtection[ 100 ] = array( 'editenrichment' );

--ColinM 19:13, 18 August 2007 (UTC)

probably a misunderstanding? It seems that 'studenteditor' cannot edit the 'Enrichment_Week' (code 100) namespace because in the last line is protected ('editenrichment' permission is required and this permission is given to 'enrichment' group and not to 'studenteditor'). I missed something? TKS --GB 12:02, 8 November 2007 (UTC)

Applying wgNamespaceProtection to anon accounts[edit | edit source]

Is there a way to apply different permissions to anon users based on namespace? For example to prevent anon users from viewing the NS_TALK namespace unless logged in. --Rob 00:00, 3 October 2007 (UTC)

Group name problems[edit | edit source]

FYI: the database that came with 1.10 is has a group name limitation of 16 characters by default. This is easily changed with your favorite mysql editor but since it truncates the names to fit it can be a gotcha.

This also effects group names that are sync'd in from LDAP/AD as mediawiki will mirror their names into it's database.

--Jacob, Oct 24, 2007

Restrict specific namespace[edit | edit source]

I would like to restrict the edition of one namespace. The main reason would be to create a new namespace labeled News and a corresponding group Journalists, then I would like to give them those permissions, but I do not want to give them the sysop range or the editinterface capability to change any Namespace a part of the dedicated for them.

I would like to do this without extensions, it is only one group and one specific namespace. Any suggestion?

Wiki info[edit | edit source]

  • MediaWiki version: 1.14.0
  • Semantic MediaWiki version: 1.4.2
  • PHP version: 5.2.5 (cgi)
  • MySQL version: 4.1.22-standard
  • URL: http://wikimanga.net
  • Direct link to Version

2009[edit | edit source]

Custom Namespace permissions[edit | edit source]

I have a custom namespace that i have been working on and i need to be able to have SysOps, Bureaucrats, and Developers (my group) to have access to the pages but not '*' or 'users'.

# Defining the Source Namespace
define("NS_SOURCE", 100);
define("NS_SOURCE_TALK", 101);
 
# Assigning the Source Namespace
$wgExtraNamespaces =
	array( NS_SOURCE => "Source",
		 NS_SOURCE_TALK => "Source_talk"
	     );
 
# Wiki Namespaces to Search
$wgNamespacesToBeSearchedDefault =
	array(NS_MEDIA => false, 
		NS_SPECIAL => false, 
		NS_MAIN => true, 
		NS_TALK => false,
		NS_USER => false,
		NS_USER_TALK => false,
		NS_PROJECT => true,
		NS_PROJECT_TALK => true,
		NS_FILE => false,
		NS_FILE_TALK => false,
		NS_MEDIAWIKI => false,
		NS_MEDIAWIKI_TALK => false,
		NS_TEMPLATE => false, 
		NS_TEMPLATE_TALK => false,
		NS_HELP => true,
		NS_HELP_TALK => false,
		NS_CATEGORY => false,
		NS_CATEGORY_TALK => false,
		NS_SOURCE => false, 
		NS_SOURCE_TALK => false
		);
 
# Wiki Namespace changes
$wgNamespacesWithSubpages[NS_MAIN] 		= true;
$wgNamespacesWithSubpages[NS_PROJECT] 	= true;
$wgNamespacesWithSubpages[NS_SOURCE] 	= true;
 
# Source Namespace Rights
$wgNamespaceProtection[NS_SOURCE] = array( 'editsource' );
$wgNamespaceProtection[NS_PROJECT] = array ( 'editproject' );

Above, is my setup of the namespaces. NS_SOURCE (100) is the custom namespace i am working on for highly modified pieces of information before it goes to either the NS_PROJECT or NS_MAIN namespaces.

Here is my permissions implmenetation for the sysop and bureau user groups

// Implicit group for all Sysops accounts
$wgGroupPermissions['sysop']['editsource']		= true;
$wgGroupPermissions['sysop']['editproject']		= true;
$wgGroupPermissions['sysop']['ns100_create']		= true;
$wgGroupPermissions['sysop']['ns100_read']		= true;
$wgGroupPermissions['sysop']['ns100_edit']		= true;
$wgGroupPermissions['sysop']['ns100_move']		= true;
$wgGroupPermissions['sysop']['ns101_create']		= true;
$wgGroupPermissions['sysop']['ns101_read']		= true;
$wgGroupPermissions['sysop']['ns101_edit']		= true;
$wgGroupPermissions['sysop']['ns101_move']		= true;
// Implicit group for all Bureaucrat accounts
$wgGroupPermissions['bureaucrat']['editsource']		= true;
$wgGroupPermissions['bureaucrat']['editproject']	= true;
$wgGroupPermissions['bureaucrat']['ns100_create']	= true;
$wgGroupPermissions['bureaucrat']['ns100_read']		= true;
$wgGroupPermissions['bureaucrat']['ns100_edit']		= true;
$wgGroupPermissions['bureaucrat']['ns100_move']		= true;
$wgGroupPermissions['bureaucrat']['ns101_create']	= true;
$wgGroupPermissions['bureaucrat']['ns101_read']		= true;
$wgGroupPermissions['bureaucrat']['ns101_edit']		= true;
$wgGroupPermissions['bureaucrat']['ns101_move']		= true;

Goldbishop 02:03, 3 July 2009 (UTC)

prevent custom namespace from reading[edit | edit source]

How do I prevent a custom namespace from reading exectp a trusted usergroup? On Mediawiki 1.18.0 on Windows, when I do

define('NS_TWUTZ', 100);
$wgExtraNamespaces[NS_TWUTZ] = "twutz";
$wgExtraNamespaces[NS_TWUTZ+1] = "twutz_talk";
$wgContentNamespaces[] = NS_TWUTZ;

$wgNamespaceProtection[NS_TWUTZ] = array( 'edittwutz' );
$wgGroupPermissions[*]['ns100_read']             = false;
$wgGroupPermissions['trusted']['ns100_read']     = true;
$wgGroupPermissions['sysop']['ns100_read']       = true;

Requesting a page in this namespace returns an empty page, also as a sysop.

With the Extension:NamespaceProtection, this was possible. However, this extension is not supported any more, and I get errors on using it together with SemantikMediaWiki. Tomaschwutz 22:03, 17 January 2012 (UTC)