Extension:Page access restriction

This is a patch to enable page restriction under the MediaWiki software. 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. Other 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 logged in the wiki log. It is also possible to restrict pages or namespaces by providing a regular expression array matching titles, and to restrict new pages by default. Optionally the user's pages can be restricted to their owner. Currently it is localized in English, German, Dutch, Swedish, Catalan, Finnish, Russian, Hebrew, Czech, Spanish and French.

This feature is mainly useful for intranet relying on MediaWiki as a non-encyclopedic content management system, like e-learning platforms or informational systems.

Written by Jej. More information at this site.

Get the patch
Download the patch, how to install, changelog, screenshots and comments here :
 * MediaWiki 1.5.x/1.6.xx
 * MediaWiki 1.4.x (deprecated)


 * MediaWiki 1.7.1 - You can find a (not very well tested) version for MW 1.7.1 here: http://www.zedlitz.de/restriction-beta-0.8.mediawiki-1.7.1.patch
 * Note: This patch seems to be missing the SpecialRestrictedpages.php file. Otherwise it works fine for me --134.91.37.96 16:08, 22 November 2006 (UTC)


 * MediaWiki 1.10.x - I've updated the restriction-beta-0.8 patch to work (mostly) with MW 1.10.0 available here: http://dolio.net/restriction-beta-0.8.mediawiki-1.10.0-v0.1.patch
 * The ./includes/SpecialImagelist.php file is not yet patched properly and edits to restricted pages are visible in the RecentChanges page, but everything else appears to work properly, maybe. --D0li0 02:04, 19 May 2007 (UTC)

Quick summary of what I did to get this running
/**  * 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 ...' */  $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; /**   * MediaWiki permissions setup */  $wgGroupPermissions['restrict']['restrict'] = true; $wgGroupPermissions['restrict']['viewrestrict'] = true; $wgGroupPermissions['viewrestrict']['viewrestrict'] = true;
 * Download the patch from the above site.
 * Add and customize this code to LocalSettings.php

mv restriction-version.mediawiki-version.patch ./mediawiki-version cd ./mediawiki-version patch -p0 < restriction-version.mediawiki-version.patch
 * Apply the patch:

cd ./mediawiki-version chown -R root:apache *
 * If necessary, reassign rights to the files that it patched:

chcon -R -t httpd_sys_content_t *
 * on SELinux you will also have to change the type of the patched files from tmp_t to http_sys_content_t


 * Add users to the restrict and viewrestric groups:

By default nobody is able to restrict page. 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). Here is a FAQ on metawiki.

If $wgUserPageRestrict is true, user pages are restricted to their respective owner, as well as members of the viewrestrict group.

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

How to help

 * You can test, report bugs, and try to find security holes (related to this restrict feature).
 * You can propose ideas, improvements, etc.
 * There is work to do to translate the messages in different languages. The texts to translate are :

'restrict' => 'Restrict', 'restrictthispage' => 'Restrict this page', 'unrestrict'   => 'Unrestrict', 'unrestrictthispage' => 'Unrestrict this page', 'restricttitle' => 'Restricted page', 'restricttext' => 'This page is restricted. To view it you have to be member of the \'restrict\' group or \'viewrestrict\' group.', 'restrictedpages' => 'Restricted pages', 'restrictlogpage' => 'Restriction_log', 'restrictlogtext' => 'Below is a list of page restrictions. See    :Restricted page for more information.', 'restrictedarticle' => 'restricted $1', 'unrestrictedarticle' => 'unrestricted $1', 'restrictsub' => '(Restrict \'$1\')', 'confirmrestrict' => 'Confirm the restriction', 'confirmrestricttext' => 'Do you really want to restrict this page?', 'restrictcomment' => 'Reason for restricting', 'unrestrictsub' => '(Unrestrict \'$1\')', 'confirmunrestricttext' => 'Do you really want to unrestrict this page?', 'confirmunrestrict' => 'Confirm unrestriction', 'unrestrictcomment' => 'Reason for unrestricting', 'restrictreason' => '(give a reason)', 'tooltip-restrict' => 'Restrict this page', 'notallowedtomoverestrictedpagetext' => 'To move this page, you have to be member of the \'restrict\' group.', 'restrictedpagespagetext' => 'This page lists all restricted pages in the wiki. ', 'regexrestrictedpagespagetext' => 'All page titles matching this/these regular expression(s) are also restricted : ',

Have a look in the language file : /languages/MessagesXx.php where Xx is the country/language code. Becareful, the charset is UTF-8. Please work on the last Mediawiki stable version.

Currently available :
 * English
 * French
 * German (thanks to Dr. Walter H. Schreiber)
 * Dutch (thanks to Peter De Baets)
 * Swedish (thanks to Samuel Lampa).
 * Catalan (thanks to Pau Cabot)
 * Finnish (thanks to Tuomas Helin)
 * Russian (thanks to T O X I N)
 * Hebrew (thanks to Yuval Hager)
 * Polish (thanks to Janusz 'Ency' Dorozynski)
 * Czech (thanks to Michal Ciza)
 * Spanish (thanks to Victor Fariña from Queres tecnologias)

You can send your contribs to restrict-mediawiki /at/ conseil-recherche-innovation.net. Please subscribe to the mailing list so I can contact users and contributors easily (restrict-mediawiki-list-subscribe /at/ conseil-recherche-innovation.net).

Inverse Restriction
Replace the isRegexRestricted function in includes/Title.php (version 1.7.1) with the following: function isRegexRestricted { global $wgEnableRestrict, $wgRegexRestrict; if ( $wgEnableRestrict == true ) { foreach ( $wgRegexRestrict as $k=>$v ) { // Reverse restriction START // If an entry starts with "!!" and the remaining string matches the namespace, // the page is NOT restricted if (substr($v, 0, 2) == "!!") { if (ereg (substr($v, 2), $this->makeName( $this->mNamespace, $this->mTextform) ) ) return false; } else // Reverse restriction END if ( ereg ( $v, $this->makeName( $this->mNamespace, $this->mTextform) ) ) return true; }               }                return false; }

You can then get inverse restriction by using this format in LocalSettings.php: $wgRegexRestrict = array("!!Public.*", ".*"); Which makes any pages starting with "Public" non-restricted and all others restricted.

I have included this patch into my restriction patch against MediaWiki 1.7.1: http://www.zedlitz.de/restriction-beta-0.8.1.mediawiki-1.7.1.patch

Todo

 * Texts translation.
 * Images are partialy protected (HTTP access still possible).
 * Being able to define other groups than sysop, bureaucrat : ex. group A of students, group B...
 * Version that works fine with Mediawiki-1.7.XX