diff --git a/hook.php b/hook.php index 34cbb74d8..f2151698c 100644 --- a/hook.php +++ b/hook.php @@ -486,8 +486,30 @@ function plugin_formcreator_dynamicReport($params) { function plugin_formcreator_redefine_menus($menus) { - if (isset($menus['tickets'])) { - unset($menus['tickets']); + if (!Session::getCurrentInterface() == "helpdesk") { + return $menus; + } + + if (PluginFormcreatorEntityconfig::getUsedConfig( + 'replace_helpdesk', + $_SESSION['glpiactive_entity'] + )) { + if (isset($menus['tickets'])) { + unset($menus['tickets']); + } + } else { + $newMenus = []; + foreach ($menus as $key => $menu) { + $newMenus[$key] = $menu; + if ($key == 'create_ticket') { + $newMenus['forms'] = [ + 'default' => '/' . Plugin::getWebDir('formcreator', false) . '/front/formlist.php', + 'title' => _n('Form', 'Forms', 2, 'formcreator'), + 'content' => [0 => true] + ]; + } + } + $menus = $newMenus; } return $menus; diff --git a/js/scripts.js.php b/js/scripts.js.php index 425652416..e2b1d9647 100644 --- a/js/scripts.js.php +++ b/js/scripts.js.php @@ -66,14 +66,6 @@ function(event) { } } -// === MENU === -var link = ''; -link += ''; - $(function() { var target = $('body'); modalWindow = $("
").dialog({ @@ -108,13 +100,6 @@ function(event) { } }); - 0) { - echo "$('#c_menu #menu1:first-child').after(link);"; - } - ?> - if (location.pathname.indexOf("helpdesk.public.php") != -1) { $('.ui-tabs-panel:visible').ready(function() { diff --git a/setup.php b/setup.php index d67a9f5a5..e137b3cde 100644 --- a/setup.php +++ b/setup.php @@ -288,14 +288,7 @@ function plugin_init_formcreator() { Plugin::registerClass(PluginFormcreatorEntityconfig::class, ['addtabon' => Entity::class]); - if (Session::getCurrentInterface() == "helpdesk" - && PluginFormcreatorEntityconfig::getUsedConfig( - 'replace_helpdesk', - $_SESSION['glpiactive_entity'] - ) - ) { - $PLUGIN_HOOKS['redefine_menus']['formcreator'] = "plugin_formcreator_redefine_menus"; - } + $PLUGIN_HOOKS['redefine_menus']['formcreator'] = "plugin_formcreator_redefine_menus"; } // Load JS and CSS files if we are on a page which need them