2005-02-03 17:42:20 +01:00
|
|
|
<?php
|
2005-11-11 00:35:55 +01:00
|
|
|
/**
|
|
|
|
* eGroupWare - resources
|
|
|
|
*
|
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
|
|
|
|
* @package resources
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
2005-11-09 22:03:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ACL userinterface object for resources
|
|
|
|
*
|
|
|
|
* @package resources
|
|
|
|
*/
|
|
|
|
class ui_acl
|
|
|
|
{
|
|
|
|
var $start = 0;
|
|
|
|
var $query = '';
|
|
|
|
var $sort = '';
|
|
|
|
var $order = '';
|
|
|
|
var $bo;
|
|
|
|
var $nextmatchs = '';
|
|
|
|
var $rights;
|
|
|
|
var $public_functions = array(
|
|
|
|
'acllist' => True,
|
|
|
|
);
|
|
|
|
|
|
|
|
function ui_acl()
|
|
|
|
{
|
2011-11-06 10:40:33 +01:00
|
|
|
$this->bo = createobject('resources.bo_acl',True);
|
|
|
|
$this->nextmatchs = createobject('phpgwapi.nextmatchs');
|
2005-11-09 22:03:35 +01:00
|
|
|
$this->start = $this->bo->start;
|
|
|
|
$this->query = $this->bo->query;
|
|
|
|
$this->order = $this->bo->order;
|
|
|
|
$this->sort = $this->bo->sort;
|
|
|
|
$this->cat_id = $this->bo->cat_id;
|
|
|
|
}
|
2008-08-09 06:43:31 +02:00
|
|
|
|
2005-11-09 22:03:35 +01:00
|
|
|
function acllist()
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2005-11-09 22:03:35 +01:00
|
|
|
if (!$GLOBALS['egw']->acl->check('run',1,'admin'))
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2005-11-09 22:03:35 +01:00
|
|
|
$this->deny();
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2005-11-09 22:03:35 +01:00
|
|
|
|
|
|
|
if ($_POST['btnDone'])
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2011-11-06 10:40:33 +01:00
|
|
|
egw::redirect_link('/admin/index.php');
|
2005-11-09 22:03:35 +01:00
|
|
|
}
|
2005-02-03 17:42:20 +01:00
|
|
|
|
2011-11-06 10:40:33 +01:00
|
|
|
common::egw_header();
|
2005-11-09 22:03:35 +01:00
|
|
|
echo parse_navbar();
|
|
|
|
|
|
|
|
if ($_POST['btnSave'])
|
|
|
|
{
|
|
|
|
foreach($_POST['catids'] as $cat_id)
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2005-11-09 22:03:35 +01:00
|
|
|
$this->bo->set_rights($cat_id,$_POST['inputread'][$cat_id],$_POST['inputwrite'][$cat_id],
|
|
|
|
$_POST['inputcalread'][$cat_id],$_POST['inputcalbook'][$cat_id],$_POST['inputadmin'][$cat_id]);
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2011-11-06 10:40:33 +01:00
|
|
|
config::save_value('location_cats', implode(',', $_POST['location_cats']), 'resources');
|
2005-11-09 22:03:35 +01:00
|
|
|
}
|
2008-10-20 16:01:43 +02:00
|
|
|
$template =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
|
|
|
|
$template->set_file(array('acl' => 'acl.tpl'));
|
|
|
|
$template->set_block('acl','cat_list','Cblock');
|
|
|
|
$template->set_var(array(
|
2005-11-09 22:03:35 +01:00
|
|
|
'title' => $GLOBALS['egw_info']['apps']['resources']['title'] . ' - ' . lang('Configure Access Permissions'),
|
2012-01-24 12:42:12 +01:00
|
|
|
//'lang_search' => lang('Search'),
|
2005-11-09 22:03:35 +01:00
|
|
|
'lang_save' => lang('Save'),
|
|
|
|
'lang_done' => lang('Done'),
|
|
|
|
'lang_read' => lang('Read permissions'),
|
|
|
|
'lang_write' => lang('Write permissions'),
|
|
|
|
'lang_implies_read' => lang('implies read permission'),
|
|
|
|
'lang_calread' => lang('Read Calendar permissions'),
|
|
|
|
'lang_calbook' => lang('Direct booking permissions'),
|
|
|
|
'lang_implies_book' => lang('implies booking permission'),
|
2011-11-06 10:40:33 +01:00
|
|
|
'lang_cat_admin' => lang('Categories admin'),
|
|
|
|
'lang_locations_rooms' => lang('Locations / rooms'),
|
2005-11-09 22:03:35 +01:00
|
|
|
));
|
2005-02-03 17:42:20 +01:00
|
|
|
|
2012-01-24 12:42:12 +01:00
|
|
|
$left = '';//$this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.ui_acl.acllist');
|
|
|
|
$right = '';//$this->nextmatchs->right('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.ui_acl.acllist');
|
2008-08-09 06:43:31 +02:00
|
|
|
|
2008-10-20 16:01:43 +02:00
|
|
|
$template->set_var(array(
|
2005-11-09 22:03:35 +01:00
|
|
|
'left' => $left,
|
|
|
|
'right' => $right,
|
|
|
|
'lang_showing' => $this->nextmatchs->show_hits($this->bo->catbo->total_records,$this->start),
|
|
|
|
'th_bg' => $GLOBALS['egw_info']['theme']['th_bg'],
|
|
|
|
'sort_cat' => $this->nextmatchs->show_sort_order(
|
2008-10-20 16:01:43 +02:00
|
|
|
$this->sort,'cat_name','cat_name','/index.php',lang('Category'),'&menuaction=resources.ui_acl.acllist'
|
2005-11-09 22:03:35 +01:00
|
|
|
),
|
2012-01-24 12:42:12 +01:00
|
|
|
//'query' => $this->query,
|
2005-11-09 22:03:35 +01:00
|
|
|
));
|
2005-02-03 17:42:20 +01:00
|
|
|
|
2011-11-06 10:40:33 +01:00
|
|
|
if ($this->bo->cats)
|
2005-11-09 22:03:35 +01:00
|
|
|
{
|
2011-11-06 10:40:33 +01:00
|
|
|
$config = config::read('resources');
|
|
|
|
$location_cats = $config['location_cats'] ? explode(',', $config['location_cats']) : array();
|
|
|
|
foreach($this->bo->cats as $cat)
|
|
|
|
{
|
|
|
|
$this->rights = $this->bo->get_rights($cat['id']);
|
2005-02-03 17:42:20 +01:00
|
|
|
|
2011-11-06 10:40:33 +01:00
|
|
|
$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
|
|
|
|
$template->set_var(array(
|
|
|
|
'tr_color' => $tr_color,
|
|
|
|
'catname' => $cat['name'],
|
|
|
|
'catid' => $cat['id'],
|
|
|
|
'read' => $this->selectlist(EGW_ACL_READ),
|
|
|
|
'write' => $this->selectlist(EGW_ACL_ADD),
|
|
|
|
'calread' => $this->selectlist(EGW_ACL_CALREAD),
|
|
|
|
'calbook' =>$this->selectlist(EGW_ACL_DIRECT_BOOKING),
|
|
|
|
'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(EGW_ACL_CAT_ADMIN,true),
|
|
|
|
'location_checked' => in_array($cat['id'], $location_cats) ? 'checked="1"' : '',
|
|
|
|
));
|
|
|
|
$template->parse('Cblock','cat_list',True);
|
|
|
|
}
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2008-10-20 16:01:43 +02:00
|
|
|
$template->pfp('out','acl',True);
|
2005-11-09 22:03:35 +01:00
|
|
|
}
|
2005-02-03 17:42:20 +01:00
|
|
|
|
2005-11-09 22:03:35 +01:00
|
|
|
function selectlist($right,$users_only=false)
|
|
|
|
{
|
2012-01-24 12:42:12 +01:00
|
|
|
static $accountList;
|
|
|
|
static $groupList;
|
2008-08-09 06:43:31 +02:00
|
|
|
switch($GLOBALS['egw_info']['user']['preferences']['common']['account_display'])
|
|
|
|
{
|
2008-10-20 16:01:43 +02:00
|
|
|
case 'firstname':
|
|
|
|
case 'firstall':
|
|
|
|
$order = 'n_given,n_family';
|
|
|
|
break;
|
|
|
|
case 'lastall':
|
|
|
|
case 'lastname':
|
|
|
|
$order = 'n_family,n_given';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$order = 'account_lid,n_family,n_given';
|
|
|
|
break;
|
2008-08-09 06:43:31 +02:00
|
|
|
}
|
2012-01-24 12:42:12 +01:00
|
|
|
if (is_null($accountList))
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2012-01-24 12:42:12 +01:00
|
|
|
$accountList = $GLOBALS['egw']->accounts->search(array(
|
|
|
|
'type' => 'accounts',
|
|
|
|
'order' => $order,
|
|
|
|
));
|
|
|
|
uasort($accountList,array($this,($order=='n_given,n_family'?"sortByNGiven":($order=='n_family,n_given'?"sortByNLast":"sortByLid"))));
|
|
|
|
$resultList = $accountList;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$resultList = $accountList;
|
|
|
|
}
|
|
|
|
if (is_null($groupList) && $users_only==false)
|
|
|
|
{
|
2012-01-24 13:20:53 +01:00
|
|
|
$groupList = $GLOBALS['egw']->accounts->search(array(
|
|
|
|
'type' => 'groups',
|
|
|
|
'order' => 'account_lid',
|
|
|
|
));
|
2012-01-24 12:42:12 +01:00
|
|
|
uasort($groupList,array($this,"sortByLid"));
|
|
|
|
}
|
2012-01-24 13:20:53 +01:00
|
|
|
if (count($groupList)>0 && $users_only==false) foreach ($groupList as $k => $val) $resultList[$k] = $val;
|
|
|
|
|
2012-01-24 12:42:12 +01:00
|
|
|
foreach ($resultList as $num => $account)
|
|
|
|
{
|
|
|
|
$selectlist .= '<option value="' . $account['account_id'] . '"';
|
|
|
|
if($this->rights[$account['account_id']] & $right)
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2012-01-24 12:42:12 +01:00
|
|
|
$selectlist .= ' selected="selected"';
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2012-01-24 12:42:12 +01:00
|
|
|
$selectlist .= '>' . common::display_fullname($account['account_lid'],$account['account_firstname'],
|
|
|
|
$account['account_lastname'],$account['account_id']) . '</option>' . "\n";
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2005-11-09 22:03:35 +01:00
|
|
|
return $selectlist;
|
|
|
|
}
|
2005-02-03 17:42:20 +01:00
|
|
|
|
2012-01-24 12:42:12 +01:00
|
|
|
function sortByNGiven($a,$b)
|
|
|
|
{
|
|
|
|
// 0, 1 und -1
|
|
|
|
$rv = strcasecmp($a['account_firstname'], $b['account_firstname']);
|
|
|
|
if ($rv==0) $rv = strcasecmp($a['account_lastname'], $b['account_lastname']);
|
|
|
|
if ($rv==0) $rv = strcasecmp($a['account_lid'], $b['account_lid']);
|
|
|
|
return $rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
function sortByNLast($a,$b)
|
|
|
|
{
|
|
|
|
// 0, 1 und -1
|
|
|
|
$rv = strcasecmp($a['account_lastname'], $b['account_lastname']);
|
|
|
|
if ($rv==0) $rv = strcasecmp($a['account_firstname'], $b['account_firstname']);
|
|
|
|
if ($rv==0) $rv = strcasecmp($a['account_lid'], $b['account_lid']);
|
|
|
|
return $rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
function sortByLid($a,$b)
|
|
|
|
{
|
|
|
|
// 0, 1 und -1
|
|
|
|
return strcasecmp($a['account_lid'], $b['account_lid']);
|
|
|
|
}
|
|
|
|
|
2005-11-09 22:03:35 +01:00
|
|
|
function deny()
|
|
|
|
{
|
|
|
|
echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
|
2011-11-06 10:40:33 +01:00
|
|
|
common::egw_exit(True);
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2005-11-09 22:03:35 +01:00
|
|
|
}
|