From b1484c2a1d0f71b9c756796d1acc475b16184404 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 15 Jan 2013 16:50:11 +0000 Subject: [PATCH] If un-deleting an accessory but not the parent resource, un-parent and make it a resource --- resources/inc/class.resources_ui.inc.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/resources/inc/class.resources_ui.inc.php b/resources/inc/class.resources_ui.inc.php index efb83bf34f..c940f4ec82 100755 --- a/resources/inc/class.resources_ui.inc.php +++ b/resources/inc/class.resources_ui.inc.php @@ -360,6 +360,20 @@ class resources_ui if(!$id) continue; $resource = $this->bo->read($id); $resource['deleted'] = null; + if($resource['accessory_of'] > 0) + { + /* + If restoring an accessory, and parent is deleted, and not in + the list of resources to be restored right now, un-parent + */ + $parent = $this->bo->read($resource['accessory_of']); + $checked_key = array_search($parent['res_id'], $checked); + if($checked_key === false && $parent['deleted']) + { + $resource['accessory_of'] = -1; + } + } + $this->bo->save($resource); if($settings == 'accessories') {