@@ -437,7 +437,7 @@ protected function setTargetUrgency($data, $formanswer) {
437
437
* find all actors and prepare data for the ticket being created
438
438
*/
439
439
protected function prepareActors (PluginFormcreatorForm $ form , PluginFormcreatorFormAnswer $ formanswer ) {
440
- global $ DB ;
440
+ global $ DB , $ PLUGIN_HOOKS ;
441
441
442
442
$ rows = $ DB ->request ([
443
443
'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -586,6 +586,26 @@ protected function prepareActors(PluginFormcreatorForm $form, PluginFormcreatorF
586
586
$ this ->addActor (PluginFormcreatorTarget_Actor::ACTOR_ROLE_SUPPLIER , $ userId , $ notify );
587
587
}
588
588
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 ;
589
609
}
590
610
}
591
611
}
@@ -1760,7 +1780,7 @@ protected function showActorSettingsHeader($type) {
1760
1780
* @return void
1761
1781
*/
1762
1782
protected function showActorSettingsForType ($ actorType , array $ actors ) {
1763
- global $ DB ;
1783
+ global $ DB , $ PLUGIN_HOOKS ;
1764
1784
1765
1785
$ itemActor = new PluginFormcreatorTarget_Actor ();
1766
1786
$ dropdownItems = ['' => Dropdown::EMPTY_VALUE ] + $ itemActor ::getEnumActorType ();
@@ -1799,21 +1819,21 @@ protected function showActorSettingsForType($actorType, array $actors) {
1799
1819
]
1800
1820
);
1801
1821
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 . ' "> ' ;
1803
1823
User::dropdown ([
1804
1824
'name ' => 'actor_value_ ' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON ,
1805
1825
'right ' => 'all ' ,
1806
1826
'all ' => 0 ,
1807
1827
]);
1808
1828
echo '</div> ' ;
1809
1829
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 . ' "> ' ;
1811
1831
Group::dropdown ([
1812
1832
'name ' => 'actor_value_ ' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP ,
1813
1833
]);
1814
1834
echo '</div> ' ;
1815
1835
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 . ' "> ' ;
1817
1837
// find already used items
1818
1838
$ request = $ DB ->request ([
1819
1839
'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1850,7 +1870,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
1850
1870
);
1851
1871
echo '</div> ' ;
1852
1872
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 . ' "> ' ;
1854
1874
// find already used items
1855
1875
$ request = $ DB ->request ([
1856
1876
'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1880,7 +1900,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
1880
1900
);
1881
1901
echo '</div> ' ;
1882
1902
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 . ' "> ' ;
1884
1904
// find already used items
1885
1905
$ request = $ DB ->request ([
1886
1906
'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1909,7 +1929,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
1909
1929
);
1910
1930
echo '</div> ' ;
1911
1931
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 . ' "> ' ;
1913
1933
// find already used items
1914
1934
$ request = $ DB ->request ([
1915
1935
'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1938,7 +1958,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
1938
1958
);
1939
1959
echo '</div> ' ;
1940
1960
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 . ' "> ' ;
1942
1962
// find already used items
1943
1963
$ request = $ DB ->request ([
1944
1964
'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1968,7 +1988,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
1968
1988
echo '</div> ' ;
1969
1989
1970
1990
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 . ' "> ' ;
1972
1992
// find already used items
1973
1993
$ request = $ DB ->request ([
1974
1994
'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -1990,7 +2010,7 @@ protected function showActorSettingsForType($actorType, array $actors) {
1990
2010
]);
1991
2011
echo '</div> ' ;
1992
2012
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 . ' "> ' ;
1994
2014
// find already used items
1995
2015
$ request = $ DB ->request ([
1996
2016
'FROM ' => PluginFormcreatorTarget_Actor::getTable (),
@@ -2021,6 +2041,19 @@ protected function showActorSettingsForType($actorType, array $actors) {
2021
2041
echo '</div> ' ;
2022
2042
}
2023
2043
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
+
2024
2057
echo '<div> ' ;
2025
2058
echo __ ('Email followup ' );
2026
2059
Dropdown::showYesNo ('use_notification ' , 1 );
@@ -2035,11 +2068,11 @@ protected function showActorSettingsForType($actorType, array $actors) {
2035
2068
2036
2069
Html::closeForm ();
2037
2070
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 () ;
2043
2076
2044
2077
foreach ($ actors [$ actorRole ] as $ id => $ values ) {
2045
2078
echo '<div data-itemtype="PluginFormcreatorTarget_Actor" data-id=" ' . $ id . '"> ' ;
@@ -2104,6 +2137,20 @@ protected function showActorSettingsForType($actorType, array $actors) {
2104
2137
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_AUTHORS_SUPERVISOR :
2105
2138
echo $ img_user . ' <b> ' . __ ('Form author \'s supervisor ' , 'formcreator ' ) . '</b> ' ;
2106
2139
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 ;
2107
2154
}
2108
2155
echo $ values ['use_notification ' ] ? ' ' . $ img_mail . ' ' : ' ' . $ img_nomail . ' ' ;
2109
2156
echo $ this ->getDeleteImage ();
@@ -2417,4 +2464,24 @@ public static function findForFormAnswer(PluginFormcreatorFormAnswer $formAnswer
2417
2464
2418
2465
return $ targets ;
2419
2466
}
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
+ }
2420
2487
}
0 commit comments