r47553 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47552‎ | r47553 | r47554 >
Date:14:02, 20 February 2009
Author:catrope
Status:deferred
Tags:
Comment:
EditOwn: Add $wgEditOwnActions, which makes it possible to extend EditOwn's restrictions to actions other than edit. For instance, to allow users to delete only their own pages, use $wgEditOwnActions[] = 'delete';
Modified paths:
  • /trunk/extensions/EditOwn/EditOwn.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EditOwn/EditOwn.php
@@ -38,16 +38,18 @@
3939 $wgHooks['userCan'][] = 'EditOwn';
4040
4141 $wgEditOwnExcludedNamespaces = array();
 42+$wgEditOwnActions = array('edit');
4243
4344 function EditOwn($title, $user, $action, &$result)
4445 {
4546 static $cache = array();
46 - global $wgEditOwnExcludedNamespaces;
 47+ global $wgEditOwnExcludedNamespaces, $wgEditOwnActions;
4748 if(!is_array($wgEditOwnExcludedNamespaces))
4849 // Prevent PHP from whining
4950 $wgEditOwnExcludedNamespaces = array();
5051
51 - if($action != 'edit' || $user->isAllowed('editall') ||
 52+ if(!in_array($action, $wgEditOwnActions) ||
 53+ $user->isAllowed('editall')||
5254 in_array($title->getNamespace(), $wgEditOwnExcludedNamespaces))
5355 {
5456 $result = null;
@@ -65,7 +67,7 @@
6668 $dbr = wfGetDb(DB_SLAVE);
6769 $res = $dbr->select('revision', Revision::selectFields(),
6870 array('rev_page' => $title->getArticleId()),
69 - __METHOD__, array('ORDER BY' => 'rev_timestamp ASC',
 71+ __METHOD__, array('ORDER BY' => 'rev_timestamp',
7072 'LIMIT' => 1));
7173 $row = $dbr->fetchObject($res);
7274 if(!$row)

Follow-up revisions

RevisionCommit summaryAuthorDate
r47557EditOwn: Update CHANGELOG for r47553catrope14:20, 20 February 2009

Status & tagging log