Jump to content

Manual talk:$wgNamespaceProtection

Add topic
From mediawiki.org
Latest comment: 7 years ago by Ciencia Al Poder in topic Custom Namespaces not accepting edit group

2007

[edit]

prevent editing of a custom namespace

[edit]

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)Reply

Restrict editing in the main namespace

[edit]

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]

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

LocalSettings.php

[edit]

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)Reply

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)Reply

Applying wgNamespaceProtection to anon accounts

[edit]

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)Reply

Bump - I would like an answer to this too. --Pompelpilt (talk) 11:52, 2 March 2015 (UTC)Reply

Group name problems

[edit]

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]

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]
  • 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]

Custom Namespace permissions

[edit]

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)Reply

prevent custom namespace from reading

[edit]

How do I prevent a custom namespace from reading except 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)Reply

Where to set $wgNamespaceProtection[PLACEHOLDER] for Namespaces generated by Extensions loaded with Composer ?

[edit]

I have certain TALK-Pages made unavailable.
I used to have lines in my LocalSettings.php akin to:
$wgNamespaceProtection[SMW_NS_PROPERTY_TALK] = array ('TalkAccess'); //Semantic Mediawiki
But since I load the extension via Composer, the expression SMW_NS_PROPERTY_TALK isn't defined when LocalSettings.php is processed.

So, where do I move that line of code ? Heinrich krebs (talk) 18:27, 3 December 2014 (UTC)Reply

2017

[edit]

Custom Namespaces not accepting edit group

[edit]

I have the following commands to add a custom namespace to my wiki:

// Namespace for the First_Brigade Pages
define("NS_First_Brigade", 3016);
define("NS_First_Brigade_TALK", 3017);
$wgNamespacesToBeSearchedDefault[NS_First_Brigade] = true;
$wgExtraNamespaces[NS_First_Brigade] = "First_Brigade";
$wgExtraNamespaces[NS_First_Brigade_TALK] = "First_Brigade_Talk";
$wgNamespacesWithSubpages[NS_First_Brigade] = true;
$wgNamespaceProtection[NS_First_Brigade] = array( 'editFirst_Brigade' );
$wgNamespaceProtection[NS_First_Brigade_TALK] = array( 'editFirst_Brigade' );
$wgGroupPermissions['sysop']['editFirst_Brigade'] = true;
$wgGroupPermissions['First_Brigade']['editFirst_Brigade'] = true;


Using MediaWiki Version: 1.28

And I created a test user and when they go to the page that they should have permission to edit they only get the View Source tab and in that tab it states:
View source for First Brigade:First Brigade
← First Brigade:First Brigade
You do not have permission to edit this page, for the following reason:
The action you have requested is limited to users in one of the groups: Administrators, Main Namespace Editors.

This does not list the group First_Brigade that the test user is apart of.

— Preceding unsigned comment added by 168.244.4.51 (talkcontribs)

I'm not sure if the message will list specific groups added by this variable, maybe it only lists groups that have the general "edit" right. Did you try to edit with a user member of the First_Brigade group? Does that group have the general 'edit' right? --Ciencia Al Poder (talk) 20:15, 19 July 2017 (UTC)Reply