Extension:Approved Revs

Description
Approved Revs is an extension that lets administrators mark a certain revision of a page as "approved". The approved revision is the one displayed when users view the page at its main URL.

Approved Revs was designed to be a simple, lightweight alternative to the FlaggedRevs extension. FlaggedRevs is a very feature-rich, heavy-duty extension that provides not just revision approval but also reviewing and related features; it defines 4 user rights, 3 user groups, 16 global variables, 2 log types, 5 special pages and 8 database tables (by contrast, Approved Revs defines 2 user rights, 3 global variables, 1 log type, 1 special page and 1 database table). If you're running a large-scale wiki like, say, Wikipedia, where the decision of which revision to show as the "official" one has to be made by, or at least accepted by, many people, FlaggedRevs is most likely the right tool to use. However, if you're running a small- or medium-scale wiki, with just a few administrators, Approved Revs may be the more appropriate solution.

Even if a revision is approved, most extensions that retrieve the contents of pages will still get the last revision, and not the approved one (if the two are different). Extensions that get specific data from pages, however, such as Semantic MediaWiki and DPL, will, fortunately, display the correct (i.e., approved) data.

Download
You can download the Approved Revs code in either one of these two compressed files:


 * approved_revs_0.5.3.tar.gz
 * approved_revs_0.5.3.zip

You can also download the code directly via SVN from the MediaWiki source code repository, at http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/ApprovedRevs/. From a command line, you can call the following:

svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/ApprovedRevs/

Installation
To install this extension, create an 'ApprovedRevs' directory (either by extracting a compressed file or downloading via SVN), and place this directory within the main MediaWiki 'extensions' directory. Then, in the file 'LocalSettings.php', add the following line:

You will also need to install a database table for this extension, also called "approved_revs". You can do this in one of two ways: either run the script "update.php" in MediaWiki's /maintenance directory, or call the SQL directly in your database - you can find it in the file ApprovedRevs.sql.

There are two user rights defined for Approved Revs: 'approverevisions' and 'viewlinktolatest':


 * 'approverevisions' is the permission to approve and unapprove revisions of pages. By default it is given to all members of the 'sysops' group.
 * 'viewlinktolatest' is the "permission" to see a note at the top of pages that have an approved revision, explaining that what the user is seeing is not necessarily the latest revision. By default it is given to everyone (i.e, '*').

Authors
Approved Revs was written by Yaron Koren. Important code contributions were also made by Raimond Spekking, Siebrand Mazeland and Jeroen De Dauw.

Usage
Once the extension is installed, anyone with the 'approverevisions' permission will see a link that reads "(approve)" on each row of a page history page. Clicking on that link will set that revision as the approved one. If you then go back to the history page, you will see an "approve" link next to every other revision, along with an "unapprove" link for the approved revision; the approved revision's row will also have a star next to it. Clicking "approve" for any other revision will re-set the approval to that revision; while clicking "unapprove" will mean that there will no longer be an approved revision for this page.

Normally, every time a user with 'approverevisions' permission makes an edit to a page, that edit, i.e. the latest revision of the page, gets automatically marked as approved. This behavior can be overridden, so that every approval has to be done manually, by adding the following to LocalSettings.php below the inclusion of Approved Revs:

Users without 'approverevisions' permission will see nothing special in the history page, other than a star icon on the approved revision's row.

Manual revision approvals and unapprovals get stored in the 'approval' log; though approvals that happen automatically, as a result of someone with approval power editing a page, do not.

Approved Revs defines a special page, "Special:ApprovedRevs" which can show three separate lists: all pages that have an approved revision, all pages whose approved revision is not their latest revision, and all pages that do not have an approved revision.

Displaying unapproved pages as blank
If you want to, you can have pages that have no approved revision show up as blank - users will still be able to see all the revisions if they click on the "history" tab, but the main display will be a blank page. To do that, just add the following line to LocalSettings.php, anywhere after the inclusion of Approved Revs:

