Skip to content

Commit

Permalink
feat(targetticket): actor type: "Form author's manager"
Browse files Browse the repository at this point in the history
aagz authored and btry committed Jul 8, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a61cbf6 commit acefca8
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions inc/abstracttarget.class.php
Original file line number Diff line number Diff line change
@@ -701,6 +701,16 @@ protected function prepareActors(PluginFormcreatorForm $form, PluginFormcreatorF

$userIds = [$object->fields[$groupFk]];
break;

case PluginFormcreatorTarget_Actor::ACTOR_TYPE_AUTHORS_SUPERVISOR:
$requester_id = $formanswer->fields['requester_id'];

$user = new User;
$user = User::getById($requester_id);
if (is_object($user)) {
$userIds = [$user->fields['users_id_supervisor']];
}
break;
}
$notify = $actor['use_notification'];

@@ -710,6 +720,7 @@ protected function prepareActors(PluginFormcreatorForm $form, PluginFormcreatorF
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS:
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_AUTHORS_SUPERVISOR:
foreach ($userIds as $userIdOrEmail) {
$this->addActor($actor['actor_role'], $userIdOrEmail, $notify);
}
@@ -1861,6 +1872,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
break;
case CommonITILActor::ASSIGN:
$type = 'assigned';
unset($dropdownItems[PluginFormcreatorTarget_Actor::ACTOR_TYPE_AUTHORS_SUPERVISOR]);
$changeActorJSFunction = 'plugin_formcreator_ChangeActorAssigned(this.value)';
$actorRole = PluginFormcreatorTarget_Actor::ACTOR_ROLE_ASSIGNED;
break;
@@ -2055,6 +2067,9 @@ protected function showActorSettingsForType($actorType, array $actors) {
echo $img_supplier . ' <b>' . __('Supplier from the question', 'formcreator')
. '</b> "' . $question->getName() . '"';
break;
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_AUTHORS_SUPERVISOR :
echo $img_user . ' <b>' . __('Form author\'s supervisor', 'formcreator') . '</b>';
break;
}
echo $values['use_notification'] ? ' ' . $img_mail . ' ' : ' ' . $img_nomail . ' ';
echo self::getDeleteImage($id);
5 changes: 5 additions & 0 deletions inc/target_actor.class.php
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@ class PluginFormcreatorTarget_Actor extends CommonDBChild implements PluginFormc
const ACTOR_TYPE_QUESTION_ACTORS = 9;
const ACTOR_TYPE_GROUP_FROM_OBJECT = 10;
const ACTOR_TYPE_TECH_GROUP_FROM_OBJECT = 11;
CONST ACTOR_TYPE_AUTHORS_SUPERVISOR = 12;

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

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

case self::ACTOR_TYPE_PERSON:
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
$user = new User;
$users_id = plugin_formcreator_getFromDBByField($user, 'name', $input['actor_value']);
if ($users_id === false) {
@@ -221,6 +225,7 @@ public function export(bool $remove_uuid = false) : array {
}
break;
case self::ACTOR_TYPE_PERSON:
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
$user = new User;
if ($user->getFromDB($target_actor['actor_value'])) {
$target_actor['actor_value'] = $user->fields['name'];

0 comments on commit acefca8

Please sign in to comment.