mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-11 16:35:38 +00:00
add files for managing access control lists
This commit is contained in:
parent
ce57466695
commit
677534c8ec
49
out/out.Acl.php
Normal file
49
out/out.Acl.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
// MyDMS. Document Management System
|
||||
// Copyright (C) 2010 Matteo Lucarelli
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
include("../inc/inc.Settings.php");
|
||||
include("../inc/inc.Language.php");
|
||||
include("../inc/inc.Init.php");
|
||||
include("../inc/inc.Extension.php");
|
||||
include("../inc/inc.DBInit.php");
|
||||
include("../inc/inc.ClassUI.php");
|
||||
include("../inc/inc.ClassAcl.php");
|
||||
include("../inc/inc.Authentication.php");
|
||||
|
||||
if (!$user->isAdmin()) {
|
||||
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
|
||||
}
|
||||
|
||||
$roles = $dms->getAllRoles();
|
||||
if (is_bool($roles)) {
|
||||
UI::exitError(getMLText("admin_tools"),getMLText("internal_error"));
|
||||
}
|
||||
|
||||
if(isset($_GET['roleid']) && $_GET['roleid']) {
|
||||
$selrole = $dms->getRole($_GET['roleid']);
|
||||
} else {
|
||||
$selrole = null;
|
||||
}
|
||||
|
||||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'settings'=>$settings, 'selrole'=>$selrole, 'allroles'=>$roles));
|
||||
if($view) {
|
||||
$view($_GET);
|
||||
exit;
|
||||
}
|
||||
|
211
views/bootstrap/class.Acl.php
Normal file
211
views/bootstrap/class.Acl.php
Normal file
|
@ -0,0 +1,211 @@
|
|||
<?php
|
||||
/**
|
||||
* Implementation of Acl view
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @license GPL 2
|
||||
* @version @version@
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @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 <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2016 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_View_Acl extends SeedDMS_Bootstrap_Style {
|
||||
|
||||
function js() { /* {{{ */
|
||||
header('Content-Type: application/javascript');
|
||||
?>
|
||||
$('#acostree').tree({
|
||||
openedIcon: '<i class="icon-minus-sign"></i>',
|
||||
closedIcon: '<i class="icon-plus-sign"></i>',
|
||||
onCreateLi: function(node, $li) {
|
||||
switch(node.permission) {
|
||||
case "-1":
|
||||
$li.find('.jqtree-element').after('<span class="jqtree-remove-permission" data-acoid="'+node.acoid+'" data-aroid="'+node.aroid+'"><i class="icon-minus-sign"></i></span> <span class="jqtree-toggle-permission" data-acoid="'+node.acoid+'" data-aroid="'+node.aroid+'"><i class="icon-exchange"></i></span>');
|
||||
$li.attr('style', 'background-color:#FDD');
|
||||
break;
|
||||
case "1":
|
||||
$li.find('.jqtree-element').after('<span class="jqtree-remove-permission" data-acoid="'+node.acoid+'" data-aroid="'+node.aroid+'"><i class="icon-minus-sign"></i></span> <span class="jqtree-toggle-permission" data-acoid="'+node.acoid+'" data-aroid="'+node.aroid+'"><i class="icon-exchange"></i></span>');
|
||||
$li.attr('style', 'background-color:#DFD');
|
||||
break;
|
||||
default:
|
||||
$li.find('.jqtree-element').after('<span class="jqtree-add-permission" data-acoid="'+node.acoid+'" data-aroid="'+node.aroid+'"><i class="icon-plus-sign"></i></span>');
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#acostree').on('click', '.jqtree-toggle-permission', function(event) {
|
||||
acoid = $(event.target).parent().attr('data-acoid');
|
||||
aroid = $(event.target).parent().attr('data-aroid');
|
||||
$.ajax('out.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-add-permission', function(event) {
|
||||
acoid = $(event.target).parent().attr('data-acoid');
|
||||
aroid = $(event.target).parent().attr('data-aroid');
|
||||
$.ajax('out.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('out.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});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$(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()});
|
||||
});
|
||||
});
|
||||
<?php
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* 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->getID();
|
||||
|
||||
$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);
|
||||
|
||||
$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();
|
||||
$node['acoid'] = $aco->getID();
|
||||
$node['aroid'] = $aro->getID();
|
||||
$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'];
|
||||
|
||||
$this->htmlStartPage(getMLText("admin_tools"));
|
||||
$this->globalNavigation();
|
||||
$this->contentStart();
|
||||
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
|
||||
?>
|
||||
<div class="row-fluid">
|
||||
<div class="span4">
|
||||
<?php
|
||||
$this->contentHeading("Role");
|
||||
?>
|
||||
<select class="chzn-select" id="selector">
|
||||
<option value="-1"><?php echo getMLText("choose_role")?>
|
||||
<?php
|
||||
foreach ($roles as $currRole) {
|
||||
print "<option value=\"".$currRole->getID()."\" ".($selrole && $currRole->getID()==$selrole->getID() ? 'selected' : '').">" . htmlspecialchars($currRole->getName());
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="span8">
|
||||
<?php
|
||||
$this->contentHeading("Acl");
|
||||
?>
|
||||
<div id="acostree" data-url="out.Acl.php?action=tree&roleid=<?= ($selrole ? $selrole->getID() : 0) ?>">Berechtigungen werden geladen ...</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$this->htmlEndPage();
|
||||
} /* }}} */
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user