Skip to content

Commit

Permalink
fix: re-add menu items for service catalog
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <[email protected]>
  • Loading branch information
btry committed Dec 2, 2021
1 parent 2849eae commit f24d4e0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
32 changes: 27 additions & 5 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,12 +521,34 @@ function plugin_formcreator_redefine_menus($menus) {
}

if (plugin_formcreator_replaceHelpdesk() !== false) {
if (isset($menus['create_ticket'])) {
unset($menus['create_ticket']);
$newMenu = [];
$newMenu['seek_assistance'] = [
'default' => Plugin::getWebDir('formcreator', false) . '/front/wizard.php',
'title' => __('Seek assistance', 'formcreator'),
'icon' => 'fa fa-paper-plane',
];
$newMenu['my_assistance_requests'] = [
'default' => PluginFormcreatorIssue::getSearchURL(false),
'title' => __('My requests for assistance', 'formcreator'),
'icon' => 'fa fa-list',
];
if (PluginFormcreatorEntityConfig::getUsedConfig('is_kb_separated', Session::getActiveEntity()) == PluginFormcreatorEntityConfig::CONFIG_KB_DISTINCT
&& Session::haveRight('knowbase', KnowbaseItem::READFAQ)
) {
$newMenu['faq'] = $menus['faq'];
}
$menus['faq']['default'] = Plugin::getWebDir('formcreator', false) . '/front/knowbaseitem.php';

return $menus;
$newMenu['faq']['default'] = Plugin::getWebDir('formcreator', false) . '/front/knowbaseitem.php';
if (Session::haveRight("reservation", ReservationItem::RESERVEANITEM)) {
$newMenu['reservation'] = $menus['reservation'];
}
if (RSSFeed::canView()) {
$newMenu['feeds'] = [
'default' => Plugin::getWebDir('formcreator', false) . '/front/wizardfeeds.php',
'title' => __('Consult feeds', 'formcreator'),
'icon' => 'fa fa-rss',
];
}
return $newMenu;
}

// Using GLPI's helpdesk interface; then just modify the menu
Expand Down
2 changes: 1 addition & 1 deletion inc/formlist.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static function getTypeName($nb = 0) {

public static function getMenuContent() {
$menu = parent::getMenuContent();
$menu['title'] = static::getTypeName(2);
$menu['title'] = static::getTypeName(Session::getPluralNumber());
$menu['page'] = PluginFormcreatorFormList::getSearchURL(false);
$menu['icon'] = 'fas fa-edit';

Expand Down
12 changes: 3 additions & 9 deletions tests/3-unit/PluginFormcreatorFormList.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,8 @@ public function testGetTypeName($nb, $expected) {
public function testGetMenuContent() {
$output = \PluginFormcreatorFormList::getMenuContent();
$plugindir = '/' . basename(dirname(dirname(dirname(__DIR__))));
$this->string($output['links']['search'])->isEqualTo($plugindir . '/formcreator/front/formlist.php');
$this->array($output['links'])->notHasKey('add');
$this->string($output['links']['config'])->isEqualTo($plugindir . '/formcreator/front/form.php');

$this->login('glpi', 'glpi');
$output = \PluginFormcreatorFormList::getMenuContent();
$this->string($output['links']['search'])->isEqualTo($plugindir . '/formcreator/front/formlist.php');
$this->string($output['links']['add'])->isEqualTo($plugindir . '/formcreator/front/form.form.php');
$this->string($output['links']['config'])->isEqualTo($plugindir . '/formcreator/front/form.php');
$this->string($output['title'])->isEqualTo('Forms');
$this->string($output['page'])->isEqualTo($plugindir . '/formcreator/front/formlist.php');
$this->string($output['icon'])->isEqualTo('fas fa-edit');
}
}

0 comments on commit f24d4e0

Please sign in to comment.