From c0867b777e7173af6071daa26625d0b264dfcaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20Wei=C3=9F?= Date: Sun, 20 Feb 2005 17:10:48 +0000 Subject: [PATCH] work on acl --- resources/inc/class.bo_acl.inc.php | 68 ++++++++++++++++++----------- resources/inc/class.ui_acl.inc.php | 23 ++++++---- resources/templates/default/acl.tpl | 6 +-- 3 files changed, 60 insertions(+), 37 deletions(-) diff --git a/resources/inc/class.bo_acl.inc.php b/resources/inc/class.bo_acl.inc.php index 0e7cbec264..8a38d0bc74 100755 --- a/resources/inc/class.bo_acl.inc.php +++ b/resources/inc/class.bo_acl.inc.php @@ -34,12 +34,11 @@ $this->so = CreateObject('resources.so_acl'); $this->permissions = $this->so->get_permissions($GLOBALS['phpgw_info']['user']['account_id'],true); - $this->egw_cats = createobject('phpgwapi.categories'); - $this->accounts = $GLOBALS['phpgw']->accounts->get_list(); $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) { $this->read_sessiondata(); @@ -64,7 +63,7 @@ @function get_cats @abstract get list of cats where current user has given rights @author Cornelius Weiß - @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 TODO mark subcats and so on! */ @@ -81,6 +80,43 @@ return $readcats; } + /*! + @function get_cat_admin + @abstract gets userid of admin for given category + @author Cornelius Weiß + @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() { $data = array( @@ -106,31 +142,12 @@ $this->limit = $data['limit']; } - function get_rights($cat_id) - { - 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) + function set_rights($cat_id,$read,$write,$book,$admin) { $readcat = $read ? $read : array(); $writecat = $write ? $write : array(); $bookcat = $book ? $book : array(); + $admincat = $admin ? $admin : array(); $this->so->remove_location('L' . $cat_id); reset($this->accounts); @@ -142,6 +159,7 @@ (PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT | PHPGW_ACL_DELETE) : (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,$admincat) ? ($rights | PHPGW_ACL_CAT_ADMIN) : $rights; if ($rights) { $GLOBALS['phpgw']->acl->add_repository('resources','L'.$cat_id,$account_id,$rights); diff --git a/resources/inc/class.ui_acl.inc.php b/resources/inc/class.ui_acl.inc.php index 38ea9d7f54..bc309772cf 100755 --- a/resources/inc/class.ui_acl.inc.php +++ b/resources/inc/class.ui_acl.inc.php @@ -57,7 +57,7 @@ { 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_implies' => lang('implies read permission'), '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'); @@ -100,25 +101,29 @@ 'catid' => $cat['id'], 'read' => $this->selectlist(PHPGW_ACL_READ), 'write' => $this->selectlist(PHPGW_ACL_ADD), - 'book' =>$this->selectlist(PHPGW_ACL_DIRECT_BOOKING) + 'book' =>$this->selectlist(PHPGW_ACL_DIRECT_BOOKING), + 'admin' => ''.$this->selectlist(PHPGW_ACL_CAT_ADMIN,true) )); $GLOBALS['phpgw']->template->parse('Cblock','cat_list',True); } $GLOBALS['phpgw']->template->pfp('out','acl',True); } - function selectlist($right) + function selectlist($right,$users_only=false) { reset($this->bo->accounts); while (list($null,$account) = each($this->bo->accounts)) { - $selectlist .= '' . "\n"; + } } return $selectlist; } diff --git a/resources/templates/default/acl.tpl b/resources/templates/default/acl.tpl index 9c28948a8d..35de299fe5 100755 --- a/resources/templates/default/acl.tpl +++ b/resources/templates/default/acl.tpl @@ -24,7 +24,7 @@
- + @@ -32,8 +32,8 @@
{sort_cat}{sort_cat}
{lang_cat_admin}
{lang_read} {lang_write}
({lang_implies})
{lang_book}
- {catname} - + {catname}
+