Skip to content

Commit 6571bd5

Browse files
committed
fix: show menu when width is low
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 98f87ab commit 6571bd5

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

hook.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,30 @@ function plugin_formcreator_dynamicReport($params) {
486486

487487

488488
function plugin_formcreator_redefine_menus($menus) {
489-
if (isset($menus['tickets'])) {
490-
unset($menus['tickets']);
489+
if (!Session::getCurrentInterface() == "helpdesk") {
490+
return $menus;
491+
}
492+
493+
if (PluginFormcreatorEntityconfig::getUsedConfig(
494+
'replace_helpdesk',
495+
$_SESSION['glpiactive_entity']
496+
)) {
497+
if (isset($menus['tickets'])) {
498+
unset($menus['tickets']);
499+
}
500+
} else {
501+
$newMenus = [];
502+
foreach ($menus as $key => $menu) {
503+
$newMenus[$key] = $menu;
504+
if ($key == 'create_ticket') {
505+
$newMenus['forms'] = [
506+
'default' => '/' . Plugin::getWebDir('formcreator', false) . '/front/formlist.php',
507+
'title' => _n('Form', 'Forms', 2, 'formcreator'),
508+
'content' => [0 => true]
509+
];
510+
}
511+
}
512+
$menus = $newMenus;
491513
}
492514

493515
return $menus;

js/scripts.js.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,6 @@ function(event) {
6666
}
6767
}
6868

69-
// === MENU ===
70-
var link = '';
71-
link += '<li id="menu7">';
72-
link += '<a href="' + formcreatorRootDoc + '/front/formlist.php" class="itemP">';
73-
link += "<?php echo Toolbox::addslashes_deep(_n('Form', 'Forms', 2, 'formcreator')); ?>";
74-
link += '</a>';
75-
link += '</li>';
76-
7769
$(function() {
7870
modalWindow = $("<div></div>").dialog({
7971
width: 980,
@@ -107,13 +99,6 @@ function(event) {
10799
}
108100
});
109101

110-
<?php
111-
if (Session::getCurrentInterface() == 'helpdesk'
112-
&& PluginFormcreatorForm::countAvailableForm() > 0) {
113-
echo "$('#c_menu #menu1:first-child').after(link);";
114-
}
115-
?>
116-
117102
if (location.pathname.indexOf("helpdesk.public.php") != -1) {
118103

119104
$('.ui-tabs-panel:visible').ready(function() {

setup.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,7 @@ function plugin_init_formcreator() {
294294

295295
Plugin::registerClass(PluginFormcreatorEntityconfig::class, ['addtabon' => Entity::class]);
296296

297-
if (Session::getCurrentInterface() == "helpdesk"
298-
&& PluginFormcreatorEntityconfig::getUsedConfig(
299-
'replace_helpdesk',
300-
$_SESSION['glpiactive_entity']
301-
)
302-
) {
303-
$PLUGIN_HOOKS['redefine_menus']['formcreator'] = "plugin_formcreator_redefine_menus";
304-
}
297+
$PLUGIN_HOOKS['redefine_menus']['formcreator'] = "plugin_formcreator_redefine_menus";
305298
}
306299

307300
// Load JS and CSS files if we are on a page which need them

0 commit comments

Comments
 (0)