1<?php 2/** 3 * DokuWiki Plugin disableactionsbygroup (Action Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Andreas Hansson 7 */ 8 9// must be run within Dokuwiki 10if (!defined('DOKU_INC')) die(); 11 12if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); 13if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); 14if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15 16require_once DOKU_PLUGIN.'action.php'; 17 18class action_plugin_disableactionsbygroup extends DokuWiki_Action_Plugin { 19 20 public function register(Doku_Event_Handler &$controller) { 21 $controller->register_hook('AUTH_LOGIN_CHECK', 'AFTER', $this, 'handle_post_login'); 22 } 23 24 public function handle_post_login(Doku_Event &$event, $param) { 25 global $conf; 26 global $USERINFO; 27 28 // If authentication failed 29 if(!$event->result) 30 // Handle settings for ALL users (non logged in) 31 $this->disablebygroupids(array('ALL')); 32 return; 33 // Handle settings for logged in users 34 $this->disablebygroupids($USERINFO['grps']); 35 } 36 37 private function disablebygroupids($groupids) { 38 global $conf; 39 // Check denyactionsbygroup to see if the user is in any matching group 40 $actionsbygroup = explode(';',$this->getConf('disableactionsbygroup')); 41 foreach($actionsbygroup as $groupandactions) { 42 list($group, $action) = explode(":", $groupandactions); 43 foreach((array)$groupids as $membergroup) { 44 if($membergroup == $group) { 45 $conf['disableactions'] = $action; 46 break 2; 47 } 48 } 49 } 50 } 51} 52 53// vim:ts=4:sw=4:et: 54