Extension:MGet

From Mario Fan Games Galaxy Wiki
Revision as of 16:18, 20 August 2010 by Kyori (talk | contribs)

Template:Notice

 Blue!box.gif Under Development

This extension is heavily under development and drastic changes could take place at any point in the near future. Information shown is therefore liable to frequent change.


MFGG User Get is a Mediawiki extension written by Kyori and Char. It adds several magic words that are used to automatically update user information on the MFGG Wiki using data from the MFGG Forums.

These magic words are used in the new MFGGer template, so it is no longer necessary to specify, or update, the badges or groups that a user currently has.

Usage

This section explains how to use each individual magic word. To omit an optional parameter, leave the section blank. If you wish to omit all optional parameters (or all after an optional parameter), you do not need to include the unneeded sections at all. For example:

{{#badges:43||{{#order:4>2}}}}      //is valid
{{#badges:43}}                      //as is this
{{#badges:43|{{#groupbadges:4=3}}}} //and this

#groups

The groups magic word pulls all of the groups that a particular user has. The usage is as follows:

{{#groups:forum_id|[optional:group_order]|[optional:FLAG]}}

Flags

The groups magic word has flags that can be used to specify which groups to return. These are:

  • FIRSTONLY - only returns the group that would have been displayed first in the list.
  • ALLBUTFIRST - returns all of the groups aside from the group that would have been displayed first in the list.

The usage for the flags is as follows:

{{#groups:756||FIRSTONLY}}

In this example, only the first group of user 756 would be returned (the list has also not been ordered, due to the omission of the group order parameter).

#badges

The badges magic word pulls all of the badges that a particular user has. It has 2 optional parameters, as well as requiring the forum ID of the user.

The usage for badges is as follows:

{{#badges:forumid|[optional:groupbadges]|[optional:badgeorder]}}

There is no need to provide a mainsite ID; if the forum account has been linked with the mainsite, things like submitter badges will be automatically added to the forum badge table.

It should be noted that due to the probable long life of the cache (2-4 hours), badges may not display when you first use the magic word if there is no information in the cache related to the user ID that you are using. However, you can be confident in the fact that as soon as the cache expires and badges are viewed, all requested badges will be updated.

#groupbadges

The groupbadges magic word is used to parse a correctly formatted string into an array and then serialize it for use with the badges magic word to add group specific badges to a users badge list. Examples of this are

Badge mod.png

and

Badge sysop.png

. The syntax for this magic word is as follows:

{{#groupbadges:groupid1=badgeid4,groupid2=badgeid15,groupid6=badgeid22=DEFAULTONLY}}

In this case, if the user was in groupid1 (i.e. a group with the id "groupid1") he would recieve badgeid4, the same case with groupid2 and badgeid15. However, even if the user was in groupid6, if groupid6 is not set as their primary group, they will not recieve badgeid22. The DEFAULTONLY flag sets the badge to only be available to those members which have the relevant group set as their primary (or "default") group.

#order

The order magic word is used to parse a correctly formatted string into an array and then serialize it for use with both the badges and groups magic words to order their results. The syntax is as follows:

{{#order: id1 > id2 > id4 > id3}}

In this example, if the user had badges/was in groups with IDs id1, id3 and id4; they would be displayed in the order id1, id4, id3. If there were additional badges/groups that were not mentioned using the order keyword, they would be appended to the end of the ordered badges/groups.

Method

When the extension is called, it checks whether the cache has expired (the cache lifetime is specified with $wgMFGGBadgesCacheTime).

  • If the cache hasn't expired, the extension adds the requested user ID to a cached list of user IDs.
  • If the cache has expired, the extension makes a POST request containing an array of the previously cached user IDs to a script in the forum directory, which then queries the database for the information for those users. The script returns the information and the extension caches it in a local file.

The script then sorts through the information (either from the cache or from a request) and finds the requested user information, then returns them in the correct template format.

For badges:

{{Badge|id|count|auto=true}}

For groups:

{{MemberType|id|auto=true}}

Note: auto is set to true so that the templates know to run specific formatting on the results.

Configuration Variables

These are the various settings that can be modified in LocalSettings.php.

# Address of the forum badge get script
$wgMFGGBadgesReadFileAddress;
# Number of seconds that the cache should live for (set to 4 hours (14400 seconds) by default)
$wgMFGGBadgesCacheTime;
# Security code to be provided to the forum script
$wgMFGGBadgesSecurityCode;

CACHE EMPTY

This message will display in place of the group information if the cache has no data on that particular user. It is formatted as following:

CACHE EMPTY
1 h 23 m 56 s
Time until recache.

In this example, the extension will recache (request all needed information from the forum server, and cache it) in 1 hour, 23 minutes and 56 seconds.

Version Log

  • v0.0.1 - Not in general usage due to being just a little bit buggy!
  • v0.1.0 - Badges and groups working.
    • v0.1.1 - Changed "error" message for empty cache to display time to recache.
    • v0.1.2 - Wiki caching disabled for pages using the extension, bug with default groups on Guinea, Char and Kyori articles (not fixed).