mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
work on acl
This commit is contained in:
parent
3a81d8234a
commit
c0867b777e
@ -34,12 +34,11 @@
|
|||||||
|
|
||||||
$this->so = CreateObject('resources.so_acl');
|
$this->so = CreateObject('resources.so_acl');
|
||||||
$this->permissions = $this->so->get_permissions($GLOBALS['phpgw_info']['user']['account_id'],true);
|
$this->permissions = $this->so->get_permissions($GLOBALS['phpgw_info']['user']['account_id'],true);
|
||||||
|
|
||||||
$this->egw_cats = createobject('phpgwapi.categories');
|
$this->egw_cats = createobject('phpgwapi.categories');
|
||||||
|
|
||||||
$this->accounts = $GLOBALS['phpgw']->accounts->get_list();
|
$this->accounts = $GLOBALS['phpgw']->accounts->get_list();
|
||||||
$this->debug = False;
|
$this->debug = False;
|
||||||
//all this is only needed when called from uiacl. not from ui,
|
|
||||||
|
//all this is only needed when called from uiacl.
|
||||||
if($session)
|
if($session)
|
||||||
{
|
{
|
||||||
$this->read_sessiondata();
|
$this->read_sessiondata();
|
||||||
@ -64,7 +63,7 @@
|
|||||||
@function get_cats
|
@function get_cats
|
||||||
@abstract get list of cats where current user has given rights
|
@abstract get list of cats where current user has given rights
|
||||||
@author Cornelius Weiß <egw@von-und-zu-weiss.de>
|
@author Cornelius Weiß <egw@von-und-zu-weiss.de>
|
||||||
@param int $perm_type one of PHPGW_ACL_READ, PHPGW_ACL_ADD, PHPGW_ACL_EDIT, PHPGW_ACL_DELETE
|
@param int $perm_type one of PHPGW_ACL_READ, PHPGW_ACL_ADD, PHPGW_ACL_EDIT, PHPGW_ACL_DELETE, PHPGW_ACL_DIRECT_BOOKING
|
||||||
@return array cat_name => cat_id
|
@return array cat_name => cat_id
|
||||||
TODO mark subcats and so on!
|
TODO mark subcats and so on!
|
||||||
*/
|
*/
|
||||||
@ -81,6 +80,43 @@
|
|||||||
return $readcats;
|
return $readcats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function get_cat_admin
|
||||||
|
@abstract gets userid of admin for given category
|
||||||
|
@author Cornelius Weiß <egw@von-und-zu-weiss.de>
|
||||||
|
@param int $cat_id
|
||||||
|
@return int userid of cat admin
|
||||||
|
*/
|
||||||
|
function get_cat_admin($cat_id)
|
||||||
|
{
|
||||||
|
return array_search (PHPGW_ACL_CAT_ADMIN, $this->get_rights($cat_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function is_permitted
|
||||||
|
@abstract cheks one of the following rights for current user:
|
||||||
|
@abstract PHPGW_ACL_READ, PHPGW_ACL_ADD, PHPGW_ACL_EDIT, PHPGW_ACL_DELETE, PHPGW_ACL_DIRECT_BOOKING
|
||||||
|
@param int $cat_id
|
||||||
|
@param int $right
|
||||||
|
@return bool user is permitted or not for right
|
||||||
|
*/
|
||||||
|
function is_permitted($cat_id,$right)
|
||||||
|
{
|
||||||
|
return $this->permissions['L'.$cat_id] & $right;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function get_rights
|
||||||
|
@abstract gets all rights from all user for given cat
|
||||||
|
@param int $cat_id
|
||||||
|
@return array userid => right
|
||||||
|
*/
|
||||||
|
function get_rights($cat_id)
|
||||||
|
{
|
||||||
|
return $this->so->get_rights('L'.$cat_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// privat functions from here on -------------------------------------------------------------------------
|
||||||
function save_sessiondata()
|
function save_sessiondata()
|
||||||
{
|
{
|
||||||
$data = array(
|
$data = array(
|
||||||
@ -106,31 +142,12 @@
|
|||||||
$this->limit = $data['limit'];
|
$this->limit = $data['limit'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_rights($cat_id)
|
function set_rights($cat_id,$read,$write,$book,$admin)
|
||||||
{
|
|
||||||
return $this->so->get_rights('L'.$cat_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_permitted($cat_id,$right)
|
|
||||||
{
|
|
||||||
return $this->permissions['L'.$cat_id] & $right;
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_readable($cat_id)
|
|
||||||
{
|
|
||||||
return $this->is_permitted($cat_id,PHPGW_ACL_READ);
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_writeable($cat_id)
|
|
||||||
{
|
|
||||||
return $this->is_permitted($cat_id,PHPGW_ACL_ADD);
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_rights($cat_id,$read,$write,$book)
|
|
||||||
{
|
{
|
||||||
$readcat = $read ? $read : array();
|
$readcat = $read ? $read : array();
|
||||||
$writecat = $write ? $write : array();
|
$writecat = $write ? $write : array();
|
||||||
$bookcat = $book ? $book : array();
|
$bookcat = $book ? $book : array();
|
||||||
|
$admincat = $admin ? $admin : array();
|
||||||
|
|
||||||
$this->so->remove_location('L' . $cat_id);
|
$this->so->remove_location('L' . $cat_id);
|
||||||
reset($this->accounts);
|
reset($this->accounts);
|
||||||
@ -142,6 +159,7 @@
|
|||||||
(PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT | PHPGW_ACL_DELETE) :
|
(PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT | PHPGW_ACL_DELETE) :
|
||||||
(in_array($account_id,$readcat) ? PHPGW_ACL_READ : False);
|
(in_array($account_id,$readcat) ? PHPGW_ACL_READ : False);
|
||||||
$rights = in_array($account_id,$bookcat) ? ($rights | PHPGW_ACL_DIRECT_BOOKING) : $rights;
|
$rights = in_array($account_id,$bookcat) ? ($rights | PHPGW_ACL_DIRECT_BOOKING) : $rights;
|
||||||
|
$rights = in_array($account_id,$admincat) ? ($rights | PHPGW_ACL_CAT_ADMIN) : $rights;
|
||||||
if ($rights)
|
if ($rights)
|
||||||
{
|
{
|
||||||
$GLOBALS['phpgw']->acl->add_repository('resources','L'.$cat_id,$account_id,$rights);
|
$GLOBALS['phpgw']->acl->add_repository('resources','L'.$cat_id,$account_id,$rights);
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
{
|
{
|
||||||
foreach($_POST['catids'] as $cat_id)
|
foreach($_POST['catids'] as $cat_id)
|
||||||
{
|
{
|
||||||
$this->bo->set_rights($cat_id,$_POST['inputread'][$cat_id],$_POST['inputwrite'][$cat_id],$_POST['inputbook'][$cat_id]);
|
$this->bo->set_rights($cat_id,$_POST['inputread'][$cat_id],$_POST['inputwrite'][$cat_id],$_POST['inputbook'][$cat_id],$_POST['inputadmin'][$cat_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +72,7 @@
|
|||||||
'lang_write' => lang('Write permissions'),
|
'lang_write' => lang('Write permissions'),
|
||||||
'lang_implies' => lang('implies read permission'),
|
'lang_implies' => lang('implies read permission'),
|
||||||
'lang_book' => lang('Direct booking permissions'),
|
'lang_book' => lang('Direct booking permissions'),
|
||||||
|
'lang_cat_admin' => lang('Categories admin')
|
||||||
));
|
));
|
||||||
|
|
||||||
$left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
|
$left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
|
||||||
@ -100,25 +101,29 @@
|
|||||||
'catid' => $cat['id'],
|
'catid' => $cat['id'],
|
||||||
'read' => $this->selectlist(PHPGW_ACL_READ),
|
'read' => $this->selectlist(PHPGW_ACL_READ),
|
||||||
'write' => $this->selectlist(PHPGW_ACL_ADD),
|
'write' => $this->selectlist(PHPGW_ACL_ADD),
|
||||||
'book' =>$this->selectlist(PHPGW_ACL_DIRECT_BOOKING)
|
'book' =>$this->selectlist(PHPGW_ACL_DIRECT_BOOKING),
|
||||||
|
'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(PHPGW_ACL_CAT_ADMIN,true)
|
||||||
));
|
));
|
||||||
$GLOBALS['phpgw']->template->parse('Cblock','cat_list',True);
|
$GLOBALS['phpgw']->template->parse('Cblock','cat_list',True);
|
||||||
}
|
}
|
||||||
$GLOBALS['phpgw']->template->pfp('out','acl',True);
|
$GLOBALS['phpgw']->template->pfp('out','acl',True);
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectlist($right)
|
function selectlist($right,$users_only=false)
|
||||||
{
|
{
|
||||||
reset($this->bo->accounts);
|
reset($this->bo->accounts);
|
||||||
while (list($null,$account) = each($this->bo->accounts))
|
while (list($null,$account) = each($this->bo->accounts))
|
||||||
{
|
{
|
||||||
$selectlist .= '<option value="' . $account['account_id'] . '"';
|
if(!($users_only && $account['account_lastname'] == 'Group'))
|
||||||
if($this->rights[$account['account_id']] & $right)
|
{
|
||||||
{
|
$selectlist .= '<option value="' . $account['account_id'] . '"';
|
||||||
$selectlist .= ' selected="selected"';
|
if($this->rights[$account['account_id']] & $right)
|
||||||
}
|
{
|
||||||
$selectlist .= '>' . $account['account_firstname'] . ' ' . $account['account_lastname']
|
$selectlist .= ' selected="selected"';
|
||||||
|
}
|
||||||
|
$selectlist .= '>' . $account['account_firstname'] . ' ' . $account['account_lastname']
|
||||||
. ' [ ' . $account['account_lid'] . ' ]' . '</option>' . "\n";
|
. ' [ ' . $account['account_lid'] . ' ]' . '</option>' . "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $selectlist;
|
return $selectlist;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<form method="POST">
|
<form method="POST">
|
||||||
<table border="0" cellspacing="2" cellpadding="2" width="60%">
|
<table border="0" cellspacing="2" cellpadding="2" width="60%">
|
||||||
<tr bgcolor="{th_bg}" valign="middle" align="center">
|
<tr bgcolor="{th_bg}" valign="middle" align="center">
|
||||||
<td>{sort_cat}</td>
|
<td>{sort_cat}<br>{lang_cat_admin}</td>
|
||||||
<td>{lang_read}</td>
|
<td>{lang_read}</td>
|
||||||
<td>{lang_write}<br>({lang_implies})</td>
|
<td>{lang_write}<br>({lang_implies})</td>
|
||||||
<td>{lang_book}</td>
|
<td>{lang_book}</td>
|
||||||
@ -32,8 +32,8 @@
|
|||||||
<!-- BEGIN cat_list -->
|
<!-- BEGIN cat_list -->
|
||||||
<tr bgcolor="{tr_color}">
|
<tr bgcolor="{tr_color}">
|
||||||
<td>
|
<td>
|
||||||
{catname}
|
{catname}<input type="hidden" name="catids[]" value="{catid}" /><br>
|
||||||
<input type="hidden" name="catids[]" value="{catid}" />
|
<select name="inputadmin[{catid}][]">{admin}</select>
|
||||||
</td>
|
</td>
|
||||||
<td align="center"><select multiple="multiple" size="5" name="inputread[{catid}][]">{read}</select></td>
|
<td align="center"><select multiple="multiple" size="5" name="inputread[{catid}][]">{read}</select></td>
|
||||||
<td align="center"><select multiple="multiple" size="5" name="inputwrite[{catid}][]">{write}</select></td>
|
<td align="center"><select multiple="multiple" size="5" name="inputwrite[{catid}][]">{write}</select></td>
|
||||||
|
Loading…
Reference in New Issue
Block a user