Extension:Permissions

This page is about the Permissions Extension for MediaWiki. For more general information about managing MediaWiki permissions see Help:User rights

Introduction
The URL of this page is http://www.mediawiki.org/wiki/Extension:Permissions

Permissions is a special page extension by Marc Meurrens, Brussels (be).

This extension is designed for : mediawiki >= 1.5beta4 The current version of the extension is : 1.5.104.9 (2005-08-04)

The extension provides a meaningful dump of the mediawiki global variable $wgGroupPermissions.

Such dump may be useful to explain to users the differences between the miscellaneous groups of users.



The above screenshot shows the output of the extension (without the definition of aliases). In this example, the groups member, publisher and staff are non standard groups added in the $wgGroupPermissions. Similarly, the rights renameuser and release are non standards feature. We'll use the aliasing, as shown in another screenshot below, to distinguish standard and non standard features.

The screenshot below shows the output when links on rights and groups are allowed (this is the default behaviour), when the language preference is french (Oui means Yes) and for the most common settings (without non standard groups).



Installation
To install the extension, do the following :
 * create a file   in your   directory (the content is listed below)
 * modify your   file

If you meet a problem, feel free to contact the authors thru the discussion page.

Content of the file
You absolutely don't need to understand this code to install, configure and use the extension. However, if you read it, you may be surprised, positively or not, by some coding conventions used here. These conventions are those used, in all their projects, by Marc Meurrens (be) and his team and are (or will be) explained in separate pages.

If you want to read the source code, it is suggested you first read the haDoc documentation provided below. \n" ;

// !STEP-6 OF BuildHtmlTable : returns the HTML string return $szhOut ; }

// the utilities : // could be private, but may be usefull elsewhere... // !SF : function Wiki_2_Html( $szwMessage ) /**    * @param wikistring $szwMessage * @return htmlstring $szhMessage * @uses parse * @uses getText * @version 1.5.104.6 * @requires (MediaWiki 1.5, beta 4 , minor revision 6) * @since 1.5.104.6 (2005-08-03) * @internal rather rely on standard stuff when integrating the patch in the whole project */               function Wiki_2_Html( $szwMessage ) {                       global $wgParser, $wgTitle, $wgOut ;

$parserOutput = $wgParser->parse(                       $szwMessage                       , $wgTitle                        , $wgOut->parserOptions                        , true                        ) ;

return $parserOutput->getText ; }

// !SF : function Translate($szOriginal) /**    * a simplified version of MediaWiki_I18N::translate * (does NOT support interpolation of variables) *    * placed here to make this file standalone * (we just need to translate 'Yes' into 'Oui', 'Si', 'Ya', etc     *     * @param string $szOriginal     * @return string $szTranslated     * @version 1.5.104.7     * @internal rather rely on standard stuff when integrating the patch in the whole project     */                 function Translate($szOriginal)                {                        $fname = 'SkinTemplate-translate';                        wfProfileIn( $fname ) ; // open                        // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23                        $szOriginal = preg_replace( '/^string:/', '', $szOriginal ); // clean                        $szTranslated = wfMsg( $szOriginal );                        // interpolate variables : removed in this simplified version !!!                        wfProfileOut( $fname ) ; // release                        return $szTranslated ;                }

// !SF : end static functions : /**#@+-*/

} // !END_OF_CLASS : Permissions

// !STEP-5 OF wfSpecialPermissions : register, make sure this special page is known SpecialPage::addPage ( new Permissions ) ;

} // !END-FUNCTION : wfSpecialPermissions // !EOF : includes/SpecialPermissions.php ?>

=== Updating your

You may also want to use this file to configure aliases and links to clarify the meaning of the groups and rights. Configuration is described in the next section. It doesn't matter if you put the configuration statements  before or after  the include_once statement.

