2017-03-03

Yaron Koren
moved page Extension:ApprovedRevs to Extension:Approved Revs over redirect Please stop doing this

New page

{{TNT|Extension

|name = Approved Revs

|status = stable

|type1 = hook

|author = [[User:Yaron Koren|Yaron Koren]] <yaron57@gmail.com> and others

|image =

|version = 0.7.3

|update = February 2017

|mediawiki = 1.21 or greater

|license = GPL

|needs-updatephp = yes

|download = {{TNT|WikimediaDownload|ApprovedRevs}}

|changelog =

|hook1 = ArticleDeleteComplete

|hook2 = ArticleEditUpdates

|hook3 = ArticleFromTitle

|hook4 = ArticleViewHeader

|hook5 = BeforeParserFetchTemplateAndtitle

|hook6 = DisplayOldSubtitle

|hook7 = EditPage::showEditForm:initial

|hook8 = LoadExtensionSchemaUpdates

|hook9 = MagicWordwgVariableIDs

|hook10 = OutputPageBodyAttributes

|hook11 = PageContentSaveComplete

|hook12 = PageHistoryBeforeList

|hook13 = PageHistoryLineEnding

|hook14 = ParserBeforeTidy

|hook15 = PersonalUrls

|hook16 = SearchResultInitFromTitle

|hook17 = SkinTemplateNavigation

|hook18 = SkinTemplateTabs

|hook19 = UnknownAction

|hook20 = wgQueryPages

|description = Allows administrators to mark a certain revision of a page as "approved".

|parameters =

|rights = viewlinktolatest, approverevisions

|example =

}}

