Extension:HNP

From MediaWiki.org

Jump to: navigation, search

           

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
HNP

Release status: stable

Implementation  User rights
Description Provides an hierarchical namespace permissions system (aka "prefixes") to Mediawiki without changes to the base installation nor creation of new database tables.
Author(s)  Jean-Lou Dupont
Last Version  1.1.2
MediaWiki  1.10, 1.11
License No license specified
Download no link
See SVN

check usage (experimental)

Contents

[edit] Features

  • Permission management through simple edition of a page
    • MediaWiki:Registry/HNP
  • Sysop has always all rights regardless of state of registry page
    • Enables easier 'human error' management
  • Prefix based namespace access with wildcards
    • E.g. 'sysop group has access to all namespaces'
  • Namespace dependant & Namespace Independant rights management
  • No additional database tables nor changes to schema
  • No mandatory patches
    • Namespace dependant rights management: no patches necessary
    • Namespace independant rights management: if wanted, requires a patch:
      • 'includes/User.php'
  • Post-installation information always available through Special:Version page.
  • Magic Words:
    • ' #username# ' magic word can be used to substitute the current user's name in the title field
      • Useful for implementing functionality akin to 'KeepYourHandsToYourself' whereas only the owner of a userpage can edit his own

[edit] Usage

Please see example configuration page Example.

[edit] Notes



[edit] Installation

See the Mediawiki Extension table entry "download" above.[1]

[edit] LocalSettings.php

Extension:ExtensionManager: See footnote[2]

require_once( "$IP/extensions/HNP/HNP.php" );

[edit] PEAR

PEAR is a repository of en:PHP software code.

pear channel-discover mediawiki.googlecode.com/svn
  • Install extension through PEAR:
pear install mediawiki/HNP
  • Add the following to LocalSettings.php[2][3]:
require 'MediaWiki/HNP/HNP.php';
  • Note that the required version of PEAR must be respected. Currently, the minimum version of PEAR usable with this channel is v1.6.2. Perform the following command to upgrade to the latest version of PEAR:
pear upgrade pear

[edit] Upgrades through PEAR

Sometimes, it is necessary to clear PEAR's cache in order to perform upgrades.

pear clear-cache

or use the force method:

pear upgrade --force mediawiki/HNP

[edit] PEAR Web Frontend

For easier remote package management, PEAR Frontend WEB can be installed. Installation notes can be found here. An example of the WEB frontend is available here.

[edit] RSS feed

To keep kept up-to-date with this channel, use the following RSS feed__Rss2.jpg.

[edit] Notes

[edit] Other Extensions From the same author

Consult User Jldupont's page.


  1. The most recent release is always available through the extension's PEAR and SVN repositories. This page is not necessarily up-to-date.
  2. 2.0 2.1 2.2 Extension:ExtensionManager does not require any modification to LocalSettings.php because ExtensionManager includes the extension.
    Note that if PHP code caching is in place (e.g. APC, eAccelerator), then to successfully complete the installation a cache flush might be needed.
  3. Modifications to LocalSettings.php is only necessary if not using Extension:ExtensionManager

[edit] User.php patch

[edit] Original file

	function isAllowed($action='') {
		if ( $action === '' )
			// In the spirit of DWIM
			return true;
 
		return in_array( $action, $this->getRights() );
	}

[edit] Patched file

	function isAllowed($action='', $ns = null /* addition */, $title = null /* addition */ ) 
	{
		if ( $action === '' )
			// In the spirit of DWIM
			return true;
 
		//  PATCH begin{{
		$result = null;
		wfRunHooks('UserIsAllowed', array( &$this, $ns, $title, &$action, &$result ) );
		if ( $result !== null )
			return $result;
		// PATCH end }}
 
		return in_array( $action, $this->getRights() );
	}

[edit] MEDIAWIKI NOTES

1) Only the forward slash is interpreted (when enabled) as an indicator of "sub-page". Thus, only the forward slash and ~ are considered here to be part of the hierarchical functionality.

2) The allowed characters in a title are defined in "DefaultSettings.php".

  $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
  NOTE that #{}[]| are not part of this list.
 

3) Special command characters for preg_match do not include the following:

  #`'~,@
  Those were tested with preg_quote

4) Be careful not to choose namespace name identifiers too long as the standard limit in Mediawiki is 16characters long.

[edit] History

[edit] 1.0.1

  • Removed file caching (causing more troubles than adding value)
  • Fixed debug messages as to not stop normal processing flow.

[edit] 1.1.0

  • Added Magic Words support
    • '#username#' magic word for implementing functionality akin to 'KeepYourHandsToYourself'

[edit] 1.1.1

  • Attempt at fixing the parser functions '#hnp_r' and '#hnp_h' that do not work on some setup.

[edit] 1.1.2

  • Reverted 'fix' of version 1.1.1
  • Adjusted dependency to Extension:StubManager v1.0.5 (fix for PHP bug with version 5.1.2)