r45702 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45701‎ | r45702 | r45703 >
Date:14:39, 13 January 2009
Author:daniel
Status:deferred
Tags:
Comment:
allow lockdown of individual actions
Modified paths:
  • /trunk/extensions/Lockdown/Lockdown.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Lockdown/Lockdown.php
@@ -41,8 +41,10 @@
4242
4343 $wgNamespacePermissionLockdown = array();
4444 $wgSpecialPageLockdown = array();
 45+$wgActionLockdown = array();
4546
4647 $wgHooks['userCan'][] = 'lockdownUserCan';
 48+$wgHooks['MediaWikiPerformAction'][] = 'lockdownMediawikiPerformAction';
4749
4850 function lockdownUserCan($title, $user, $action, &$result) {
4951 global $wgNamespacePermissionLockdown, $wgSpecialPageLockdown, $wgWhitelistRead;
@@ -77,11 +79,12 @@
7880 }
7981 else {
8082 $groups = @$wgNamespacePermissionLockdown[$ns][$action];
81 - if (!$groups) $groups = @$wgNamespacePermissionLockdown['*'][$action];
82 - if (!$groups) $groups = @$wgNamespacePermissionLockdown[$ns]['*'];
 83+ if ( $groups === NULL ) $groups = @$wgNamespacePermissionLockdown['*'][$action];
 84+ if ( $groups === NULL ) $groups = @$wgNamespacePermissionLockdown[$ns]['*'];
8385 }
8486
85 - if (!$groups) return true;
 87+ if ( $groups === NULL ) return true;
 88+ if ( count( $groups ) == 0 ) return false;
8689
8790 #print "<br />nsAccessUserCan(".$title->getPrefixedDBkey().", ".$user->getName().", $action)<br />\n";
8891 #print_r($groups);
@@ -106,3 +109,20 @@
107110 }
108111 }
109112
 113+function lockdownMediawikiPerformAction ($output, $article, $title, $user, $request, $wiki) {
 114+ global $wgActionLockdown;
 115+
 116+ $action = $wiki->getVal( 'Action' );
 117+
 118+ if ( !isset( $wgActionLockdown[$action] ) ) return true;
 119+
 120+ $groups = $wgActionLockdown[$action];
 121+ if ( $groups === NULL ) return true;
 122+ if ( count( $groups ) == 0 ) return false;
 123+
 124+ $ugroups = $user->getEffectiveGroups();
 125+ $match = array_intersect($ugroups, $groups);
 126+
 127+ if ( $match ) return true;
 128+ else return false;
 129+}
\ No newline at end of file

Status & tagging log