r96461 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96460‎ | r96461 | r96462 >
Date:17:56, 7 September 2011
Author:ashley
Status:deferred
Tags:
Comment:
putting this quick hack in SVN so that it won't get lost
Modified paths:
  • /trunk/extensions/LockDownEnglishPages (added) (history)
  • /trunk/extensions/LockDownEnglishPages/LockDownEnglishPages.php (added) (history)

Diff [purge]

Index: trunk/extensions/LockDownEnglishPages/LockDownEnglishPages.php
@@ -0,0 +1,50 @@
 2+<?php
 3+/**
 4+ * LockDownEnglishPages -- prevents non-staff users from editing the English
 5+ * interface messages on the Inteface Messages Wiki
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ * @version 0.1
 10+ * @date 6 July 2011
 11+ * @author Jack Phoenix <jack@countervandalism.net>
 12+ * @license http://en.wikipedia.org/wiki/Public_domain Public domain
 13+ * @see http://bugzilla.shoutwiki.com/show_bug.cgi?id=54
 14+ */
 15+
 16+if ( !defined( 'MEDIAWIKI' ) ) {
 17+ die();
 18+}
 19+
 20+// Extension credits that will show up on Special:Version
 21+$wgExtensionCredits['other'][] = array(
 22+ 'name' => 'Lock Down English Pages',
 23+ 'version' => '0.1',
 24+ 'author' => 'Jack Phoenix',
 25+ 'description' => 'Prevents non-staff users from editing the English interface messages',
 26+ 'url' => 'http://www.mediawiki.org/wiki/Extension:LockDownEnglishPages',
 27+);
 28+
 29+$wgHooks['userCan'][] = 'wfLockDownEnglishPages';
 30+function wfLockDownEnglishPages( &$title, &$user, $action, &$result ) {
 31+ // We want to prevent editing of MediaWiki pages for users who have the
 32+ // editinterface right but who are not staff when the action is 'edit'
 33+ if (
 34+ $title->getNamespace() == NS_MEDIAWIKI &&
 35+ $user->isAllowed( 'editinterface' ) &&
 36+ !in_array( 'staff', $user->getEffectiveGroups() ) &&
 37+ $action == 'edit'
 38+ )
 39+ {
 40+ $pageTitle = $title->getDBkey();
 41+ if (
 42+ preg_match( '/\/en/', $pageTitle ) || // page title has /en in it
 43+ !preg_match( '/\//', $pageTitle ) // page title has no / in it
 44+ )
 45+ {
 46+ $result = false;
 47+ return false;
 48+ }
 49+ }
 50+ return true;
 51+}
\ No newline at end of file
Property changes on: trunk/extensions/LockDownEnglishPages/LockDownEnglishPages.php
___________________________________________________________________
Added: svn:eol-style
152 + native

Status & tagging log