Skip to content

Commit 5bf758f

Browse files
committed
refactor: keep distinction between target name and generated name
Signed-off-by: Thierry Bugier <[email protected]>
1 parent 83fad70 commit 5bf758f

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

inc/form.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ public function showTargets($ID, $options = []) {
558558
$targetItemUrl = Toolbox::getItemTypeFormURL($targetType) . '?id=' . $targetId;
559559
echo '<td onclick="document.location=\'' . $targetItemUrl . '\'" style="cursor: pointer">';
560560

561-
echo $target->fields['name'];
561+
echo $target->fields['target_name'];
562562
echo '</td>';
563563

564564
echo '<td align="center" width="32">';
@@ -2439,7 +2439,7 @@ public function showAddTargetForm() {
24392439

24402440
echo '<tr class="line1">';
24412441
echo '<td width="15%"><strong>'.__('Name').' <span style="color:red;">*</span></strong></td>';
2442-
echo '<td width="40%"><input type="text" name="name" style="width:100%;" value="" /></td>';
2442+
echo '<td width="40%"><input type="text" name="target_name" style="width:100%;" value="" /></td>';
24432443
echo '<td width="15%"><strong>'._n('Type', 'Types', 1).' <span style="color:red;">*</span></strong></td>';
24442444
echo '<td width="30%">';
24452445
$targetTypes = [];

inc/targetchange.class.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ public function showForm($options = []) {
252252
echo '<div class="center" style="width: 950px; margin: 0 auto;">';
253253
echo '<form name="form_target" method="post" action="' . self::getFormURL() . '">';
254254

255+
// General information: target_name
256+
echo '<table class="tab_cadre_fixe">';
257+
echo '<tr><th colspan="2">' . __('Edit a destination', 'formcreator') . '</th></tr>';
258+
echo '<tr class="line1">';
259+
echo '<td width="15%"><strong>' . __('Name') . ' <span style="color:red;">*</span></strong></td>';
260+
echo '<td width="85%"><input type="text" name="target_name" style="width:704px;" value="' . $this->fields['target_name'] . '" /></td>';
261+
echo '</tr>';
262+
echo '</table>';
263+
255264
// change information: title, template...
256265
echo '<table class="tab_cadre_fixe">';
257266

inc/targetticket.class.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,22 @@ static function getEnumAssociateRule() {
9393
* @return void
9494
*/
9595
public function showForm($ID, $options = []) {
96-
global $CFG_GLPI, $DB;
97-
9896
$rand = mt_rand();
9997

10098
$form = $this->getForm();
10199

102100
echo '<div class="center" style="width: 950px; margin: 0 auto;">';
103101
echo '<form name="form_target" method="post" action="' . self::getFormURL() . '">';
104102

103+
// General information: target_name
104+
echo '<table class="tab_cadre_fixe">';
105+
echo '<tr><th colspan="2">' . __('Edit a destination', 'formcreator') . '</th></tr>';
106+
echo '<tr class="line1">';
107+
echo '<td width="15%"><strong>' . __('Name') . ' <span style="color:red;">*</span></strong></td>';
108+
echo '<td width="85%"><input type="text" name="target_name" style="width:704px;" value="' . $this->fields['target_name'] . '" /></td>';
109+
echo '</tr>';
110+
echo '</table>';
111+
105112
// Ticket information: title, template...
106113
echo '<table class="tab_cadre_fixe">';
107114

install/mysql/plugin_formcreator_empty.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targettickets` (
181181
`id` int(11) NOT NULL AUTO_INCREMENT,
182182
`name` varchar(255) NOT NULL DEFAULT '',
183183
`plugin_formcreator_forms_id` int(11) NOT NULL,
184+
`target_name` varchar(255) NOT NULL DEFAULT '',
184185
`tickettemplates_id` int(11) DEFAULT NULL,
185186
`content` longtext,
186187
`due_date_rule` int(11) DEFAULT '1',

install/upgrade_to_2.9.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function upgrade(Migration $migration) {
4848
$formFk = 'plugin_formcreator_forms_id';
4949
foreach ($tables as $table) {
5050
$migration->addField($table, $formFk, 'integer', ['after' => 'name']);
51+
$migration->addField($table, 'target_name', 'string', ['after' => $formFk]);
5152
$migration->addField($table, 'uuid', 'string');
5253
$migration->migrationOneTable($table);
5354
}
@@ -68,7 +69,8 @@ public function upgrade(Migration $migration) {
6869
$table,
6970
[
7071
$formFk => $target[$formFk],
71-
'uuid' => plugin_formcreator_getUuid(),
72+
'uuid' => $target['uuid'],
73+
'target_name' => $target['name'],
7274
],
7375
[
7476
'id' => $target['items_id'],

0 commit comments

Comments
 (0)