From 59c35020e7b6a88c13755dda5727fe6677fd9e09 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 4 Dec 2012 23:57:02 +0000 Subject: [PATCH] When viewing accessories of a resource - Add button adds an accessory - Allow context menu -> add accessory = add accessory to resource, _not_ selected accessory --- resources/inc/class.resources_bo.inc.php | 4 +++- resources/inc/class.resources_ui.inc.php | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/resources/inc/class.resources_bo.inc.php b/resources/inc/class.resources_bo.inc.php index 5e298884f4..e6df7b2ea1 100755 --- a/resources/inc/class.resources_bo.inc.php +++ b/resources/inc/class.resources_bo.inc.php @@ -165,7 +165,9 @@ class resources_bo $readonlys["delete[$resource[res_id]]"] = true; $resource['class'] .= 'no_delete '; } - if ((!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_ADD)) || $resource['accessory_of'] != -1) + if ((!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_ADD)) || + // Allow new accessory action when viewing accessories of a certain resource + $query['filter2'] <= 0 && $resource['accessory_of'] != -1) { $readonlys["new_acc[$resource[res_id]]"] = true; $resource['class'] .= 'no_new_accessory '; diff --git a/resources/inc/class.resources_ui.inc.php b/resources/inc/class.resources_ui.inc.php index 2c5f9959c5..cbb2efdd97 100755 --- a/resources/inc/class.resources_ui.inc.php +++ b/resources/inc/class.resources_ui.inc.php @@ -436,8 +436,10 @@ class resources_ui } } + $nm_session_data = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm'); $res_id = is_numeric($content) ? (int)$content : $content['res_id']; if (isset($_GET['res_id'])) $res_id = $_GET['res_id']; + if (isset($nm_session_data['filter2']) && $nm_session_data['filter2'] > 0) $accessory_of = $nm_session_data['filter2']; if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of']; $content = array('res_id' => $res_id); @@ -453,11 +455,16 @@ class resources_ui } elseif ($accessory_of > 0) { // Pre-set according to parent $owner = $this->bo->read($accessory_of); + if($owner['accessory_of'] > 0) + { + // Accessory of accessory not allowed, grab parent resource + $accessory_of = $owner['accessory_of']; + $owner = $this->bo->read($accessory_of); + } $content['cat_id'] = $owner['cat_id']; $content['bookable'] = true; } else { // New resource - $nm_session_data = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm'); $content['cat_id'] = $nm_session_data['filter']; $content['bookable'] = true; }