r62507 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62506‎ | r62507 | r62508 >
Date:09:56, 15 February 2010
Author:lhridley
Status:deferred
Tags:
Comment:
Adding UserPageEditProtection extension to repository
Modified paths:
  • /trunk/extensions/UserPageEditProtection (added) (history)
  • /trunk/extensions/UserPageEditProtection/UserPageEditProtection.php (added) (history)

Diff [purge]

Index: trunk/extensions/UserPageEditProtection/UserPageEditProtection.php
@@ -0,0 +1,76 @@
 2+<?php
 3+if(! defined( 'MEDIAWIKI' ) ) {
 4+ echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" );
 5+ die( -1 );
 6+}
 7+/**
 8+ * Extension: UserPageEditProtection.php
 9+ * Created: 6 December 2007
 10+ * Author: Lisa Ridley, Eric Gingell
 11+ * Version: 2.0
 12+ * Copyright (C) 2007 Lisa Ridley
 13+ *
 14+ * This program is free software; you can redistribute it and/or modify
 15+ * it under the terms of the GNU General Public License as published by
 16+ * the Free Software Foundation; either version 2 of the License, or
 17+ * (at your option) any later version.
 18+ *
 19+ * This program is distributed in the hope that it will be useful,
 20+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 21+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 22+ * GNU General Public License for more details.
 23+ *
 24+ * You can find a copy of the GNU General Public License at http://www.gnu.org/copyleft/gpl.html
 25+ * A paper copy can be obtained by writing to: Free Software Foundation, Inc.,
 26+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 27+ *
 28+ * User Page Edit Protection
 29+ *
 30+ * Provides User Page Edit Protection to limit user page edits to User and to sysops.
 31+ *
 32+ *
 33+ * Usage:
 34+ * Save this file in your extensions folder of your MediaWiki installation. Add the following to LocalSettings.php:
 35+ * //turn on user page protection
 36+ * $wgOnlyUserEditUserPage = true;
 37+ * //allow sysops to edit user pages by adding the following setting
 38+ * $wgGroupPermissions['sysop']['editalluserpages'] = true;
 39+ * require_once('extensions/UserPageEditProtection.php');
 40+ **/
 41+
 42+/* register extension */
 43+$wgExtensionCredits['other'][] = array(
 44+ 'name' => 'UserPageEditProtection',
 45+ 'author' => 'Lisa Ridley, Eric Gingell',
 46+ 'version' => '2.0',
 47+ 'url' => 'http://www.mediawiki.org/wiki/Extension:UserPageEditProtection',
 48+ 'description' => 'This Extension restricts editing on user pages to User and allowed editors');
 49+
 50+/* use the userCan hook to check user page edit permissions */
 51+$wgHooks[ 'userCan' ][] = 'fnUserPageEditProtection';
 52+
 53+function fnUserPageEditProtection( $title, $user, $action, &$result ) {
 54+ global $wgOnlyUserEditUserPage;
 55+ $lTitle = explode('/', $title->getText());
 56+ if (!($action == 'edit'||$action == 'move')) {
 57+ $result = null;
 58+ return true;
 59+ }
 60+ if (NS_USER !== $title->mNamespace) {
 61+ $result = null;
 62+ return true;
 63+ }
 64+ if ($wgOnlyUserEditUserPage) {
 65+ if ($user->isAllowed('editalluserpages') || ($lTitle[0] == $user->getname())) {
 66+ $result = null;
 67+ return true;
 68+ } else {
 69+ $result = false;
 70+ return false;
 71+ }
 72+ }
 73+ $result = null;
 74+ return true;
 75+
 76+}
 77+
Property changes on: trunk/extensions/UserPageEditProtection/UserPageEditProtection.php
___________________________________________________________________
Added: svn:eol-style
178 + native

Status & tagging log