Fandom

Wikia Developers Wiki

UserRightsRecord

869pages on
this wiki
Add New Page
Talk0 Share

The UserRightsRecord script generates a list of all users who have been members of rights groups on a wiki, with the dates they received and lost the rights, and how long they held them. It can be customized in several ways. Note that the default output of this script can be missing dates due to software errors and hidden log entries.

Installation

Add this JavaScript on your wiki:

Global Personal Site-wide
w:Special:Mypage/global.js Special:Mypage/common.js MediaWiki:Common.js
importArticles({
    type: 'script',
    articles: [
        'u:dev:UserRightsRecord/code.js'
    ]
});
importArticles — Best Practices for installing JavaScript on Fandom
The importArticles statement is designed to combine multiple HTTP requests into a single data transfer, allowing multiple scripts to load and execute faster. If you've been installing several different scripts, your JavaScript file has probably accumulated unnecessary import statements. Click "Expand" to learn how to efficiently batch import scripts to speed up performance and make your code look cleaner. One other approach is by using the MediaWiki:ImportJS.
If your JavaScript file has several lines of code that say importScript, importScriptPage, or importArticles, you may be able to combine them! By batch importing a collection of scripts with a single import, your JavaScript code will load faster and look cleaner. Consider the example below. On the left is an example of what your JavaScript file might currently look like. On the right is how you could improve that code.
Multiple imports — messy and slow One import — clean and efficient
importScriptPage('AjaxRC/code.js','dev');
 
importScript('MediaWiki:localScript.js');
 
importArticle({
  type: 'script',
  article: 'u:dev:FloatingToc/code.js'
});
 
importScriptPage('page1.js', 'wikiname');
 
importScriptPage('page2.js', 'wikiname');
importArticles({
    type: 'script',
    articles: [
        'u:dev:AjaxRC/code.js',
        'MediaWiki:localScript.js',
        'u:dev:FloatingToc/code.js',
        'u:wikiname:page1.js',
        'u:wikiname:page2.js'
    ]
});
Note: In this example, pay close attention to the placement of commas and other punctuation. For people who aren't familiar with programming (and even those who are!), a common mistake when writing code is to accidentally delete, forget, or misplace critical symbols like commas or quotation marks. This can cause a syntax error that breaks the code. Carefully follow the convention shown here when using importArticles.
But there's much more to importArticles than just this! For more examples and advanced usage, see the help page at Help:Including additional JavaScript and CSS.


Usage

To use the script with default behavior (listing all results in all groups for all time), simply place an element with the rightsrecord class on a page after importing the script. This can be used multiple times per page. Anything within the div is overwritten when the script runs.

<div class="rightsrecord"></div>

Here is a skeleton with placeholders for all of the available parameters, which are explained below. (As written, this code will still act like the default.)

<div class="rightsrecord" data-urr-mode="rights" data-urr-exclude="" data-urr-start="" data-urr-end="" data-urr-user="" data-urr-daymin="1" data-urr-showdays="true" data-urr-onlyknown="false" data-urr-onlypast="false">{"Username1":"Username2", "User3":"User4", "Baduser":null}</div>

mode

The default mode is rights, which separates the list by group and places a table of contents at the top of the div. Setting the value to users separates the list by user instead, with no TOC.

exclude

This allows exclusion of specific user groups from the list. Use the name of the group as it appears in the unlimited script output. Specify multiple groups to exclude like this: data-urr-exclude="group1, group2, group3".

start/end

Allows specifying dates to start and/or end going through the rights log; rights changes that occurred before/after these dates, respectively, will not be included. These must be fully formatted dates in UTC, e.g. "2013-01-01T23:59:00Z". Both do not have to be specified at once, but end has to be after start. Note that use of these parameters will likely cause inaccurate statement of "unknown" and "present" in the list.

user

Allows specifying a single user for whom to display records. Must have "User:" prefix.

daymin

Specifies a minimum duration, in days, required for an entry to be listed. The default is 1.

showdays

Set this to "false" to hide the days duration for each rights entry, or set it to "divided" to separate the day counts into years, months, and days (note that this is increasingly inaccurate over longer periods of time). This will not affect other options.

onlyknown

Set this to "true" to hide entries for which the start date is unknown.

onlypast

Set this to "true" to hide entries who still have the rights.

name changes

You can specify a list of users who changed their names so that each user's entries are grouped under the same name in the output. This is done by putting JSON syntax as the content of the div, as seen in the example above. Each key's value (the data to the right of the colon) is the username that should be displayed, or null (without quotes) to remove that user from the listing. You can have multiple keys with the same value. This must be valid JSON: all values (except null) are enclosed with double quotes ("), keys are separated from values with colons (:), pairs are delimited by commas (,), and the whole thing is surrounded by braces ({ }). Quotation marks within user names must be escaped with a backslash (\").

Notes

Please leave a message on my talk page or that of the script with any bug reports or suggestions!

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.