Extension:UserFunctions
| WARNING: The code or configuration described here poses a major security risk.
Site administrators: You are advised against using it until this security issue is resolved. Problem: These functions can be used to leak some of your user's personal data like e-mail address and real name in case $wgUFEnablePersonalDataFunctions is set to true (disabled by default). Solution: If unsure, don't activate personal data functions. --Wikinaut 20:56, 11 June 2011 (UTC) |
|
UserFunctions Release status: beta |
|||
|---|---|---|---|
| Implementation | Parser function | ||
| Description | Provides a set of dynamic parser functions that trigger on the current user | ||
| Author(s) | Algorithm, Toniher and others | ||
| Last version | 2.4.2 (2013-04-08) | ||
| MediaWiki | 1.12 + | ||
| Database changes | no | ||
| License | GPLv2 + | ||
| Download |
CHANGELOG |
||
|
|||
|
|||
| Check usage and version matrix | |||
The UserFunctions extension provides a set of dynamic parser functions that trigger on the current user.
Contents |
Usage [edit]
{{#ifanon:then|else}}- Tests whether the current user is anonymous.{{#ifblocked:then|else}}- Tests whether the current user is blocked.{{#ifsysop:then|else}}- Tests whether the current user is a sysop.{{#ifingroup:group|then|else}}- Tests whether the current user is a member of the group "group". You can check for multiple groups as well:{{#ifingroup:group1, group2, group3|then|else}}{{#realname:alt}}- Returns the current user's real name. If the user is not logged in, this function returns the given alternate text, or the user IP if no alternate is provided.{{#username:alt}}- Returns the current username. If the user is not logged in, this function returns the given alternate text, or the user IP if no alternate is provided.{{#useremail:alt}}- Returns the current user's e-mail address. If the user is not logged in, this function returns the given alternate text, or the user IP if no alternate is provided.{{#nickname:alt}}- Returns the current user's nickname. If the user has no nickname, returns the username. If the user is not logged in, this function returns the given alternate text, or the user IP if no alternate is provided.{{#ip:}}- Returns the current user's IP address.
By default the personal data functions #realname, #username, #useremail, #nickname and #ip are disabled. See here to see how to enable them.
By default functions are only enabled in NS_MEDIAWIKI namespace, for enabling them in other namespaces, check out the examples below.
Installation [edit]
- Download the files from Git with
orgit clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/UserFunctions.git
download a snapshot - Place the files under
$IP/extensions/UserFunctions - Add to the end of LocalSettings.php:
require_once("$IP/extensions/UserFunctions/UserFunctions.php");
- If you want to use the following functions:
#realname, #username, #useremail, #nickname, #ip, add:just after that line.$wgUFEnablePersonalDataFunctions = true;
- If you want to enable functions in other namespaces apart from
NS_MEDIAWIKI(default), follow the model of some of the examples below. - Installation can now be verified through Special:Version on your wiki
Allowing namespaces [edit]
By default, user functions only work in NS_MEDIAWIKI namespace.
Below there are some examples of allowing or disallowing the functions to work in other namespaces. The syntax is based on the one used with subpages.
# Enable UserFunctions in Main Namespace $wgUFAllowedNamespaces[NS_MAIN] = true;
# User Functions enabled in User Mainspace, but not in Main one. $wgUFAllowedNamespaces = array( NS_MAIN => false, NS_USER => true );
# Enable all User Functions in all NS numbered from 0 to 200 $wgUFAllowedNamespaces = array_fill(0, 200, true);
More info on namespace numbering.
In other contexts (recognized as NS -1, but not always a Special Page), such as in Semantic Forms pages, check you have the following parameter enabled:
$wgUFEnableSpecialContexts = true;
The parameter above is enabled by default.
If you experience any problem with bots or maintenance scripts, turn it to false and report it to this talk page.
Version history [edit]
Authors: Algorithm and others
- Version 2.4.2 (April 08, 2013) Some code cleaning by Reedy
- Version 2.4.1 (July 17, 2012) Fixed problems with Sidebar (report Kghbln). Cleared PHP warnings in functions - Toniher
- Version 2.4 (June 2, 2012) Cleaned using current ParserFunctions models. Fix when editing Semantic Forms - Toniher
- Version 2.3 (May 27, 2012) fixed problems when using scripts and allowed multiple groups to be checked against in ifingroup. - Toniher
- Version 2.2 (January 03, 2012) added $wgUFAllowedNamespaces parameter. Users need to define in which allowed NS functions will work. - Toniher
- Version 2.1 (December 21, 2011) added $wgUFEnablePersonalDataFunctions parameter. Migrated $wgUser to ParserOptions equivalent - Toniher
- Version 2.0 (December 13, 2011) added i18n and compatibility with other parser function extensions - Toniher
- Version 1.5 (October 30, 2011) added ip - Kghbln
- Version 1.4 (September 27, 2011) added realname - Kghbln
- Version 1.3 (February 13, 2010) added useremail - Wikinaut
- Version 1.2 (July 25, 2008) added ifingroup - Louperivois
- Version 1.1 (June 27, 2008) added nickname - Lexw
- Version 1.0 (May 21, 2006) - Algorithm