In rare cases, you may want to modify the default behaviour of the extensions. Full features are provided by default. If you want to modify this default behaviour, you should place one or more of the following statements, in your ''' file : $wg_zPermissionsWithConvenienceLinks = false ; or to include define( 'Permissions_CONVENIENCE_LINKS', false ) ; as to change the default behaviour,  before  the include_once.

Aliasing the Groups and Rights
If you need to define aliases and links for groups or rights, you may define some variables in your   file as suggested in this examples :

By default, the extension will try to link rights and groups to standard definitions. If you want to avoid this feature, you need to turn it off by including the corresponding statement anywhere in your   file : $wg_zShowRightsOnMeta = false ; $wg_zShowGroupsOnMeta = false ; or by including the corresponding statements : define( 'Permissions_SHOW_RIGHTS_ON_META', false ) ; define( 'Permissions_SHOW_GROUPS_ON_META', false ) ; as to change the default behaviour,  before  the include_once.

The above feature does not apply to rights and groups for which you provide your own replacements. This is specially usefull for non standards rights and groups (for which there is obviously no help available on meta). Replacements may be defined in pure HTML or as a wiki text. In case of conflicts, the wiki definition has priority.

The HTML definitions are provided as in the example (in general, you'll prefer wiki links as shown below): $wg_szGroup_2_szhGroupMeaning = array( // szh ==> HTML 'member' => 'member (étudiant), // étudiant (fr) == student (en) 'publisher' => 'publisher (professeur) , // professeur (fr) == teacher (en) 'staff' => "this will be ignored because of the wiki definition below" , ) ; $wg_szRight_2_szhRightMeaning = array( 'renameuser' => ' renameuser ', 'release' => ' release ' , ) ; Mind the sz h ...

The wiki definitions are provided as in the example (in general, you'll use this feature to link to some pages of your wiki explaining your groups, etc) : $wg_szGroup_2_szwGroupMeaning = array( // szw ==> WIKI 'staff' => "staff (secrétariat)", ) ; $wg_szRight_2_szwRightMeaning = array ; Mind the sz w ...

With the above statements, the output becomes :



Where is your special page?
The Permissions special page is immediately available within your wiki pages when writing : Permissions

The page is also available at the URL : http://www.yourdomain.org/wiki/index.php/Special:Permissions

The page is listed, at the entry Permissions in the Special Pages alphabetical list.

Linking to or Using this extension in other pages
The Permissions special page provides (by default) wiki links to related other special pages.

=== Updating your by :

Hacking
Within this section, it's assumed you use a Unix or GNU/Linux operating system (other systems may eventually (?) be useful for other tasks (?), but developing or hacking under such systems is, anyway, not considered professional/serious by the authors of the extension)

While you can easily retrieve it yourself by a statement such as : ./haDoc.sh SpecialPermissions.php where haDoc.sh is : cat $1 | grep "// \!" > $1.hadoc here is the content of the haDoc documentation :

// !FILE : includes/SpecialPermissions.php // !CLASS : Permissions // !INNER-CLASS // !ANTI-CRASH : mediawiki stuff + version stuff // !VERSION // !DVRM : // !CONFIG : default values (to be eventually modified before include) : // !CONSTANT's : internal constants // !INIT : pre-init stuff processed because of an include_once in the LocalSettings.php file : // !FUNCTION : wfSpecialPermissions // !STEP-1 OF wfSpecialPermissions : complete the messages that will be used : // !STEP-2 OF wfSpecialPermissions  : hooks for logs : none... // !STEP-3 OF wfSpecialPermissions : include what should be included : // !STEP-4 OF wfSpecialPermissions : inner class definition(s) : // !CLASS: Permissions extends SpecialPage // !INNER-CLASS // !IV's : none // !CT // !IM's : instance methods // !IM : execute // !OVRDN // !TODO : rely on $wgValidSpecialPagesFr to translate... // !SF's : begin static functions : // !SF : function BuildHtmlLink // !SF : function BuildHtmlTable // !STEP-1 OF BuildHtmlTable : translate // !STEP-2 OF BuildHtmlTable : init // !STEP-3 OF BuildHtmlTable : build the 2 sets // !STEP-4 OF BuildHtmlTable : sort the 2 sets // !STEP-5 OF BuildHtmlTable : it's now time to prepare the HTML output // !STEP-5-1 OF BuildHtmlTable : HTML thead stuff // !STEP-5-2 OF BuildHtmlTable : HTML tbody stuff // !STEP-6 OF BuildHtmlTable : returns the HTML string // !SF : function Wiki_2_Html( $szwMessage ) // !SF : function Translate($szOriginal) // !SF : end static functions : } // !END_OF_CLASS : Permissions // !STEP-5 OF wfSpecialPermissions : register, make sure this special page is known } // !END-FUNCTION : wfSpecialPermissions // !EOF : includes/SpecialPermissions.php