
Article restriction patch for MediaWiki
---------------------------------------

Here is a patch to enable article restriction under MediaWiki. Pages can be articles or categories. It adds a new |restrict| tab link allowing members of the group ''restrict'' to restrict pages. Users member of the group ''viewrestrict'' can read (and modify) the restricted pages. Others users cannot see, search, export, etc, the restricted pages. You can still |protect| them for editing. A restricted page is distinguished by a red background tab, and you have a special page (Special:Restrictedpages) to list the restricted pages. All restriction/unrestriction actions are loggued in the wiki log. It is also possible to restrict pages by providing a regular expression array matching titles. Optionaly the user's pages can be restricted to their owner. Currently it is localized in English, German, Dutch, Swedish, Finnish, Russian, Hebrew and French.

This feature is mainly useful for intranet relying on WikiMedia as a non-encyclopedic content management system, like e-learning platforms or informational systems. To respect the wiki philosophy, it is not appropriate to use it to restrict public access!

To install restriction-patch, download MediaWiki (do a security backup if you patch your own installation).

- Apply patch :

 mv restriction-version.mediawiki-version.patch ./mediawiki-version
 cd ./mediawiki-version
 patch -p0 < restriction-version.mediawiki-version.patch

- Configure :

Restriction is disabled by default. Add in your ''./LocalSettings.php'' file (below require_once( "includes/DefaultSettings.php" );) :

    /**
    * If true, a new menu action allows to restrict pages access to 'restrict' group users. If false, all previously restricted pages are accessible again.
    */
    $wgEnableRestrict = true;
    
    /**
    * If true, new pages are restricted by default for 'restrict' group users.
    */
    $wgRestrictNewPages = false;
    
    /**
    * If true restrict user pages to their owner (as well as viewrestrict/restrict members)
    */
    $wgUserPageRestrict = false;
    
    /**
    * Regular expression array to restrict matching pages
    * eg. $wgRegexRestrict = array("^Secure:", "^Secret "); // restrict all pages where title is like 'Secure:...' or 'Secret ...'
    * Warning : titles can still be retrieved via the search engine (to be fixed)
    */
    $wgRegexRestrict = array();
    
    /**
     * If true do not add recent changes entry for restricted pages
     */
    $wgNoRecentChangesRestrict = true;
    
    /**
     * If true hide log entries related to restriction, except for 'restrict' or 'viewrestrict' users (Special:Log page)
     */
    $wgHideRestrictLog = true;


Go to the ''User rights management'' page (in special pages) and add users in group ''restrict'' (allow to view and restrict pages) or ''viewrestrict'' (allow only to view restricted pages). If $wgUserPageRestrict is true, user pages are restricted to their respective owner, as well as members of the ''viewrestrict'' group.

Don't write sensible information in page titles, they could be retrieved in some cases. This is beta and GPL, test and feedback welcome !


Jerome Combaz (restrict-mediawiki/at/conseil-recherche-innovation.net)


  Download patch, updates, screenshots and comments here :
  http://conseil-recherche-innovation.net/index.php/1974/04/11/41-restrict-pages-under-mediawiki-15


ChangeLog
---------

Version beta-0.72 for MW 1.6.6/1.6.7/1.6.8 (09-01-2006)
- Spanish translation (thanks to Victor Fariņa from Queres tecnologias)
- Czech translation (thanks to Michal Ciza)

Version beta-0.71 for MW 1.6.6/1.6.7 (07-13-2006)
- Two bugs in Articles.php and Skin.php (thanks to Owen, see http://conseil-recherche-innovation.net/index.php/1974/04/11/41-restrict-pages-under-mediawiki-15#c489)

Version beta-0.70 for MW 1.6.6/1.6.7 (06-06-2006)
- SQL requests are not modified anymore to check the restriction (better sustenability of the patch)
- Now restricted pages and *regex* restricted pages are treated in the same way. So none of pages title should be listed whatever the protection mechanism choosed, nor during a search request
- Regex restriction include the namespace, so it is now possible to restrict whole namespaces (eg. "^Talk:" restrict all talk pages)
- Image partialy restricted (not listed but file accessible via HTTP)
- The SpecialVersion page informs that MW is patched
- Correction of text error on the unrestrict page (thanks to Mathaba)
- Polish translation (thanks to Janusz 'Ency' Dorozynski)

Version beta-0.64 for MW 1.6.3 (05-01-2006)
- Bug when displaying SpecialCategories page (thanks to T O X I N)
- Hebrew translation (thanks to Yuval Hager)
- Bug in OutputPage.php (thanks again to Yuval Hager)

Version beta-0.63 for MW 1.6.3 (04-20-2006)
- Upgrade for 1.6.3 (thanks to Anthony for his help)
- Russian translation (thanks to T O X I N)
- Finnish translation (thanks to Tuomas Helin)

Version beta-0.62 for MW 1.5.5/1.5.6 (02-13-2006) 1.5.7 (03-05-2006)
- Catalan translation (thanks to Pau Cabot)
- Small mistake (comma) in swedish translation

Version beta-0.61 for MW 1.5.5/1.5.6 (01-18-2006)
- Swedish translation (thanks to Samuel Lampa)
- Dutch translation (thanks to Peter De Baets)

Version beta-0.6 for MW 1.5.3 (12-15-2005)
- $wgHideRestrictLog option is back

Version beta-0.59 for MW 1.5.1/1.5.2 (10-31-2005)
- Allow to restrict new pages by default ($wgRestrictNewPages option)
- Bug : 'ArticleProtectComplete' hook function remplaced by 'ArticleRestrictComplete' (stupid mistake !)

Version beta-0.58 for MW 1.5.0 (10-07-2005)
- Restriction by regular expression test on title.
- Bug which avoided to view restricted pages in special pages (only 'restrict' group can see it, not possible to add 'viewrestrict' group) (thanks to Karen O'Flaherty)
- German translation updated (thanks to Hugo Wirz)
- French and english translations updated.
- Bug in Broken Redirects special page SQL request
- Categories special page hide restricted categories for non allowed users
- No more modifications in monobook stylesheet than one style added (see bottom of /skins/monobook/main.css file).

Version beta-0.57 for MW 1.5.0 (09-18-2005)
- Stupid cosmetic bug which avoid patch working if user page restriction enabled (thanks to Christophe Berger)

Version beta-0.56 for MW 1.5.0 (09-11-2005)
- Bug "variables can be passed by reference in [mediawiki]\includes\Article.php on line 1703" with some PHP configurations (thanks to Chunho Lee)

Version beta-0.55 for MW 1.5.0 (09-07-2005)
- First public release for MediaWiki 1.5
