From eb104a9ee53ba8e656ca040c371107ccb28b1646 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 14 Jan 2013 18:42:16 +0000 Subject: [PATCH] Nice handling for no read on any categories: - Short-cut on link query to skip search - no categories means no results - Hide add button - with no categories, user will not be able to save --- resources/inc/class.resources_bo.inc.php | 7 +++++++ resources/inc/class.resources_ui.inc.php | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/inc/class.resources_bo.inc.php b/resources/inc/class.resources_bo.inc.php index 5210e3b19c..d1fc33748a 100755 --- a/resources/inc/class.resources_bo.inc.php +++ b/resources/inc/class.resources_bo.inc.php @@ -555,6 +555,13 @@ class resources_bo , 'short_description' => $pattern); } $only_keys = 'res_id,name,short_description,bookable,useable'; + + // If no read access to any category, just stop + if(!$this->acl->get_cats(EGW_ACL_READ)) + { + $options['total'] = 0; + return array(); + } $filter = array( 'cat_id' => array_flip((array)$this->acl->get_cats(EGW_ACL_READ)), //'accessory_of' => '-1' diff --git a/resources/inc/class.resources_ui.inc.php b/resources/inc/class.resources_ui.inc.php index bc365aa5cb..efb83bf34f 100755 --- a/resources/inc/class.resources_ui.inc.php +++ b/resources/inc/class.resources_ui.inc.php @@ -144,9 +144,10 @@ class resources_ui $content['nm']['actions'] = $this->get_actions(); // check if user is permitted to add resources - if(!$this->bo->acl->get_cats(EGW_ACL_ADD)) + // If they can't read any categories, they won't be able to save it + if(!$this->bo->acl->get_cats(EGW_ACL_ADD) || !$this->bo->acl->get_cats(EGW_ACL_READ)) { - $no_button['add'] = true; + $no_button['add'] = $no_button['nm']['add'] = true; } $no_button['back'] = true; $GLOBALS['egw_info']['flags']['app_header'] = lang('resources');