central method in categories class to check a given list of category ids for needed permission

This commit is contained in:
Christian Binder 2009-11-26 08:24:51 +00:00
parent 3de4879a18
commit 30fd54c4ac

View File

@ -491,6 +491,34 @@ class categories
return $id;
}
/**
* Checks category permissions for a given list of commaseparated category ids
* and truncates it by the ones the user does not have the requested permission on
*
* @param int $needed necessary ACL right: EGW_ACL_{READ|EDIT|DELETE}
* @param string $cat_list commaseparated list of category ids
* @return string truncated commaseparated list of category ids
*/
function check_list($needed, $cat_list)
{
if (empty($cat_list)) return $cat_list;
$cat_arr = explode(',',$cat_list);
if (!empty($cat_arr) && is_array($cat_arr) && count($cat_arr) > 0)
{
foreach($cat_arr as $id=>$cat_id)
{
if (!$this->check_perms($needed, $cat_id))
{
unset($cat_arr[$id]);
}
}
$cat_list = implode(',',$cat_arr);
}
return $cat_list;
}
/**
* Checks if the current user has the necessary ACL rights
*