@@ -437,7 +437,7 @@ protected function setTargetUrgency($data, $formanswer) {
437437 * find all actors and prepare data for the ticket being created
438438 */
439439 protected function prepareActors (PluginFormcreatorForm $ form , PluginFormcreatorFormAnswer $ formanswer ) {
440- global $ DB ;
440+ global $ DB , $ PLUGIN_HOOKS ;
441441
442442 $ rows = $ DB ->request ([
443443 'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -586,6 +586,26 @@ protected function prepareActors(PluginFormcreatorForm $form, PluginFormcreatorF
586586 $ this ->addActor (PluginFormcreatorTarget_Actor::ACTOR_ROLE_SUPPLIER , $ userId , $ notify );
587587 }
588588 break ;
589+ default :
590+ foreach (($ PLUGIN_HOOKS ['formcreator_actors_type ' ] ?? []) as $ plugin => $ classes ) {
591+ foreach ($ classes as $ plugin_target ) {
592+ if (!is_a ($ plugin_target , PluginFormcreatorPluginTargetInterface::class, true )) {
593+ continue ;
594+ }
595+ if ($ actor ['actor_type ' ]== $ plugin_target ::getId ()) {
596+ $ value = $ plugin_target ::getActorId ($ formanswer , $ actor ['actor_value ' ]);
597+ if ($ value ) {
598+ if ($ plugin_target ::getActorType () == PluginFormcreatorPluginTargetInterface::ACTOR_TYPE_USER ) {
599+ $ this ->addActor ($ actor ['actor_role ' ], $ value , $ notify );
600+ } else if (PluginFormcreatorPluginTargetInterface::ACTOR_TYPE_GROUP ) {
601+ $ this ->addGroupActor ($ actor ['actor_role ' ], $ value );
602+ }
603+ }
604+ break 2 ;
605+ }
606+ }
607+ }
608+ break ;
589609 }
590610 }
591611 }
@@ -1760,7 +1780,7 @@ protected function showActorSettingsHeader($type) {
17601780 * @return void
17611781 */
17621782 protected function showActorSettingsForType ($ actorType , array $ actors ) {
1763- global $ DB ;
1783+ global $ DB , $ PLUGIN_HOOKS ;
17641784
17651785 $ itemActor = new PluginFormcreatorTarget_Actor ();
17661786 $ dropdownItems = ['' => Dropdown::EMPTY_VALUE ] + $ itemActor ::getEnumActorType ();
@@ -1799,21 +1819,21 @@ protected function showActorSettingsForType($actorType, array $actors) {
17991819 ]
18001820 );
18011821
1802- echo '<div id="block_ ' . $ type . ' _user" style="display:none "> ' ;
1822+ echo '<div style="display:none" data-actor-type=" ' . $ type . " _ " . PluginFormcreatorTarget_Actor:: ACTOR_TYPE_PERSON . ' "> ' ;
18031823 User::dropdown ([
18041824 'name ' => 'actor_value_ ' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON ,
18051825 'right ' => 'all ' ,
18061826 'all ' => 0 ,
18071827 ]);
18081828 echo '</div> ' ;
18091829
1810- echo '<div id="block_ ' . $ type . ' _group" style="display:none "> ' ;
1830+ echo '<div style="display:none" data-actor-type=" ' . $ type . " _ " . PluginFormcreatorTarget_Actor:: ACTOR_TYPE_GROUP . ' "> ' ;
18111831 Group::dropdown ([
18121832 'name ' => 'actor_value_ ' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP ,
18131833 ]);
18141834 echo '</div> ' ;
18151835
1816- echo '<div id="block_ ' . $ type . ' _question_user" style="display:none "> ' ;
1836+ echo '<div style="display:none" data-actor-type=" ' . $ type . " _ " . PluginFormcreatorTarget_Actor:: ACTOR_TYPE_QUESTION_PERSON . ' "> ' ;
18171837 // find already used items
18181838 $ request = $ DB ->request ([
18191839 'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1850,7 +1870,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
18501870 );
18511871 echo '</div> ' ;
18521872
1853- echo '<div id="block_ ' . $ type . ' _question_group" style="display:none "> ' ;
1873+ echo '<div style="display:none" data-actor-type=" ' . $ type . " _ " . PluginFormcreatorTarget_Actor:: ACTOR_TYPE_QUESTION_GROUP . ' "> ' ;
18541874 // find already used items
18551875 $ request = $ DB ->request ([
18561876 'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1880,7 +1900,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
18801900 );
18811901 echo '</div> ' ;
18821902
1883- echo '<div id="block_ ' . $ type . ' _group_from_object" style="display:none "> ' ;
1903+ echo '<div style="display:none" data-actor-type=" ' . $ type . " _ " . PluginFormcreatorTarget_Actor:: ACTOR_TYPE_GROUP_FROM_OBJECT . ' "> ' ;
18841904 // find already used items
18851905 $ request = $ DB ->request ([
18861906 'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1909,7 +1929,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
19091929 );
19101930 echo '</div> ' ;
19111931
1912- echo '<div id="block_ ' . $ type . ' _tech_group_from_object" style="display:none "> ' ;
1932+ echo '<div style="display:none" data-actor-type=" ' . $ type . " _ " . PluginFormcreatorTarget_Actor:: ACTOR_TYPE_TECH_GROUP_FROM_OBJECT . ' "> ' ;
19131933 // find already used items
19141934 $ request = $ DB ->request ([
19151935 'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1938,7 +1958,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
19381958 );
19391959 echo '</div> ' ;
19401960
1941- echo '<div id="block_ ' . $ type . ' _question_actors" style="display:none "> ' ;
1961+ echo '<div style="display:none" data-actor-type=" ' . $ type . " _ " . PluginFormcreatorTarget_Actor:: ACTOR_TYPE_QUESTION_ACTORS . ' "> ' ;
19421962 // find already used items
19431963 $ request = $ DB ->request ([
19441964 'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1968,7 +1988,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
19681988 echo '</div> ' ;
19691989
19701990 if ($ actorType == CommonITILActor::ASSIGN ) {
1971- echo '<div id="block_ ' . $ type . ' _supplier" style="display:none "> ' ;
1991+ echo '<div style="display:none" data-actor-type=" ' . $ type . " _ " . PluginFormcreatorTarget_Actor:: ACTOR_TYPE_SUPPLIER . ' "> ' ;
19721992 // find already used items
19731993 $ request = $ DB ->request ([
19741994 'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1990,7 +2010,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
19902010 ]);
19912011 echo '</div> ' ;
19922012
1993- echo '<div id="block_ ' . $ type . ' _question_supplier" style="display:none "> ' ;
2013+ echo '<div style="display:none" data-actor-type=" ' . $ type . " _ " . PluginFormcreatorTarget_Actor:: ACTOR_TYPE_QUESTION_SUPPLIER . ' "> ' ;
19942014 // find already used items
19952015 $ request = $ DB ->request ([
19962016 'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -2021,6 +2041,19 @@ protected function showActorSettingsForType($actorType, array $actors) {
20212041 echo '</div> ' ;
20222042 }
20232043
2044+ foreach (($ PLUGIN_HOOKS ['formcreator_actors_type ' ] ?? []) as $ plugin => $ classes ) {
2045+ foreach ($ classes as $ plugin_target ) {
2046+ if (!is_a ($ plugin_target , PluginFormcreatorPluginTargetInterface::class, true )) {
2047+ continue ;
2048+ }
2049+
2050+ // Show custom form
2051+ echo '<div style="display:none" data-actor-type=" ' . $ type . "_ " . $ plugin_target ::getId () . '"> ' ;
2052+ echo $ plugin_target ::getForm ($ this ->getForm ());
2053+ echo '</div> ' ;
2054+ }
2055+ }
2056+
20242057 echo '<div> ' ;
20252058 echo __ ('Email followup ' );
20262059 Dropdown::showYesNo ('use_notification ' , 1 );
@@ -2035,11 +2068,11 @@ protected function showActorSettingsForType($actorType, array $actors) {
20352068
20362069 Html::closeForm ();
20372070
2038- $ img_user = ' <i class="fas fa-user" alt=" ' . __ ( ' User ' ) . ' " title=" ' . __ ( ' User ' ) . ' " width="20"></i> ' ;
2039- $ img_group = ' <i class="fas fa-users" alt=" ' . __ ( ' Group ' ) . ' " title=" ' . __ ( ' Group ' ) . ' " width="20"></i> ' ;
2040- $ img_supplier = ' <i class="fas fa-suitcase" alt=" ' . __ ( ' Supplier ' ) . ' " title=" ' . __ ( ' Supplier ' ) . ' " width="20"></i> ' ;
2041- $ img_mail = ' <i class="fas fa-envelope pointer" title=" ' . __ ( ' Email followup ' ) . ' ' . __ ( ' Yes ' ) . ' " width="20"></i> ' ;
2042- $ img_nomail = ' <i class="fas fa-envelope pointer" title=" ' . __ ( ' Email followup ' ) . ' ' . __ ( ' No ' ) . ' " width="20"></i> ' ;
2071+ $ img_user = static :: getUserImage () ;
2072+ $ img_group = static :: getGroupImage () ;
2073+ $ img_supplier = static :: getSupplierImage () ;
2074+ $ img_mail = static :: getMailImage () ;
2075+ $ img_nomail = static :: getNoMailImage () ;
20432076
20442077 foreach ($ actors [$ actorRole ] as $ id => $ values ) {
20452078 echo '<div data-itemtype="PluginFormcreatorTarget_Actor" data-id=" ' . $ id . '"> ' ;
@@ -2104,6 +2137,20 @@ protected function showActorSettingsForType($actorType, array $actors) {
21042137 case PluginFormcreatorTarget_Actor::ACTOR_TYPE_AUTHORS_SUPERVISOR :
21052138 echo $ img_user . ' <b> ' . __ ('Form author \'s supervisor ' , 'formcreator ' ) . '</b> ' ;
21062139 break ;
2140+ default :
2141+ foreach (($ PLUGIN_HOOKS ['formcreator_actors_type ' ] ?? []) as $ plugin => $ classes ) {
2142+ foreach ($ classes as $ plugin_target ) {
2143+ if (!is_a ($ plugin_target , PluginFormcreatorPluginTargetInterface::class, true )) {
2144+ continue ;
2145+ }
2146+
2147+ if ($ values ['actor_type ' ] == $ plugin_target ::getId ()) {
2148+ echo $ plugin_target ::getDisplayedValue ($ values ['actor_value ' ]);
2149+ break 2 ;
2150+ }
2151+ }
2152+ }
2153+ break ;
21072154 }
21082155 echo $ values ['use_notification ' ] ? ' ' . $ img_mail . ' ' : ' ' . $ img_nomail . ' ' ;
21092156 echo $ this ->getDeleteImage ();
@@ -2417,4 +2464,24 @@ public static function findForFormAnswer(PluginFormcreatorFormAnswer $formAnswer
24172464
24182465 return $ targets ;
24192466 }
2467+
2468+ public static function getUserImage () {
2469+ return '<i class="fas fa-user" alt=" ' . __ ('User ' ) . '" title=" ' . __ ('User ' ) . '" width="20"></i> ' ;
2470+ }
2471+
2472+ public static function getGroupImage () {
2473+ return '<i class="fas fa-users" alt=" ' . __ ('Group ' ) . '" title=" ' . __ ('Group ' ) . '" width="20"></i> ' ;
2474+ }
2475+
2476+ public static function getSupplierImage () {
2477+ return '<i class="fas fa-suitcase" alt=" ' . __ ('Supplier ' ) . '" title=" ' . __ ('Supplier ' ) . '" width="20"></i> ' ;
2478+ }
2479+
2480+ public static function getMailImage () {
2481+ return '<i class="fas fa-envelope pointer" title=" ' . __ ('Email followup ' ) . ' ' . __ ('Yes ' ) . '" width="20"></i> ' ;
2482+ }
2483+
2484+ public static function getNoMailImage () {
2485+ return '<i class="fas fa-envelope pointer" title=" ' . __ ('Email followup ' ) . ' ' . __ ('No ' ) . '" width="20"></i> ' ;
2486+ }
24202487}
0 commit comments