Skip to content

Commit 33ee3ea

Browse files
committed
feat(issue): access to admins
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 893b2cc commit 33ee3ea

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

hook.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,25 @@ function plugin_formcreator_addDefaultWhere($itemtype) {
127127
$currentUser = Session::getLoginUserID();
128128
switch ($itemtype) {
129129
case PluginFormcreatorIssue::class:
130+
if (Session::haveRight(Entity::$rightname, UPDATE)) {
131+
// The user is a Formcreator administrator
132+
return '';
133+
}
134+
// Simplified interface or service catalog
130135
// Use default where from Tickets
131136
$condition = Search::addDefaultWhere(Ticket::class);
132137
if ($condition != '') {
133138
// Replace references to ticket tables with issues table
134139
$condition = str_replace('`glpi_tickets`', '`glpi_plugin_formcreator_issues`', $condition);
135140
$condition = str_replace('`users_id_recipient`', '`requester_id`', $condition);
136-
// $condition .= ' OR ';
141+
$condition .= ' OR ';
137142
}
138143
// condition where current user is a validator of the issue
139144
if (Plugin::isPluginActive('advform')) {
140145
$complexJoinId = Search::computeComplexJoinID(Search::getOptions($itemtype)[9]['joinparams']);
141-
$condition .= " OR `glpi_users_$complexJoinId`.`id` = '$currentUser'";
146+
$condition .= "`glpi_users_$complexJoinId`.`id` = '$currentUser'";
142147
} else {
143-
$condition .= " OR `glpi_plugin_formcreator_issues`.`users_id_validator` = '$currentUser'";
148+
$condition .= "`glpi_plugin_formcreator_issues`.`users_id_validator` = '$currentUser'";
144149
}
145150
// condition where current user is a member of a validator group of the issue
146151
$groupList = [];

inc/form.class.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,13 @@ public static function getMenuContent() {
119119
title="' . __('Forms waiting for validation', 'formcreator') . '"></i>';
120120
$import_image = '<i class="fas fa-download"
121121
title="' . __('Import forms', 'formcreator') . '"></i>';
122+
$requests_image = '<i class="fa fa-paper-plane"
123+
title="' . PluginFormcreatorIssue::getTypeName(Session::getPluralNumber()) . '"></i>';
124+
122125
$menu['links']['search'] = PluginFormcreatorFormList::getSearchURL(false);
123126
$menu['links'][$validation_image] = PluginFormcreatorFormAnswer::getSearchURL(false);
124127
$menu['links'][$import_image] = PluginFormcreatorForm::getFormURL(false)."?import_form=1";
125-
128+
$menu['links'][$requests_image] = PluginFormcreatorIssue::getSearchURL(false);
126129
return $menu;
127130
}
128131

tests/4-functional/PluginFormcreatorForm.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,10 @@ public function testVisibilityByLanguage() {
257257
$output = $this->crawler->filter($formTileSelector);
258258
$this->integer(count($output))->isEqualTo(0);
259259
}
260+
261+
public function testAcessToIssuesFromAdmin() {
262+
$this->crawler = $this->client->request('GET', '/' . Plugin::getWebDir('formcreator', false) . '/front/form.php');
263+
$href = '/' . Plugin::getWebDir('formcreator', false) . '/front/issue.php';
264+
$this->client->waitForVisibility('header li.nav-item a[href="' . $href . '"]');
265+
}
260266
}

0 commit comments

Comments
 (0)