Extension:FlaggedRevs/Restricting unapproved revisions

This page describes how to only give read access to the stable versions of articles to anonymous users for MediaWiki 1.17+.

Basic idea
This approach works as follows: The details to do this are described in the next few sections.
 * (i) Make all pages unreadable and uneditable by non-users (that is, readable only for users)
 * (ii) But make the stable version of pages an exception in that they are readable to non-users

Making the site readable only by users
See Manual:Preventing_access and Manual:Preventing_access

Add these lines to your LocalSettings.php file:

Adding stable version as exemption for non-users
Add the following to LocalSettings.php:

is an array of user groups. Setting it to  will let all visitors be able to see the stable version of pages. Setting it to  will make the stable versions visible to users in the group 'supergroup'.

You also don't have to use these global variables and can just hard code whatever is needed into the efFlaggedRevsHooks_userCanView function mentioned below.

MediaWiki >= 1.19
Add the following code to localsettings.php (or an appropriate custom start-up config file): ...and then define the following function:

MediaWiki <= 1.18
Add the following code to localsettings.php (or an appropriate custom start-up config file): ...and then define the following function:

Caveats

 * This does not work well with img_auth.php, as non-user viewers will not be able to see images. You will probably just want to leave images public but under hashed directories to make them harder to find. This is acceptable if there are no private files and the main concern is just not to release unverified content.
 * The search index is still based on the current version of pages, but only results for pages with stable versions are displayed at Special:Search. If a stable version is out of date then unreviewed content for that page becomes theoretically discoverable by brute force searching.
 * This will probably be useless without having.
 * Make sure that  is set properly. You will at least want something like  . You may also want visible directory or category pages. Otherwise, the wiki will be hard to browse for readers.
 * You will probably want to edit MediaWiki:loginreqpagetext to make it more detailed. It will come up in various situations and thus should explain the approval system setup.

hacking DifferenceEngine
the approach described above works quite well - however, it doesn't seem possible to give anonymous users write access to wiki pages anymore.

basic idea
to solve this issue, i resorted to  and decided to change mediawikis view history-facility, which is being used to show non-reviewed changes of a page. in its default version, it doesn't care about restrictions defined by the flaggedrevs-configuration - ie., all users are able to see non-reviewed changes by clicking on either the view history or Pending changes-tabs of a page.

implementation
mediawiki does not seem to have a hook which can be used to override the display of the version history of a page - therefore, i had to hack mediawikis built-in DifferenceEngine class. the diff below applies to mediawiki 1.20.3, ymmv … this seems to do what it is supposed to do … i haven't yet a clue about performance issues caused by this hack, nor do i know if it is possible to sidestep this. it probably is.

please also note that i'm not a php programmer by profession :-) thoralf_schulze@yahoo.de