permissionstyles plugin by Gabriel Birke
Include different stylesheets depending on the groups a user is in.
Last updated on 2008-01-30. Provides Action.
No compatibility info given!
If you want to hide some elements from users which are not in the admin group, if you want different backgrounds for different company departments—this plugin is for you. Just install it and put css files into the lib/styles/ folder that follow the convention of group_groupname.css, for example group_admin.css .
/** * Permission Styles: Include different stylesheets depending on the groups a user is in. * * @author Gabriel Birke <birke@d-scribe.de> */ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_permissionstyles extends DokuWiki_Action_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Gabriel Birke', 'email' => '<birke@d-scribe.de', 'date' => '2008-01-30', 'name' => 'Action Plugin Permission Styles', 'desc' => 'Include different stylesheets depending on the groups a user is in.', 'url' => 'http://www.d-scribe.de', ); } /** * Register its handlers with the dokuwiki's event controller */ function register(&$controller) { $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, '_includeStylesheets'); } /** * Look for group_*.css files in lib/styles/. * Include the stylesheets for the group where the user is a member. */ function _includeStylesheets(&$event, $param) { global $conf; $auth_class = 'auth_'.$conf['authtype']; $auth = new $auth_class(); $userdata = $auth->getUserData($_SERVER['REMOTE_USER']); if(empty($userdata) || empty($userdata['grps'])) return; foreach($userdata['grps'] as $group) { $file = 'lib/styles/group_'.$group.'.css'; if(file_exists(DOKU_INC.$file)) { $event->data['link'][] = array ( 'rel' => 'stylesheet', 'type' => 'text/css', 'href' => DOKU_BASE.$file ); } } } }