Skip to content

Commit 87d7bc5

Browse files
committed
fix(targetticket,targetchange): editing actors
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 5ab2460 commit 87d7bc5

File tree

3 files changed

+88
-107
lines changed

3 files changed

+88
-107
lines changed

front/targetticket.form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
$targetticket = new PluginFormcreatorTargetTicket();
4242

4343
// Edit an existing target ticket
44-
if (isset($_POST["update"])) {
44+
if (isset($_POST['update'])) {
4545
$targetticket->update($_POST);
4646
Html::back();
4747

inc/targetbase.class.php

Lines changed: 48 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ protected function showDueDateSettings(PluginFormcreatorForm $form, $rand) {
776776
Dropdown::showFromArray('due_date_rule', self::getEnumDueDateRule(),
777777
[
778778
'value' => $this->fields['due_date_rule'],
779-
'on_change' => 'formcreatorChangeDueDate(this.value)',
779+
'on_change' => 'plugin_formcreator_formcreatorChangeDueDate(this.value)',
780780
'display_emptychoice' => true
781781
]
782782
);
@@ -1102,27 +1102,27 @@ protected function showActorsSettings() {
11021102
// Requester header
11031103
echo '<th width="33%">';
11041104
echo _n('Requester', 'Requesters', 1) . ' &nbsp;';
1105-
echo '<img title="Ajouter" alt="Ajouter" onclick="displayRequesterForm()" class="pointer"
1105+
echo '<img title="Ajouter" alt="Ajouter" onclick="plugin_formcreator_displayRequesterForm()" class="pointer"
11061106
id="btn_add_requester" src="../../../pics/add_dropdown.png">';
1107-
echo '<img title="Annuler" alt="Annuler" onclick="hideRequesterForm()" class="pointer"
1107+
echo '<img title="Annuler" alt="Annuler" onclick="plugin_formcreator_hideRequesterForm()" class="pointer"
11081108
id="btn_cancel_requester" src="../../../pics/delete.png" style="display:none">';
11091109
echo '</th>';
11101110

11111111
// Watcher header
11121112
echo '<th width="34%">';
11131113
echo _n('Watcher', 'Watchers', 1) . ' &nbsp;';
1114-
echo '<img title="Ajouter" alt="Ajouter" onclick="displayWatcherForm()" class="pointer"
1114+
echo '<img title="Ajouter" alt="Ajouter" onclick="plugin_formcreator_displayWatcherForm()" class="pointer"
11151115
id="btn_add_watcher" src="../../../pics/add_dropdown.png">';
1116-
echo '<img title="Annuler" alt="Annuler" onclick="hideWatcherForm()" class="pointer"
1116+
echo '<img title="Annuler" alt="Annuler" onclick="plugin_formcreator_hideWatcherForm()" class="pointer"
11171117
id="btn_cancel_watcher" src="../../../pics/delete.png" style="display:none">';
11181118
echo '</th>';
11191119

11201120
// Assigned header
11211121
echo '<th width="33%">';
11221122
echo __('Assigned to') . ' &nbsp;';
1123-
echo '<img title="Ajouter" alt="Ajouter" onclick="displayAssignedForm()" class="pointer"
1123+
echo '<img title="Ajouter" alt="Ajouter" onclick="plugin_formcreator_displayAssignedForm()" class="pointer"
11241124
id="btn_add_assigned" src="../../../pics/add_dropdown.png">';
1125-
echo '<img title="Annuler" alt="Annuler" onclick="hideAssignedForm()" class="pointer"
1125+
echo '<img title="Annuler" alt="Annuler" onclick="plugin_formcreator_hideAssignedForm()" class="pointer"
11261126
id="btn_cancel_assigned" src="../../../pics/delete.png" style="display:none">';
11271127
echo '</th>';
11281128

@@ -1143,45 +1143,39 @@ protected function showActorsSettings() {
11431143
Dropdown::showFromArray(
11441144
'actor_type',
11451145
$dropdownItems, [
1146-
'on_change' => 'formcreatorChangeActorRequester(this.value)'
1146+
'on_change' => 'plugin_formcreator_ChangeActorRequester(this.value)'
11471147
]
11481148
);
11491149

11501150
echo '<div id="block_requester_user" style="display:none">';
11511151
User::dropdown([
1152-
'name' => 'actor_value_person',
1152+
'name' => 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON,
11531153
'right' => 'all',
11541154
'all' => 0,
11551155
]);
11561156
echo '</div>';
11571157

11581158
echo '<div id="block_requester_group" style="display:none">';
11591159
Group::dropdown([
1160-
'name' => 'actor_value_group',
1160+
'name' => 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP,
11611161
]);
11621162
echo '</div>';
11631163

11641164
echo '<div id="block_requester_question_user" style="display:none">';
1165-
// Dropdown::showFromArray('actor_value_question_person', $questions_user_list, [
1166-
// 'value' => $this->fields['due_date_question'],
1167-
// ]);
11681165
PluginFormcreatorQuestion::dropdownForForm(
11691166
$this->getForm()->getID(),
11701167
[
11711168
'fieldtype' => ['glpiselect'],
11721169
'values' => User::class,
11731170
],
1174-
'actor_value_question_person',
1171+
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON,
11751172
[
11761173
'value' => 0
11771174
]
11781175
);
11791176
echo '</div>';
11801177

11811178
echo '<div id="block_requester_question_group" style="display:none">';
1182-
// Dropdown::showFromArray('actor_value_question_group', $questions_group_list, [
1183-
// 'value' => $this->fields['due_date_question'],
1184-
// ]);
11851179
PluginFormcreatorQuestion::dropdownForForm(
11861180
$this->getForm()->getID(),
11871181
[
@@ -1196,15 +1190,12 @@ protected function showActorsSettings() {
11961190
echo '</div>';
11971191

11981192
echo '<div id="block_requester_question_actors" style="display:none">';
1199-
// Dropdown::showFromArray('actor_value_question_actors', $questions_actors_list, [
1200-
// 'value' => $this->fields['due_date_question'],
1201-
// ]);
12021193
PluginFormcreatorQuestion::dropdownForForm(
12031194
$this->getForm()->getID(),
12041195
[
12051196
'fieldtype' => ['actor'],
12061197
],
1207-
'actor_value_question_person',
1198+
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS,
12081199
[
12091200
'value' => 0
12101201
]
@@ -1218,7 +1209,7 @@ protected function showActorsSettings() {
12181209

12191210
echo '<p align="center">';
12201211
echo '<input type="hidden" name="id" value="' . $this->getID() . '" />';
1221-
echo '<input type="hidden" name="actor_role" value="requester" />';
1212+
echo '<input type="hidden" name="actor_role" value="' . PluginFormcreatorTarget_Actor::ACTOR_ROLE_REQUESTER . '" />';
12221213
echo '<input type="submit" value="' . __('Add') . '" class="submit_button" />';
12231214
echo '</p>';
12241215

@@ -1283,67 +1274,58 @@ protected function showActorsSettings() {
12831274
unset($dropdownItems['supplier']);
12841275
unset($dropdownItems['question_supplier']);
12851276
Dropdown::showFromArray('actor_type',
1286-
$dropdownItems, ['on_change' => 'formcreatorChangeActorWatcher(this.value)']
1277+
$dropdownItems, ['on_change' => 'plugin_formcreator_ChangeActorWatcher(this.value)']
12871278
);
12881279

12891280
echo '<div id="block_watcher_user" style="display:none">';
12901281
User::dropdown([
1291-
'name' => 'actor_value_person',
1282+
'name' => 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON,
12921283
'right' => 'all',
12931284
'all' => 0,
12941285
]);
12951286
echo '</div>';
12961287

12971288
echo '<div id="block_watcher_group" style="display:none">';
12981289
Group::dropdown([
1299-
'name' => 'actor_value_group',
1290+
'name' => 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP,
13001291
]);
13011292
echo '</div>';
13021293

13031294
echo '<div id="block_watcher_question_user" style="display:none">';
1304-
// Dropdown::showFromArray('actor_value_question_person', $questions_user_list, [
1305-
// 'value' => $this->fields['due_date_question'],
1306-
// ]);
13071295
PluginFormcreatorQuestion::dropdownForForm(
13081296
$this->getForm()->getID(),
13091297
[
13101298
'fieldtype' => ['glpiselect'],
13111299
'values' => User::class,
13121300
],
1313-
'actor_value_question_person',
1301+
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON,
13141302
[
13151303
'value' => 0
13161304
]
13171305
);
13181306
echo '</div>';
13191307

13201308
echo '<div id="block_watcher_question_group" style="display:none">';
1321-
// Dropdown::showFromArray('actor_value_question_group', $questions_group_list, [
1322-
// 'value' => $this->fields['due_date_question'],
1323-
// ]);
13241309
PluginFormcreatorQuestion::dropdownForForm(
13251310
$this->getForm()->getID(),
13261311
[
13271312
'fieldtype' => ['glpiselect'],
13281313
'values' => Group::class,
13291314
],
1330-
'actor_value_question_person',
1315+
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_GROUP,
13311316
[
13321317
'value' => 0
13331318
]
13341319
);
13351320
echo '</div>';
13361321

13371322
echo '<div id="block_watcher_question_actors" style="display:none">';
1338-
// Dropdown::showFromArray('actor_value_question_actors', $questions_actors_list, [
1339-
// 'value' => $this->fields['due_date_question'],
1340-
// ]);
13411323
PluginFormcreatorQuestion::dropdownForForm(
13421324
$this->getForm()->getID(),
13431325
[
13441326
'fieldtype' => ['actor'],
13451327
],
1346-
'actor_value_question_person',
1328+
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS,
13471329
[
13481330
'value' => 0
13491331
]
@@ -1357,7 +1339,7 @@ protected function showActorsSettings() {
13571339

13581340
echo '<p align="center">';
13591341
echo '<input type="hidden" name="id" value="' . $this->getID() . '" />';
1360-
echo '<input type="hidden" name="actor_role" value="observer" />';
1342+
echo '<input type="hidden" name="actor_role" value="' . PluginFormcreatorTarget_Actor::ACTOR_ROLE_OBSERVER . '" />';
13611343
echo '<input type="submit" value="' . __('Add') . '" class="submit_button" />';
13621344
echo '</p>';
13631345

@@ -1422,91 +1404,79 @@ protected function showActorsSettings() {
14221404
Dropdown::showFromArray(
14231405
'actor_type',
14241406
$dropdownItems, [
1425-
'on_change' => 'formcreatorChangeActorAssigned(this.value)'
1407+
'on_change' => 'plugin_formcreator_ChangeActorAssigned(this.value)'
14261408
]
14271409
);
14281410

14291411
echo '<div id="block_assigned_user" style="display:none">';
14301412
User::dropdown([
1431-
'name' => 'actor_value_person',
1413+
'name' => 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON,
14321414
'right' => 'all',
14331415
'all' => 0,
14341416
]);
14351417
echo '</div>';
14361418

14371419
echo '<div id="block_assigned_group" style="display:none">';
14381420
Group::dropdown([
1439-
'name' => 'actor_value_group',
1421+
'name' => 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP,
14401422
]);
14411423
echo '</div>';
14421424

14431425
echo '<div id="block_assigned_supplier" style="display:none">';
14441426
Supplier::dropdown([
1445-
'name' => 'actor_value_supplier',
1427+
'name' => 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_SUPPLIER,
14461428
]);
14471429
echo '</div>';
14481430

14491431
echo '<div id="block_assigned_question_user" style="display:none">';
1450-
// Dropdown::showFromArray('actor_value_question_person', $questions_user_list, [
1451-
// 'value' => $this->fields['due_date_question'],
1452-
// ]);
14531432
PluginFormcreatorQuestion::dropdownForForm(
14541433
$this->getForm()->getID(),
14551434
[
14561435
'fieldtype' => ['glpiselect'],
14571436
'values' => User::class,
14581437
],
1459-
'actor_value_question_person',
1438+
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON,
14601439
[
14611440
'value' => 0
14621441
]
14631442
);
14641443
echo '</div>';
14651444

14661445
echo '<div id="block_assigned_question_group" style="display:none">';
1467-
// Dropdown::showFromArray('actor_value_question_group', $questions_group_list, [
1468-
// 'value' => $this->fields['due_date_question'],
1469-
// ]);
14701446
PluginFormcreatorQuestion::dropdownForForm(
14711447
$this->getForm()->getID(),
14721448
[
14731449
'fieldtype' => ['glpiselect'],
14741450
'values' => Group::class,
14751451
],
1476-
'actor_value_question_person',
1452+
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP,
14771453
[
14781454
'value' => 0
14791455
]
14801456
);
14811457
echo '</div>';
14821458

14831459
echo '<div id="block_assigned_question_actors" style="display:none">';
1484-
// Dropdown::showFromArray('actor_value_question_actors', $questions_actors_list, [
1485-
// 'value' => $this->fields['due_date_question'],
1486-
// ]);
14871460
PluginFormcreatorQuestion::dropdownForForm(
14881461
$this->getForm()->getID(),
14891462
[
14901463
'fieldtype' => ['actor'],
14911464
],
1492-
'actor_value_question_person',
1465+
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS,
14931466
[
14941467
'value' => 0
14951468
]
14961469
);
14971470
echo '</div>';
14981471

14991472
echo '<div id="block_assigned_question_supplier" style="display:none">';
1500-
// Dropdown::showFromArray('actor_value_question_supplier', $questions_supplier_list, [
1501-
// 'value' => $this->fields['due_date_question'],
1502-
// ]);
15031473
PluginFormcreatorQuestion::dropdownForForm(
15041474
$this->getForm()->getID(),
15051475
[
15061476
'fieldtype' => ['glpiselect'],
15071477
'values' => Supplier::class,
15081478
],
1509-
'actor_value_question_person',
1479+
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_SUPPLIER,
15101480
[
15111481
'value' => 0
15121482
]
@@ -1520,7 +1490,7 @@ protected function showActorsSettings() {
15201490

15211491
echo '<p align="center">';
15221492
echo '<input type="hidden" name="id" value="' . $this->getID() . '" />';
1523-
echo '<input type="hidden" name="actor_role" value="assigned" />';
1493+
echo '<input type="hidden" name="actor_role" value="' . PluginFormcreatorTarget_Actor::ACTOR_ROLE_ASSIGNED . '" />';
15241494
echo '<input type="submit" value="' . __('Add') . '" class="submit_button" />';
15251495
echo '</p>';
15261496

@@ -1816,23 +1786,25 @@ public function prepareInputForUpdate($input) {
18161786
}
18171787

18181788
public function post_addItem() {
1819-
if (!$this->skipCreateActors) {
1820-
$target_actor = $this->getItem_Actor();
1821-
$myFk = self::getForeignKeyField();
1822-
$target_actor->add([
1823-
$myFk => $this->getID(),
1824-
'actor_role' => PluginFormcreatorTarget_Actor::ACTOR_ROLE_REQUESTER,
1825-
'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_CREATOR,
1826-
'use_notification' => '1',
1827-
]);
1828-
$target_actor = $this->getItem_Actor();
1829-
$target_actor->add([
1830-
$myFk => $this->getID(),
1831-
'actor_role' => PluginFormcreatorTarget_Actor::ACTOR_ROLE_OBSERVER,
1832-
'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_VALIDATOR,
1833-
'use_notification' => '1',
1834-
]);
1835-
}
1789+
if ($this->skipCreateActors) {
1790+
return;
1791+
}
1792+
1793+
$target_actor = $this->getItem_Actor();
1794+
$myFk = self::getForeignKeyField();
1795+
$target_actor->add([
1796+
$myFk => $this->getID(),
1797+
'actor_role' => PluginFormcreatorTarget_Actor::ACTOR_ROLE_REQUESTER,
1798+
'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_CREATOR,
1799+
'use_notification' => '1',
1800+
]);
1801+
$target_actor = $this->getItem_Actor();
1802+
$target_actor->add([
1803+
$myFk => $this->getID(),
1804+
'actor_role' => PluginFormcreatorTarget_Actor::ACTOR_ROLE_OBSERVER,
1805+
'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_VALIDATOR,
1806+
'use_notification' => '1',
1807+
]);
18361808
}
18371809

18381810
protected static function getDeleteImage($id) {

0 commit comments

Comments
 (0)