Setting pages as approvable
Some wiki pages can have their revisions approved, while others cannot; this is generally determined by namespace. A global variable, $egApprovedRevsNamespaces, exists, that determines which namespaces are handled by the extension (in previous versions of Approved Revs, the variable "$egApprovedRevsExcludedNamespaces" was used instead). This variable is an array, and by default it holds just four namespaces: NS_MAIN (the main namespace), NS_HELP (help pages), NS_TEMPLATE (templates) and NS_PROJECT (the project namespace, which usually has the same name as the wiki). You can add additional namespaces to this set; after the inclusion of Approved Revs in LocalSettings.php, you can add something like: It is not recommended to add the File/Image, Category or MediaWiki namespaces to this array, because, due to their special implementation in MediaWiki, approvals will not work correctly on those pages.

Individual pages not within one of the specified namespaces can also be made approvable, by adding the __APPROVEDREVS__ magic word anywhere within the page. It is recommended to add in this magic word to pages via a template. If __APPROVEDREVS__ is added directly to a page, just be careful not to approve a revision of the page from before that string was added; this could lead to unexpected behavior.

Marking all pages as approved
For pages that do not yet have an approved revision, you may want to automatically mark their approve their latest revision, as a way to quickly initialize the content. A script exists to let you do that: 'approveAllPages.php', in the '/maintenance' directory. If you run this script from the command line, it will go through all pages that are approvable, and do not yet have an approved revision, and mark their latest revision as approved. It should be noted that 'approveAllPages.php' only works with Mediawiki 1.16 and higher.

Version
Approved Revs is currently at version 0.5.3. The version history is:
 * 0.1 - June 24, 2010 - Initial version
 * 0.2 - July 2, 2010 - approveAllPages.php script added; bug fixes
 * 0.3 - July 14, 2010 - $egApprovedRevsExcludedNamespaces changed to $egApprovedRevsNamespaces; __APPROVEDREVS__ magic word added
 * 0.3.1 - August 2, 2010 - approveAllPages.php no longer causes re-parse of pages
 * 0.4 - September 28, 2010 - $egApprovedRevsBlankIfUnapproved added; automatic approval added for edits by users with approval power; Special:UnapprovedPages added; sorting in Special:ApprovedPages fixed
 * 0.4.1 - October 7, 2010 - automatic approval only done if page already has an approved revision, or $egApprovedRevsBlankIfUnapproved is true; "edit" tab now links correctly for non-Vector skins; "edit" (and, when applicable, "edit with form") page show warning if latest revision being edited is not the approved one
 * 0.5 - November 4, 2010 - Special:ApprovedPages and Special:UnapprovedPages merged into one page, Special:ApprovedRevs; $egApprovedRevsAutomaticApprovals added
 * 0.5.1 - November 10, 2010 - Fix in Special:ApprovedRevs for MW <= 1.15
 * 0.5.2 - November 22, 2010 - Fixes for MW 1.17 (automatic approval of latest revision approves correct revision, latest revision gets displayed correctly); fix for pages saved directly by the Semantic Forms extension
 * 0.5.3 - December 15, 2010 - Fix for page "save" with identical content; fix for "blank if unaproved" setting when looking at latest revision; fix for user message display for MW <= 1.15

Bugs and feature requests
Send any bug reports and requests to Yaron Koren, at yaron57 -at- gmail.com.

Contributing patches to the project
If you found some bug and fixed it, or if you wrote code for a new feature, please create a patch by going to the "ApprovedRevs" directory, and typing:

svn diff > descriptivename.patch

Then send this patch, with a description, to Yaron Koren.

Translating
Translation of ApprovedRevs is done through translatewiki.net. The translation for this extension can be found here. To add language values or change existing ones, you should create an account on translatewiki.net, then request permission from the administrators to translate a certain language or languages on this page (this is a very simple process). Once you have permission for a given language, you can log in and add or edit whatever messages you want to in that language.