File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -961,7 +961,9 @@ function plugin_formcreator_hideAllParameters() {
961961 ];
962962 dropdown::showFromArray ('show_ticket_categories ' , $ ticketCategoriesOptions , [
963963 'rand ' => $ rand ,
964- 'value ' => $ decodedValues ['show_ticket_categories ' ]
964+ 'value ' => isset ($ decodedValues ['show_ticket_categories ' ])
965+ ? $ decodedValues ['show_ticket_categories ' ]
966+ : 'both '
965967 ]);
966968 echo '</td> ' ;
967969 echo '<td> ' ;
@@ -972,7 +974,9 @@ function plugin_formcreator_hideAllParameters() {
972974 echo '<td> ' ;
973975 dropdown::showNumber ('show_ticket_categories_depth ' , [
974976 'rand ' => $ rand ,
975- 'value ' => $ decodedValues ['show_ticket_categories_depth ' ],
977+ 'value ' => isset ($ decodedValues ['show_ticket_categories_depth ' ])
978+ ? $ decodedValues ['show_ticket_categories_depth ' ]
979+ : 0 ,
976980 'min ' => 1 ,
977981 'max ' => 16 ,
978982 'toadd ' => [0 => __ ('No limit ' , 'formcreator ' )],
Original file line number Diff line number Diff line change @@ -88,4 +88,24 @@ function plugin_formcreator_update_2_7(Migration $migration) {
8888 $ id = $ row ['id ' ];
8989 $ DB ->query ("UPDATE `glpi_plugin_formcreator_questions` SET `name`=' $ name' WHERE `id` = ' $ id' " );
9090 }
91+
92+ // Add properties for dropdown of ticket categories
93+ $ request = [
94+ 'FROM ' => 'glpi_plugin_formcreator_questions ' ,
95+ 'WHERE ' => [
96+ 'fieldtype ' => 'dropdown '
97+ ],
98+ ];
99+ foreach ($ DB ->request ($ request ) as $ row ) {
100+ $ values = json_decode ($ row ['values ' ], true );
101+ if (!isset ($ values ['show_ticket_categories ' ])) {
102+ $ values ['show_ticket_categories ' ] = 'both ' ;
103+ }
104+ if (!isset ($ values ['show_ticket_categories_depth ' ])) {
105+ $ values ['show_ticket_categories_depth ' ] = '0 ' ;
106+ }
107+ $ id = $ row ['id ' ];
108+ $ values = json_encode ($ values );
109+ $ DB ->query ("UPDATE `glpi_plugin_formcreator_questions` SET `values`=' $ values' WHERE `id` = ' $ id' " );
110+ }
91111}
You can’t perform that action at this time.
0 commit comments