egroupware_official/resources/inc/class.ui_acl.inc.php

139 lines
4.2 KiB
PHP
Raw Normal View History

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$
*/
/**
* 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()
{
$this->bo =& createobject('resources.bo_acl',True);
$this->nextmatchs =& createobject('phpgwapi.nextmatchs');
$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;
}
2005-02-20 15:41:52 +01:00
function acllist()
2005-02-03 17:42:20 +01:00
{
if (!$GLOBALS['egw']->acl->check('run',1,'admin'))
2005-02-03 17:42:20 +01:00
{
$this->deny();
2005-02-03 17:42:20 +01:00
}
if ($_POST['btnDone'])
2005-02-03 17:42:20 +01:00
{
$GLOBALS['egw']->redirect_link('/admin/index.php');
}
2005-02-03 17:42:20 +01:00
$GLOBALS['egw']->common->egw_header();
echo parse_navbar();
if ($_POST['btnSave'])
{
foreach($_POST['catids'] as $cat_id)
2005-02-03 17:42:20 +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
}
}
2005-02-03 17:42:20 +01:00
$GLOBALS['egw']->template->set_file('acl', 'acl.tpl');
$GLOBALS['egw']->template->set_block('acl','cat_list','Cblock');
$GLOBALS['egw']->template->set_var(array(
'title' => $GLOBALS['egw_info']['apps']['resources']['title'] . ' - ' . lang('Configure Access Permissions'),
'lang_search' => lang('Search'),
'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'),
'lang_cat_admin' => lang('Categories admin')
));
2005-02-03 17:42:20 +01:00
$left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
$right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
$GLOBALS['egw']->template->set_var(array(
'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(
$this->sort,'cat_name','cat_name','/index.php',lang('Category'),'&menuaction=resources.uiacl.acllist'
),
'query' => $this->query,
));
2005-02-03 17:42:20 +01:00
@reset($this->bo->cats);
while (list(,$cat) = @each($this->bo->cats))
{
$this->rights = $this->bo->get_rights($cat['id']);
2005-02-03 17:42:20 +01:00
$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
$GLOBALS['egw']->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)
2005-02-03 17:42:20 +01:00
));
$GLOBALS['egw']->template->parse('Cblock','cat_list',True);
2005-02-03 17:42:20 +01:00
}
$GLOBALS['egw']->template->pfp('out','acl',True);
}
2005-02-03 17:42:20 +01:00
function selectlist($right,$users_only=false)
{
foreach ($GLOBALS['egw']->accounts->get_list() as $num => $account)
2005-02-03 17:42:20 +01:00
{
if(!($users_only && $account['account_lastname'] == 'Group'))
2005-02-03 17:42:20 +01:00
{
$selectlist .= '<option value="' . $account['account_id'] . '"';
if($this->rights[$account['account_id']] & $right)
2005-02-20 18:10:48 +01:00
{
$selectlist .= ' selected="selected"';
2005-02-20 18:10:48 +01:00
}
$selectlist .= '>' . $account['account_firstname'] . ' ' . $account['account_lastname']
. ' [ ' . $account['account_lid'] . ' ]' . '</option>' . "\n";
2005-02-03 17:42:20 +01:00
}
}
return $selectlist;
}
2005-02-03 17:42:20 +01:00
function deny()
{
echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
$GLOBALS['egw']->common->egw_exit(True);
2005-02-03 17:42:20 +01:00
}
}