@@ -49,7 +49,6 @@ class PluginFormcreatorFormAnswer extends CommonDBTM
4949
5050 private $ questionFields = [];
5151 private $ questions = [];
52- private $ form = null ;
5352
5453 public static function getStatuses () {
5554 return [
@@ -753,10 +752,10 @@ public function pre_deleteItem() {
753752 /**
754753 * Create or update answers of a form
755754 *
756- * @param PluginFormcreatorForm $form
757- * @param array $data answers
758- * @param array $fields array of field: question id => instance
759- * @return integer ID of the created or updated Form Answer
755+ * @param PluginFormcreatorForm $form
756+ * @param array $data answers
757+ * @param array $fields array of field: question id => instance
758+ * @return integer ID of the created or updated Form Answer
760759 */
761760 public function saveAnswers (PluginFormcreatorForm $ form , $ data , $ fields ) {
762761 global $ DB ;
@@ -819,13 +818,13 @@ public function saveAnswers(PluginFormcreatorForm $form, $data, $fields) {
819818
820819 $ formanswers_id = $ this ->add ([
821820 'entities_id ' => isset ($ _SESSION ['glpiactive_entity ' ])
822- ? $ _SESSION ['glpiactive_entity ' ]
823- : $ form ->fields ['entities_id ' ],
821+ ? $ _SESSION ['glpiactive_entity ' ]
822+ : $ form ->fields ['entities_id ' ],
824823 'is_recursive ' => $ form ->fields ['is_recursive ' ],
825824 'plugin_formcreator_forms_id ' => $ form ->getID (),
826825 'requester_id ' => isset ($ _SESSION ['glpiID ' ])
827- ? $ _SESSION ['glpiID ' ]
828- : 0 ,
826+ ? $ _SESSION ['glpiID ' ]
827+ : 0 ,
829828 'users_id_validator ' => $ usersIdValidator ,
830829 'groups_id_validator ' => $ groupIdValidator ,
831830 'status ' => $ status ,
@@ -1088,8 +1087,9 @@ public function generateTarget() {
10881087 $ success = true ;
10891088
10901089 // Get all targets
1091- $ this ->form ->getFromDB ($ this ->fields ['plugin_formcreator_forms_id ' ]);
1092- $ all_targets = $ this ->form ->getTargetsFromForm ();
1090+ $ form = new PluginFormcreatorForm ();
1091+ $ form ->getFromDB ($ this ->fields ['plugin_formcreator_forms_id ' ]);
1092+ $ all_targets = $ form ->getTargetsFromForm ();
10931093
10941094 $ CFG_GLPI ['plugin_formcreator_disable_hook_create_ticket ' ] = '1 ' ;
10951095
@@ -1400,13 +1400,13 @@ public function parseTags($content, PluginFormcreatorTargetInterface $target, $r
14001400 */
14011401 protected function validateFormAnswer ($ input ) {
14021402 // Find the form the requester is answering to
1403- $ this -> form = new PluginFormcreatorForm ();
1404- $ this -> form ->getFromDB ($ input ['plugin_formcreator_forms_id ' ]);
1403+ $ form = new PluginFormcreatorForm ();
1404+ $ form ->getFromDB ($ input ['plugin_formcreator_forms_id ' ]);
14051405
14061406 $ valid = true ;
14071407 $ fieldValidities = [];
14081408
1409- $ this ->questionFields = $ this -> form ->getFields ();
1409+ $ this ->questionFields = $ form ->getFields ();
14101410 foreach ($ this ->questionFields as $ id => $ question ) {
14111411 $ fieldValidities [$ id ] = $ this ->questionFields [$ id ]->parseAnswerValues ($ input );
14121412 }
@@ -1428,7 +1428,7 @@ protected function validateFormAnswer($input) {
14281428 }
14291429
14301430 // Check required_validator
1431- if ($ this -> form ->fields ['validation_required ' ] && empty ($ input ['formcreator_validator ' ])) {
1431+ if ($ form ->fields ['validation_required ' ] && empty ($ input ['formcreator_validator ' ])) {
14321432 Session::addMessageAfterRedirect (__ ('You must select validator! ' , 'formcreator ' ), false , ERROR );
14331433 $ valid = false ;
14341434 }
@@ -1456,7 +1456,9 @@ private function sendNotification() {
14561456 break ;
14571457 case self ::STATUS_ACCEPTED :
14581458 // Notify the requester
1459- if ($ this ->form ->fields ['validation_required ' ]) {
1459+ $ form = new PluginFormcreatorForm ();
1460+ $ form ->getFromDB ($ this ->fields ['plugin_formcreator_forms_id ' ]);
1461+ if ($ form ->fields ['validation_required ' ] != PluginFormcreatorForm::VALIDATION_NONE ) {
14601462 NotificationEvent::raiseEvent ('plugin_formcreator_accepted ' , $ this );
14611463 } else {
14621464 NotificationEvent::raiseEvent ('plugin_formcreator_form_created ' , $ this );
0 commit comments