From da02eca77053cfd5919f74936a1391ce97b99aeb Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 7 Jun 2015 01:41:20 -0400 Subject: [PATCH] \# 208 Add category to user if they can't see it This makes it much easier to tell if the user has access to the category or not, instead of querying for which categories the user is manager of. --- admin/manage_categories.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/admin/manage_categories.php b/admin/manage_categories.php index e0b267f1..7fbf5112 100644 --- a/admin/manage_categories.php +++ b/admin/manage_categories.php @@ -742,6 +742,17 @@ function change_manager() { { hesk_process_messages($hesklang['int_error'].': '.$hesklang['cat_not_found'],'./manage_categories.php'); } + if ($newManagerId == 0) { + // There is no new manager. + return; + } + // Add the category to the user's categories list, if not already present + $currentCatRs = hesk_dbQuery('SELECT `categories` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'users` WHERE `id` = '.intval($newManagerId)); + $currentCategories = hesk_dbFetchAssoc($currentCatRs); + $categories = explode(',', $currentCategories['categories']); + if (!in_array($catid, $categories)) { + hesk_dbQuery('UPDATE `'.hesk_dbEscape($hesk_settings['db_pfix']).'users` SET `categories` = \''.$currentCategories['categories'].','.$catid.'\' WHERE `id` = '.intval($newManagerId)); + } hesk_process_messages($hesklang['manager_updated'],'./manage_categories.php','SUCCESS'); }