'''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 [[Extension:FlaggedRevs|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, 15 global variables, 3 log types, 11 special pages and 9 database tables (by contrast, Approved Revs defines 2 user rights, no user groups, 6 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 [[Extension:Cargo|Cargo]], [[Extension:Semantic MediaWiki|Semantic MediaWiki]] and [[Extension:DynamicPageList|DynamicPageList]], will, fortunately, display the correct (i.e., approved) data.

==Download==

You can download the Approved Revs code, in .zip format, [https://github.com/wikimedia/mediawiki-extensions-ApprovedRevs/archive/0.7.3.zip here].

You can also download the code directly via Git from the MediaWiki source code repository. From a command line, you can call the following:

<syntaxhighlight lang="bash">git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ApprovedRevs.git</syntaxhighlight>

To view the code online, including version history for each file, go [https://phabricator.wikimedia.org/diffusion/EARE/browse/master/ here].

{{TNT|SB Extension}}

==Installation==

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

<syntaxhighlight lang="php">require_once( "$IP/extensions/ApprovedRevs/ApprovedRevs.php" );</syntaxhighlight>

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 "[[Manual:Update.php|update.php]]" in MediaWiki's /maintenance directory, or call the SQL directly in your database - you can find it in the file <code>ApprovedRevs.sql</code>.

MediaWiki's text search (i.e., the Special:Search page) will search pages based on the contents of their approved revision, if they have one. However, if you're using MediaWiki 1.19, the ''display'' of search results will still show the page's latest revision. To get this working correctly, you will have to apply a small patch to the core MediaWiki code - you can see it [[Extension:Approved Revs/MediaWiki search patch|here]].

Finally, there are two [[Manual:User rights|user rights]] defined for Approved Revs: '<code>approverevisions</code>' and '<code>viewlinktolatest</code>':

* '<code>approverevisions</code>' is the permission to approve and unapprove revisions of pages. By default it is given to all members of the 'sysop' group.

* '<code>viewlinktolatest</code>' 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, '*').

You can modify the set of users who have either permission. For example, to have the "view most recent revision" link show up only for administrators, you could add the following, below the inclusion of Approved Revs:

<syntaxhighlight lang="php">

$wgGroupPermissions['*']['viewlinktolatest'] = false;

$wgGroupPermissions['sysop']['viewlinktolatest'] = true;

</syntaxhighlight>

==Authors==

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

==Usage==

[[File:Approved Revs history page.png|thumb|550px|right|A history page, with "approve" links, plus a star and an "unapprove" link for the approved revision]]

Once the extension is installed, anyone with the '<code>approverevisions</code>' 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.

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

By default, if a user with '<code>approverevisions</code>' permission makes an edit to a page that already has an approved revision, that edit, i.e. the latest revision of the page, gets automatically marked as approved. By contrast, if a page has no approved revision (this of course includes new pages), automatic approvals will not be applied.

You can eliminate automatic approvals, thus requiring that every approval has to be done manually, by adding the following to <code>LocalSettings.php</code> below the inclusion of Approved Revs:

<syntaxhighlight lang="php">$egApprovedRevsAutomaticApprovals = false;</syntaxhighlight>

Conversely, if you set "<code>$egApprovedRevsBlankIfUnapproved</code>" to true in <code>LocalSettings.php</code> (see below), every edit made by a user with '<code>approverevisions</code>' permission becomes approved - even edits to pages that don't have an approved revision.

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.

===Special:ApprovedRevs page===

Approved Revs defines a special page, "<code>Special:ApprovedRevs</code>" 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.

For the third list, of pages with no approved revision, you can optionally include a link for each page to mark that page's latest revision as approved. To include such links, add the following to <code>LocalSettings.php</code>:

<syntaxhighlight lang="php">$egApprovedRevsShowApproveLatest = true;</syntaxhighlight>

===Storage of approval information===

Information about approvals - who made them, and when they were made - is stored in the "Revision approval" log, which can be viewed at the page Special:Log. Recent approvals are also shown in Special:RecentChanges.

===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 <code>LocalSettings.php</code>, anywhere after the inclusion of Approved Revs:

<syntaxhighlight lang="php">$egApprovedRevsBlankIfUnapproved = true;</syntaxhighlight>

===Indicating unapproved pages===

By default, pages with no approved revision simply show up normally, with no indication of their status. You can have such pages display a message at the top saying, "This is the latest revision of this page; it has no approved revision." To do that, add the following line to <code>LocalSettings.php</code>:

<syntaxhighlight lang="php">$egApprovedRevsShowNotApprovedMessage = true;</syntaxhighlight>

===Setting pages as approvable===

Some wiki pages can have their revisions approved, while others cannot; this is generally determined by namespace. A global variable, <tt>$egApprovedRevsNamespaces</tt>, exists, that determines which namespaces are handled by the extension. This variable is an array, and by default it holds five namespaces: NS_MAIN (the main namespace), NS_USER (user pages), NS_TEMPLATE (templates), NS_HELP (help pages) 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 <code>LocalSettings.php</code>, add something like:

<source lang="php">

$egApprovedRevsNamespaces[] = NS_USER_TALK;

</source>

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 <code>__APPROVEDREVS__ </code>[[Help:Magic words|magic word]] anywhere within the page. It is recommended to add in this magic word to pages via a template. If <code>__APPROVEDREVS__</code> 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.

===Letting non-administrators "own" pages===

Sometimes it's helpful to allow those without the general '<code>approverevisions</code>' permission to be able to approve revisions of certain pages - in other words, to have ownership of certain pages. An obvious example is user pages - it makes sense to allow each user to be able to approve revisions on their own user pages. For namespaces other than "User", you can choose to have the user who originally created any page in that namespace be designated as the page owner, who then has revision-approval permission for that page.

To have this kind of "ownership" for a specific namespace, you need to add the namespace to the variable <code>$egApprovedRevsSelfOwnedNamespaces</code>. To allow users to "own", i.e. be able to approve, pages in the main and user namespaces, for instance, you should add the following to LocalSettings.php:

<source lang="php">

$egApprovedRevsSelfOwnedNamespaces[] = array( NS_MAIN, NS_USER );

</source>

A namespace needs to belong to <code>$egApprovedRevsNamespaces</code> before it can be added to <code>$egApprovedRevsSelfOwnedNamespaces</code>.

===Marking all pages as approved===

For pages that do not yet have an approved revision, you may want to automatically approve their latest revision, as a way to quickly initialize their content. For that, you can use the command line script '<code>ApprovedRevs/maintenance/approveAllPages.php</code>'. This script approves the latest revision of all pages that can be approved but do not have an approved revision.

==Version history==

Approved Revs is currently at version 0.7.3. See the entire [[Extension:Approved Revs/Version history|version history]].

==Known issues==

* Approved Revs does not seem to work with the [[Extension:AccessControl|AccessControl]] extension - approving a revision leads to a "Deny_action" error.

==Contributing to the project==

===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 either do a Git commit for it, or create a patch by going to the "<code>ApprovedRevs</code>" directory, and typing:

git diff > descriptivename.patch

If you create a patch, please send it, with a description, to Yaron Koren.

===Translating===

Translation of Approved Revs is done through [[translatewiki:Main Page|translatewiki.net]]. The translation for this extension can be found [http://translatewiki.net/w/?title=Special:Translate&group=ext-approvedrevs 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 [[translatewiki:Project:Translator|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.

== See also ==

* [[Extension:Moderation]] - edits remain private until they're approved

* [[Extension:FlaggedRevs]] - the more complex alternative to Approved Revs

[[Category:Revision management extensions]]

Show more