Extension:RightFunctions

From mediawiki.org
This page is a translated version of the page Extension:RightFunctions and the translation is 49% complete.
Outdated translations are marked like this.
Manuel des extensions MediaWiki
RightFunctions
État de la version : stable
Implémentation Fonction d'analyseur
Description Fournit des fonctions d'analyse basées sur les autorisations
Auteur(s) Ryan Schmidt (Skizzerzdiscussion)
Dernière version 1.13.0 (2020-08-08)
MediaWiki 1.23+
PHP 5.3+
Modifie la base
de données
Non
Licence domaine public
Téléchargement
CHANGELOG

  • $wgRightFunctionsUserGroups
  • $wgRightFunctionsDisableFunctions
  • $wgRightFunctionsAllowExpensiveQueries
  • $wgRightFunctionsAllowCaching
Téléchargements trimestriels 11 (Ranked 129th)
Traduire l’extension RightFunctions sur translatewiki.net si elle y est disponible
Problèmes Tâches ouvertes · Signaler un bogue

L'extension RightFunctions teste différentes autorisations d'utilisateur ou de page et affiche du texte en fonction de celles-ci.

Veuillez noter que ces fonctions d'analyse peuvent être utilisées pour cacher superficiellement des informations à ceux qui ont certains droits. Notez également que toutes les fonctions désactivent le cache sur la page dans laquelle elles sont utilisées sauf si vous définissez $wgRightFunctionsAllowCaching à true.

Utilisation

Ifright

Vérifie si l'utilisateur actuel dispose du droit indiqué, puis affiche le texte approprié. Si le droit n'existe pas, il renvoie simplement autre chose. Si aucun droit n'est spécifié, il return alors. Cette fonction ignore les restrictions par page sur les droits d'un utilisateur, donc utilisez #Ifpageright si vous avez besoin de cette fonctionnalité.

