Skip to content

Commit acefca8

Browse files
aagzbtry
authored andcommitted
feat(targetticket): actor type: "Form author's manager"
1 parent a61cbf6 commit acefca8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

inc/abstracttarget.class.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,16 @@ protected function prepareActors(PluginFormcreatorForm $form, PluginFormcreatorF
701701

702702
$userIds = [$object->fields[$groupFk]];
703703
break;
704+
705+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_AUTHORS_SUPERVISOR:
706+
$requester_id = $formanswer->fields['requester_id'];
707+
708+
$user = new User;
709+
$user = User::getById($requester_id);
710+
if (is_object($user)) {
711+
$userIds = [$user->fields['users_id_supervisor']];
712+
}
713+
break;
704714
}
705715
$notify = $actor['use_notification'];
706716

@@ -710,6 +720,7 @@ protected function prepareActors(PluginFormcreatorForm $form, PluginFormcreatorF
710720
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON :
711721
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON :
712722
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS:
723+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_AUTHORS_SUPERVISOR:
713724
foreach ($userIds as $userIdOrEmail) {
714725
$this->addActor($actor['actor_role'], $userIdOrEmail, $notify);
715726
}
@@ -1861,6 +1872,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
18611872
break;
18621873
case CommonITILActor::ASSIGN:
18631874
$type = 'assigned';
1875+
unset($dropdownItems[PluginFormcreatorTarget_Actor::ACTOR_TYPE_AUTHORS_SUPERVISOR]);
18641876
$changeActorJSFunction = 'plugin_formcreator_ChangeActorAssigned(this.value)';
18651877
$actorRole = PluginFormcreatorTarget_Actor::ACTOR_ROLE_ASSIGNED;
18661878
break;
@@ -2055,6 +2067,9 @@ protected function showActorSettingsForType($actorType, array $actors) {
20552067
echo $img_supplier . ' <b>' . __('Supplier from the question', 'formcreator')
20562068
. '</b> "' . $question->getName() . '"';
20572069
break;
2070+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_AUTHORS_SUPERVISOR :
2071+
echo $img_user . ' <b>' . __('Form author\'s supervisor', 'formcreator') . '</b>';
2072+
break;
20582073
}
20592074
echo $values['use_notification'] ? ' ' . $img_mail . ' ' : ' ' . $img_nomail . ' ';
20602075
echo self::getDeleteImage($id);

inc/target_actor.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class PluginFormcreatorTarget_Actor extends CommonDBChild implements PluginFormc
5454
const ACTOR_TYPE_QUESTION_ACTORS = 9;
5555
const ACTOR_TYPE_GROUP_FROM_OBJECT = 10;
5656
const ACTOR_TYPE_TECH_GROUP_FROM_OBJECT = 11;
57+
CONST ACTOR_TYPE_AUTHORS_SUPERVISOR = 12;
5758

5859
const ACTOR_ROLE_REQUESTER = 1;
5960
const ACTOR_ROLE_OBSERVER = 2;
@@ -73,6 +74,7 @@ static function getEnumActorType() {
7374
self::ACTOR_TYPE_SUPPLIER => __('Specific supplier', 'formcreator'),
7475
self::ACTOR_TYPE_QUESTION_SUPPLIER => __('Supplier from the question', 'formcreator'),
7576
self::ACTOR_TYPE_QUESTION_ACTORS => __('Actors from the question', 'formcreator'),
77+
self::ACTOR_TYPE_AUTHORS_SUPERVISOR => __('Form author\'s supervisor', 'formcreator'),
7678
];
7779
}
7880

@@ -126,6 +128,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
126128
case self::ACTOR_TYPE_QUESTION_SUPPLIER :
127129
case self::ACTOR_TYPE_GROUP_FROM_OBJECT :
128130
case self::ACTOR_TYPE_TECH_GROUP_FROM_OBJECT :
131+
/** @var PluginFormcreatorQuestion $question */
129132
$question = $linker->getObject($input['actor_value'], PluginFormcreatorQuestion::class);
130133
if ($question === false) {
131134
$linker->postpone($input[$idKey], $item->getType(), $input, $containerId);
@@ -135,6 +138,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
135138
break;
136139

137140
case self::ACTOR_TYPE_PERSON:
141+
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
138142
$user = new User;
139143
$users_id = plugin_formcreator_getFromDBByField($user, 'name', $input['actor_value']);
140144
if ($users_id === false) {
@@ -221,6 +225,7 @@ public function export(bool $remove_uuid = false) : array {
221225
}
222226
break;
223227
case self::ACTOR_TYPE_PERSON:
228+
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
224229
$user = new User;
225230
if ($user->getFromDB($target_actor['actor_value'])) {
226231
$target_actor['actor_value'] = $user->fields['name'];

0 commit comments

Comments
 (0)