* @copyright Copyright (C) 2002-2005 Markus Westphal, * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, * 2010-2012 Uwe Steinmann * @version Release: @package_version@ */ /** * Include parent class */ //require_once("class.Bootstrap.php"); /** * Class which outputs the html page for Acl view * * @category DMS * @package SeedDMS * @author Uwe Steinmann * @copyright Copyright (C) 2016 Uwe Steinmann * @version Release: @package_version@ */ class SeedDMS_View_Acl extends SeedDMS_Theme_Style { function js() { /* {{{ */ $selrole = $this->params['selrole']; header('Content-Type: application/javascript'); ?> $('#acostree').tree({ autoOpen: 0, saveState: 'acostreegetID() : ''); ?>', openedIcon: $(''), closedIcon: $(''), onCreateLi: function(node, $li) { switch(node.permission) { case -1: $li.find('.jqtree-element span:last-child').after(' '); $li.attr('style', 'background-color:#FDD'); break; case 1: $li.find('.jqtree-element span:last-child').after(' '); $li.attr('style', 'background-color:#DFD'); break; default: $li.find('.jqtree-element span:last-child').after(''); } } }); $('#acostree').on('click', '.jqtree-toggle-permission', function(event) { acoid = $(event.target).parent().attr('data-acoid'); aroid = $(event.target).parent().attr('data-aroid'); $.ajax('../op/op.Acl.php?action=toggle_permission&acoid='+acoid+'&aroid='+aroid, { dataType: 'json', success: function(data, textStatus) { if(data.type == 'success') { timeout = 1500; $('#acostree').tree('loadDataFromUrl'); } else { timeout = 3500; } noty({text: data.msg, type: data.type, dismissQueue: true, layout: 'topRight', theme: 'defaultTheme', timeout: timeout}); }, }); }); $('#acostree').on('click', '.jqtree-add-permission', function(event) { acoid = $(event.target).parent().attr('data-acoid'); aroid = $(event.target).parent().attr('data-aroid'); $.ajax('../op/op.Acl.php?action=add_permission&acoid='+acoid+'&aroid='+aroid, { dataType: 'json', success: function(data, textStatus) { if(data.type == 'success') { timeout = 1500; $('#acostree').tree('loadDataFromUrl'); } else { timeout = 3500; } noty({text: data.msg, type: data.type, dismissQueue: true, layout: 'topRight', theme: 'defaultTheme', timeout: timeout}); }, }); }); $('#acostree').on('click', '.jqtree-remove-permission', function(event) { acoid = $(event.currentTarget).attr('data-acoid'); aroid = $(event.currentTarget).attr('data-aroid'); $.ajax('../op/op.Acl.php?action=remove_permission&acoid='+acoid+'&aroid='+aroid, { dataType: 'json', success: function(data, textStatus) { if(data.type == 'success') { timeout = 1500; $('#acostree').tree('loadDataFromUrl'); } else { timeout = 3500; } noty({text: data.msg, type: data.type, dismissQueue: true, layout: 'topRight', theme: 'defaultTheme', timeout: timeout}); }, }); }); $('#add_aro').on('click', function(event) { roleid = $(event.currentTarget).attr('data-roleid'); $.ajax('../op/op.Acl.php?action=add_aro&roleid='+roleid, { dataType: 'json', success: function(data, textStatus) { if(data.type == 'success') { timeout = 1500; window.location='out.Acl.php?action=show&roleid=' + roleid; } else { timeout = 3500; } noty({text: data.msg, type: data.type, dismissQueue: true, layout: 'topRight', theme: 'defaultTheme', timeout: timeout}); }, }); }); $(document).ready( function() { $( "#selector" ).change(function() { window.location='out.Acl.php?action=show&roleid=' + $(this).val(); // $('#acostree').tree({dataUrl: 'out.Acl.php?action=tree&roleid=' + $(this).val()}); }); }); params['dms']; $user = $this->params['user']; $selrole = $this->params['selrole']; $accessobject = $this->params['accessobject']; if($selrole) { $this->contentHeading(getMLText("role_info")); $users = $selrole->getUsers(); if($users) { echo ""; foreach($users as $currUser) { echo ""; echo ""; echo ""; echo ""; } echo "
".getMLText('name')."
"; echo htmlspecialchars($currUser->getFullName())." (".htmlspecialchars($currUser->getLogin()).")"; echo "
getEmail())."\">".htmlspecialchars($currUser->getEmail()).""; if($currUser->getComment()) echo "
".htmlspecialchars($currUser->getComment()).""; echo "
"; if($accessobject->check_view_access(array('UsrMgr', 'RemoveUser'))) { echo "
"; if($accessobject->check_view_access('UsrMgr')) echo "getID()."\"> "; if($accessobject->check_view_access('RemoveUser')) echo "getID()."\">"; echo "
"; } echo "
"; } } } /* }}} */ /** * Show tree of acos * */ private function _tree($aro=null, $aco=null) { /* {{{ */ $children = array(); $tchildren = $aco->getChildren(); if($tchildren) { foreach($tchildren as $child) { $node = array(); if(false === ($perm = $child->getPermission($aro))) $node['permission'] = 0; else $node['permission'] = $perm; $node['id'] = $child->getID(); $node['label'] = $child->getAlias(); $node['acoid'] = $child->getID(); $node['aroid'] = $aro ? $aro->getID() : 0; $nchildren = $this->_tree($aro, $child); if($nchildren) { $node['is_folder'] = true; $node['children'] = $nchildren; } $children[] = $node; } } return $children; } /* }}} */ /** * List all registered hooks * */ public function tree() { /* {{{ */ $dms = $this->params['dms']; $selrole = $this->params['selrole']; $result = array(); if($selrole) { $aro = SeedDMS_Aro::getInstance($selrole, $dms); if($acos = SeedDMS_Aco::getRoot($dms)) { foreach($acos as $aco) { if(false === ($perm = $aco->getPermission($aro))) $tree['permission'] = 0; else $tree['permission'] = $perm; $tree['id'] = $aco->getID(); $tree['label'] = $aco->getAlias(); $tree['acoid'] = $aco->getID(); $tree['aroid'] = $aro ? $aro->getID() : 0; $tree['is_folder'] = true; $tree['children'] = $this->_tree($aro, $aco); $result[] = $tree; } } } echo json_encode($result); } /* }}} */ public function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $roles = $this->params['allroles']; $selrole = $this->params['selrole']; $settings = $this->params['settings']; $accessop = $this->params['accessobject']; $this->htmlStartPage(getMLText("admin_tools")); $this->globalNavigation(); $this->contentStart(); $this->pageNavigation(getMLText("admin_tools"), "admin_tools"); if(!$settings->_advancedAcl) { $this->warningMsg(getMLText("access_control_is_off")); } $this->rowStart(); $this->columnStart(4); $this->contentHeading(getMLText("role")); ?>
getID(), htmlspecialchars($currRole->getName()), $selrole && $currRole->getID()==$selrole->getID()); } $this->formField( null, //getMLText("selection"), array( 'element'=>'select', 'id'=>'selector', 'class'=>'chzn-select', 'options'=>$options ) ); ?>
check_view_access($this, array('action'=>'info')) || $user->isAdmin()) { ?>
getID()."\"" : "") ?>>
columnEnd(); $this->columnStart(8); $this->contentHeading(getMLText("access_control")); if($selrole) { $aro = SeedDMS_Aro::getInstance($selrole, $dms); if(!$aro) { $this->warningMsg(getMLText("missing_request_object")); echo ""; } else { ?>
columnEnd(); $this->rowEnd(); $this->contentEnd(); $this->htmlEndPage(); } /* }}} */ }