From 6fad9c2d3bb633d503f2274149ce4e7375ad5750 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Dec 2020 16:29:21 +0100 Subject: [PATCH] Fix edition of operation into email collector --- htdocs/admin/emailcollector_card.php | 57 ++++++++++++------- .../class/emailcollector.class.php | 5 +- htdocs/langs/en_US/admin.lang | 3 +- htdocs/langs/en_US/errors.lang | 3 +- htdocs/langs/en_US/mails.lang | 1 + htdocs/langs/en_US/main.lang | 1 + 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index adfaaf4f816..6525013c6bc 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -153,13 +153,21 @@ if (GETPOST('addoperation', 'alpha')) $emailcollectoroperation->status = 1; $emailcollectoroperation->position = 50; - $result = $emailcollectoroperation->create($user); + if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty')) + && empty($emailcollectoroperation->actionparam)) { + $error++; + setEventMessages($langs->trans("ErrorAParameterIsRequiredForThisOperation"), null, 'errors'); + } - if ($result > 0) - { - $object->fetchActions(); - } else { - setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + if (!$error) { + $result = $emailcollectoroperation->create($user); + + if ($result > 0) { + $object->fetchActions(); + } else { + $error++; + setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + } } } @@ -170,13 +178,22 @@ if ($action == 'updateoperation') $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'restricthtml'); - $result = $emailcollectoroperation->update($user); + if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty')) + && empty($emailcollectoroperation->actionparam)) { + $error++; + setEventMessages($langs->trans("ErrorAParameterIsRequiredForThisOperation"), null, 'errors'); + } - if ($result > 0) - { - $object->fetchActions(); - } else { - setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + if (!$error) { + $result = $emailcollectoroperation->update($user); + + if ($result > 0) + { + $object->fetchActions(); + } else { + $error++; + setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + } } } if ($action == 'deleteoperation') @@ -458,7 +475,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print ''; print ''; - print ''; + print ''; print ''; // Add filter print ''; @@ -491,7 +508,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea 'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1), 'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1) ); - print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth500', 0, '', 2); + print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth500', 1, '', 2); print "\n"; print '
'.$langs->trans("Filters").''.$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'