Utilisation : {{#ifright:right|then|else}}

Ifallowed

Vérifie si l'utilisateur donné a le droit donné, puis affiche le texte approprié. Cette fonction ne retourne rien sauf si un utilisateur est défini. Cette fonction ignore les restrictions par page sur les droits d'un utilisateur, donc utilisez #Ifpageallowed si vous avez besoin de cette fonctionnalité.

Utilisation : {{#ifallowed:user|right|then|else}}

Switchright

Instruction switch qui vérifie si l'utilisateur actuel dispose des droits. Cela fonctionne comme l'instruction ParserFunctions #switch.

Utilisation :

{{#switchright:
 right1=result1
|right2
|right3=result2 and 3
|right4=result4
|default (or #default=default if the default text contains =)
}}

Userrights

Répertorie tous les droits dans une liste non ordonnée de l'utilisateur actuel ou de l'utilisateur donné. Si un utilisateur n'est pas défini, l'utilisateur actuel est selectionné.

Utilisation:

  • {{#userrights:}} - (pour l'utilisateur actuel)
  • {{#userrights:user}} - (pour les autres utilisateurs)

Usergroup

Renvoie le groupe d'utilisateurs le plus élevé auquel l'utilisateur appartient. Les groupes sont définis par classement du plus bas au plus élevé dans le tableau $wgRightFunctionsUserGroups. Si un utilisateur n'est pas défini, l'utilisateur actuel. est selectionné

Usage:

  • {{#usergroup:}} - for current user
  • {{#usergroup:user}} - for other users

Ifgroup

Teste si l'utilisateur donné est dans le groupe spécifié. Si aucun utilisateur n'est spécifié, le test s'applique pour l'utilisateur actuel. Si aucun groupe n'est spécifié, il renvoie le libellé else.

Usage:

  • {{#ifgroup:group|then|else}} - for current user
  • {{#ifgroup:group|then|else|user}} - for other users

Switchgroup

L'instruction switch teste si l'utilisateur actuel fait partie d'un groupe. This operates much like the ParserFunctions #switch statement.

Utilisation:

{{#switchgroup:
 group1=result1
|group2
|group3=result2 and 3
|group4=result4
|default (or #default=default if the default text contains =)
}}

Ifpageright

Tests whether the current user has the given right on the given page, then displays the appropriate text. If the right doesn't exist, it simply returns else. If no right is specified, it returns then. This function does not ignore per-page restrictions on a user's rights.

Usage:

  • {{#ifpageright:right|then|else|page}} - for testing other pages
  • {{#ifpageright:right|then|else}} - for testing the current page

Ifpageallowed

Tests whether the given user has the given right on the given page, then displays the appropriate text. If no user is specified, it returns nothing. If no page is specified, it checks the current page. If the right doesn't exist, it returns else and if no right is specified, it returns then. This function does not ignore per-page restrictions on a user's rights.

Usage:

  • {{#ifpageallowed:user|right|then|else|page}} - for testing other pages
  • {{#ifpageallowed:user|right|then|else}} - for testing the current page

Ifprotected

Tests whether the given page is protected, then displays the appropriate text. If no page is given, it tests the current page. It will return then if the page is either fully-protected, semi-protected, protected because it is included in a cascading-protected page, or if it is namespace-protected. You may control which of these are tested by adding the letters "f", "s", "c", and/or "n" (standing for fully-protected, semi-protected, cascading-protected, and namespace-protected, respectively) to the fourth parameter of the page (by default all 4 are tested).

Usage:

  • {{#ifprotected:then|else|page}} - for testing other pages
  • {{#ifprotected:then|else}} - for testing the current page
  • {{#ifprotected:then|else|page|fns}} - for testing only certain types of protection

Getrestrictions

Grabs what right is required to carry out the action on the given page. If no page is given, it checks the current page instead. If no right is given, it checks the 'edit' right. If there are no restrictions on that page for the particular right, it returns the empty string (""). If the page has cascading restrictions as well, it returns the highest restriction level for the page (from all cascading sources and the local page itself). If you would like all the restrictions to be listed instead, set the third parameter to "true". If you do, the output format changes to be more detailed, depending on what restrictions exist for the current page, cascading-protected sources, and namespace protection.

Usage:

  • {{#getrestrictions:right|page}} - for testing other pages
  • {{#getrestrictions:right}} - for testing the current page
  • {{#getrestrictions:right|page|true}} - for listing all restrictions instead of just the highest one

Installation

  • Téléchargez et placez le(s) fichier(s) dans un répertoire appelé RightFunctions dans votre dossier extensions/.
    Les développeurs et les contributeurs au code doivent à la place installer l'extension à partir de Git en utilisant:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/RightFunctions
  • Ajoutez le code suivant à la fin de votre fichier LocalSettings.php  :
    wfLoadExtension( 'RightFunctions' );
    
  • Configure as required
  • Yes Fait – Accédez à Special:Version sur votre wiki pour vérifier que l'extension a bien été installée.

Configuration

These variables control how the various parser functions work. There are currently 4 variables.

$wgRightFunctionsUserGroups

Default value: array( '*', 'user', 'autoconfirmed', 'sysop', 'bureaucrat' ) An array of groups to test for in #Usergroup. They are arranged in order of least to greatest for group testing.

$wgRightFunctionsAllowCaching

Default value: false

If set to true, the functions do not disable the parser cache and they do not trigger the recache when getting a user's groups. It is recommended that you leave this as false.

$wgRightFunctionsAllowExpensiveQueries

Default value: true

If set to true, using ifpageright and ifpageallowed will check the rights more thoroughly (like through cascading protection), so it will produce more accurate results, but it will me more server-intensive to perform. It is recommended that you leave this as true.

$wgRightFunctionsDisableFunctions

Default value: array()

Les fonctions de ce tableau ne seront pas évaluées et renverront rien.

Changelog

Version 1.12
Removed backwards compatible I18n shim
Version 1.11
Converted I18n to use json files including providing a backwards compatible shim
Version 1.10
Many bugfixes. Messages for getrestrictions are now more customizable, ifprotected and getrestrictions now properly detect namespace protection, fixed typo in variable name that caused getrestrictions to crash.
Version 1.9
Moved to Subversion. Was accidentally changed to "2.0" when some test stuff was removed, please be aware that it is not actually 2.0, but 1.9
Version 1.8
Added two parser functions for easier multi-testing of rights/groups: switchright and switchgroup.
Version 1.7
Fixed title bug (side issue in bug 12420), removed restrictions for viewing other users' rights, removed warnings, added in variable to disable functions, modified ifallowed and ifpageallowed to require a user be defined.
Version 1.6
Getrestrictions now only returns the highest-level restriction by default, a list of all restrictions can be had by setting the third parameter true.
Version 1.5
Major bugfix in getrestrictions, should now work as expected (yay)
Version 1.4
Getrestrictions now checks cascading sources (albeit not very efficiently), now allows user to pick protection types to check for in ifprotected, bugfix in return of getrestrictions.
Version 1.3
Cleaned up code for less redundancy, added $wgRightFunctionsAllowCaching to allow caching, added ifgroup, made usergroup actually work off of real user groups instead of rights that mimicked group names, changed $wgRightFunctionsOtherUsers to test groups instead of rights. $wgRightFunctionsAllowExpensiveQueries is now true by default.
Version 1.2
Added four parser functions ifpageright, ifpageallowed, ifprotected, and getrestrictions. Added in variable for hiding warning messages and a variable for enabling more server-intensive queries for the ifpageright and ifpageallowed functions.
Version 1.1
Added safeguard against those trying to access extension directly, and an additional parser function usergroup.
Version 1.0
Initial release defined three parser functions, ifright, ifallowed, and userrights.