@@ -489,7 +489,9 @@ public function showForm($ID, $options = []) {
489
489
$ form = $ this ->getForm ();
490
490
491
491
$ canEdit = $ this ->fields ['status ' ] == self ::STATUS_REFUSED
492
- && $ _SESSION ['glpiID ' ] == $ this ->fields ['requester_id ' ];
492
+ && Session::getLoginUserID () == $ this ->fields ['requester_id ' ]
493
+ || $ this ->fields ['status ' ] == self ::STATUS_WAITING
494
+ && $ this ->canValidate ();
493
495
494
496
// form title
495
497
echo "<h1 class='form-title'> " ;
@@ -578,9 +580,10 @@ public function showForm($ID, $options = []) {
578
580
579
581
echo '</li> ' ;
580
582
}
581
- if ($ canEdit ) {
583
+
584
+ if ($ canEdit || $ editMode ) {
582
585
echo Html::scriptBlock ('$(function() {
583
- plugin_formcreator.showFields($("form[name= \'form \']"));
586
+ plugin_formcreator.showFields($("form[name= \'' . $ formName . ' \']"));
584
587
}) ' );
585
588
}
586
589
@@ -729,8 +732,14 @@ public function prepareInputForUpdate($input) {
729
732
$ input ['status ' ] = self ::STATUS_ACCEPTED ;
730
733
if (isset ($ input ['refuse_formanswer ' ])) {
731
734
$ input ['status ' ] = self ::STATUS_REFUSED ;
735
+ // Update is restricted to a subset of fields
736
+ $ input = [
737
+ 'id ' => $ input ['id ' ],
738
+ 'status ' => $ input ['status ' ],
739
+ 'comment ' => isset ($ input ['comment ' ]) ? $ input ['comment ' ] : 'NULL ' ,
740
+ ];
741
+ $ skipValidation = true ;
732
742
}
733
- $ skipValidation = true ;
734
743
} else {
735
744
// The form answer is being updated
736
745
$ input ['status ' ] = self ::STATUS_WAITING ;
@@ -741,13 +750,6 @@ public function prepareInputForUpdate($input) {
741
750
return false ;
742
751
}
743
752
744
- // Update is restricted to a subset of fields
745
- $ input = [
746
- 'id ' => $ input ['id ' ],
747
- 'status ' => $ input ['status ' ],
748
- 'comment ' => isset ($ input ['comment ' ]) ? $ input ['comment ' ] : 'NULL ' ,
749
- ];
750
-
751
753
return $ input ;
752
754
}
753
755
0 commit comments