This is a MediaWiki Extension. For more information about it, see the documentation in EditOnlyYourOwnPage Extension.
Important! Unless otherwise specified, this extension is released under The MIT License. If you choose to install it, you do so at your own risk and discretion.
/* * EditOnlyYourOwnPage.php - Allows users to edit their own pages. * @author Jim R. Wilson * @version 0.1 * @copyright Copyright (C) 2007 Jim R. Wilson * @license The MIT License - http://www.opensource.org/licenses/mit-license.php * ----------------------------------------------------------------------- * Description: * This is a MediaWiki extension which restricts non-sysop users to only edit * their own pages, talk pages, or subpages thereof regardless of other permissions. * Requirements: * MediaWiki 1.6.x, 1.9.x, 1.10.x or higher * PHP 4.x, 5.x or higher. * Installation: * 1. Drop this script (EditOnlyYourOwnPage.php) in $IP/extensions * Note: $IP is your MediaWiki install dir. * 2. Enable the extension by adding this line to your LocalSettings.php: * require_once('extensions/EditOnlyYourOwnPage.php'); * Version Notes: * version 0.1: * Initial release. * ----------------------------------------------------------------------- * Copyright (c) 2007 Jim R. Wilson * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * ----------------------------------------------------------------------- */ # Confirm MW environment if (defined('MEDIAWIKI')) { # Credits $wgExtensionCredits['other'][] = array( 'name'=>'EditOnlyYourOwnPage', 'author'=>'Jim R. Wilson - wilson.jim.r<at>gmail.com', 'url'=>'http://jimbojw.com/wiki/index.php?title=EditOnlyYourOwnPage', 'description'=>'Prevents users from editing anything other than their own pages.', 'version'=>'0.1' ); # Attach Hook $wgHooks['userCan'][] = 'EditOnlyYourOwnPage'; /** * Allow edit action if user attempts to edit their own page, their own talk page or subpages * Usage: $wgHooks['userCan'][] = 'EditOnlyYourOwnPage'; * @param Title $title Title of the article. (passed by reference) * @param User $user User attempting action on article - presumably $wgUser. (passed by reference) * @param String $action Action being taken on article. (passed by value) * @param Mixed $result The result of processing. (passed by reference) * @return Boolean Always true so other extensions have a chance to process 'userCan' */ function EditOnlyYourOwnPage(&$title, &$user, $action, &$result) { # Check for edit or create action and sysop membership if ( ($action!='edit' && $action!='create') || in_array('sysop', $user->getGroups()) ) return true; # Check for User (or User_Talk) namespace if ( $title->getNamespace()!=NS_USER && $title->getNamespace()!=NS_USER_TALK ) { $result = false; return false; } # Check if the page name matches or starts with the username $name = $user->getName(); $text = $title->getText(); if ( $name==$text || preg_match('/^'.preg_quote($name).'\\//', $text) ) { $result = true; return true; } # User is trying to edit another user's page or talk page $result = false; return false; } } # End MW Environment wrapper //