Add ignore_acl flag for read and checkUsable methods

This commit is contained in:
Hadi Nategh 2020-12-15 13:08:48 +01:00
parent 77d195bd9c
commit 8bc5b22b5e

View File

@ -289,15 +289,16 @@ class resources_bo
* *
* Cornelius Weiss <egw@von-und-zu-weiss.de> * Cornelius Weiss <egw@von-und-zu-weiss.de>
* @param int $res_id resource id * @param int $res_id resource id
* @param bool $_ignore_acl ignores acl check if set to true
* @return array with key => value or false if not found or allowed * @return array with key => value or false if not found or allowed
*/ */
function read($res_id) function read($res_id, $_ignore_acl=false)
{ {
if (!($data = $this->so->read(array('res_id' => $res_id)))) if (!($data = $this->so->read(array('res_id' => $res_id))))
{ {
return null; // not found return null; // not found
} }
if (!$this->acl->is_permitted($data['cat_id'],Acl::READ)) if (!$_ignore_acl && !$this->acl->is_permitted($data['cat_id'],Acl::READ))
{ {
return false; // permission denied return false; // permission denied
} }
@ -330,7 +331,7 @@ class resources_bo
{ {
$resource['res_modifier'] = $GLOBALS['egw_info']['user']['account_id']; $resource['res_modifier'] = $GLOBALS['egw_info']['user']['account_id'];
$resource['res_modified'] = Api\DateTime::server2user(time(),'ts'); $resource['res_modified'] = Api\DateTime::server2user(time(),'ts');
$old = $this->read($resource['res_id']); $old = $this->read($resource['res_id'], $ignore_acl);
} }
switch ($resource['picture_src']) switch ($resource['picture_src'])
@ -398,7 +399,7 @@ class resources_bo
foreach($accessories as $accessory => $name) foreach($accessories as $accessory => $name)
{ {
Link::unlink(0,'resources',$accessory,'','resources',$resource['res_id']); Link::unlink(0,'resources',$accessory,'','resources',$resource['res_id']);
if (($acc = $this->read($accessory))) if (($acc = $this->read($accessory, $ignore_acl)))
{ {
$acc['accessory_of'] = -1; $acc['accessory_of'] = -1;
$this->so->save($acc); $this->so->save($acc);
@ -844,11 +845,12 @@ class resources_bo
* @param $_res_id * @param $_res_id
* @param $_starttime * @param $_starttime
* @param $_endtime * @param $_endtime
* @param bool $_ignore_acl ignores acl check if set to true
* @return array|null returns array of resource data with calculated useable quantity * @return array|null returns array of resource data with calculated useable quantity
*/ */
function checkUseable($_res_id, $_starttime, $_endtime) function checkUseable($_res_id, $_starttime, $_endtime, $_ignore_acl=false)
{ {
$resource = $this->read($_res_id); $resource = $this->read($_res_id, $_ignore_acl);
if ($resource && $resource['bookable']) if ($resource && $resource['bookable'])
{ {
//get a calendar objet for reservations //get a calendar objet for reservations