Fix edition of operation into email collector

This commit is contained in:
Laurent Destailleur 2020-12-22 16:29:21 +01:00
parent ef2bd563e2
commit 6fad9c2d3b
6 changed files with 46 additions and 24 deletions

View File

@ -153,14 +153,22 @@ if (GETPOST('addoperation', 'alpha'))
$emailcollectoroperation->status = 1; $emailcollectoroperation->status = 1;
$emailcollectoroperation->position = 50; $emailcollectoroperation->position = 50;
if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty'))
&& empty($emailcollectoroperation->actionparam)) {
$error++;
setEventMessages($langs->trans("ErrorAParameterIsRequiredForThisOperation"), null, 'errors');
}
if (!$error) {
$result = $emailcollectoroperation->create($user); $result = $emailcollectoroperation->create($user);
if ($result > 0) if ($result > 0) {
{
$object->fetchActions(); $object->fetchActions();
} else { } else {
$error++;
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
} }
}
} }
if ($action == 'updateoperation') if ($action == 'updateoperation')
@ -170,14 +178,23 @@ if ($action == 'updateoperation')
$emailcollectoroperation->actionparam = GETPOST('operationparam2', 'restricthtml'); $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'restricthtml');
if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty'))
&& empty($emailcollectoroperation->actionparam)) {
$error++;
setEventMessages($langs->trans("ErrorAParameterIsRequiredForThisOperation"), null, 'errors');
}
if (!$error) {
$result = $emailcollectoroperation->update($user); $result = $emailcollectoroperation->update($user);
if ($result > 0) if ($result > 0)
{ {
$object->fetchActions(); $object->fetchActions();
} else { } else {
$error++;
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
} }
}
} }
if ($action == 'deleteoperation') if ($action == 'deleteoperation')
{ {
@ -458,7 +475,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Filters").'</td><td></td><td></td>'; print '<td>'.$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'</td><td></td><td></td>';
print '</tr>'; print '</tr>';
// Add filter // Add filter
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -491,7 +508,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1), 'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1),
'isanswer'=>array('label'=>'IsAnAnswer', '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 "\n";
print '<script>'; print '<script>';
@ -544,7 +561,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table id="tablelines" class="noborder noshadow tableforfield">'; print '<table id="tablelines" class="noborder noshadow tableforfield">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("EmailcollectorOperations").'</td><td></td><td></td><td></td>'; print '<td>'.$form->textwithpicto($langs->trans("EmailcollectorOperations"), $langs->trans("EmailcollectorOperationsDesc")).'</td><td></td><td></td><td></td>';
print '</tr>'; print '</tr>';
// Add operation // Add operation
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -561,13 +578,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$parameters = array('arrayoftypes' => $arrayoftypes); $parameters = array('arrayoftypes' => $arrayoftypes);
$res = $hookmanager->executeHooks('addMoreActionsEmailCollector', $parameters, $object, $action); $res = $hookmanager->executeHooks('addMoreActionsEmailCollector', $parameters, $object, $action);
if ($res) if ($res) {
$arrayoftypes = $hookmanager->resArray; $arrayoftypes = $hookmanager->resArray;
else foreach ($hookmanager->resArray as $k=>$desc) } else {
foreach ($hookmanager->resArray as $k=>$desc) {
$arrayoftypes[$k] = $desc; $arrayoftypes[$k] = $desc;
}
}
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300', 1);
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300');
print '</td><td>'; print '</td><td>';
print '<input type="text" name="operationparam">'; print '<input type="text" name="operationparam">';
print '</td>'; print '</td>';

View File

@ -1555,10 +1555,9 @@ class EmailCollector extends CommonObject
// Search and create thirdparty // Search and create thirdparty
if ($operation['type'] == 'loadthirdparty' || $operation['type'] == 'loadandcreatethirdparty') if ($operation['type'] == 'loadthirdparty' || $operation['type'] == 'loadandcreatethirdparty')
{ {
if (empty($operation['actionparam'])) if (empty($operation['actionparam'])) {
{
$errorforactions++; $errorforactions++;
$this->error = "Action loadthirdparty or loadandcreatethirdparty has empty parameter. Must be 'SET:xxx' or 'EXTRACT:(body|subject):regex' to define how to extract data"; $this->error = "Action loadthirdparty or loadandcreatethirdparty has empty parameter. Must be a rule like 'SET:xxx' or 'EXTRACT:(body|subject):regex' to define how to set or extract data";
$this->errors[] = $this->error; $this->errors[] = $this->error;
} else { } else {
$actionparam = $operation['actionparam']; $actionparam = $operation['actionparam'];

View File

@ -1985,6 +1985,7 @@ EMailHost=Host of email IMAP server
MailboxSourceDirectory=Mailbox source directory MailboxSourceDirectory=Mailbox source directory
MailboxTargetDirectory=Mailbox target directory MailboxTargetDirectory=Mailbox target directory
EmailcollectorOperations=Operations to do by collector EmailcollectorOperations=Operations to do by collector
EmailcollectorOperationsDesc=Operations are executed from top to bottom order
MaxEmailCollectPerCollect=Max number of emails collected per collect MaxEmailCollectPerCollect=Max number of emails collected per collect
CollectNow=Collect now CollectNow=Collect now
ConfirmCloneEmailCollector=Are you sure you want to clone the Email collector %s ? ConfirmCloneEmailCollector=Are you sure you want to clone the Email collector %s ?
@ -2007,7 +2008,7 @@ WithDolTrackingID=Message from a conversation initiated by a first email sent fr
WithoutDolTrackingID=Message from a conversation initiated by a first email NOT sent from Dolibarr WithoutDolTrackingID=Message from a conversation initiated by a first email NOT sent from Dolibarr
WithDolTrackingIDInMsgId=Message sent from Dolibarr WithDolTrackingIDInMsgId=Message sent from Dolibarr
WithoutDolTrackingIDInMsgId=Message NOT sent from Dolibarr WithoutDolTrackingIDInMsgId=Message NOT sent from Dolibarr
CreateCandidature=Create candidature CreateCandidature=Create job application
FormatZip=Zip FormatZip=Zip
MainMenuCode=Menu entry code (mainmenu) MainMenuCode=Menu entry code (mainmenu)
ECMAutoTree=Show automatic ECM tree ECMAutoTree=Show automatic ECM tree

View File

@ -254,6 +254,7 @@ ErrorNotAvailableWithThisDistribution=Not available with this distribution
ErrorPublicInterfaceNotEnabled=Public interface was not enabled ErrorPublicInterfaceNotEnabled=Public interface was not enabled
ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must be defined if it is set as a translation of another page ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must be defined if it is set as a translation of another page
ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother=The language of new page must not be the source language if it is set as a translation of another page ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother=The language of new page must not be the source language if it is set as a translation of another page
ErrorAParameterIsRequiredForThisOperation=A parameter is mandatory for this operation
# Warnings # Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.

View File

@ -92,6 +92,7 @@ MailingModuleDescEmailsFromUser=Emails input by user
MailingModuleDescDolibarrUsers=Users with Emails MailingModuleDescDolibarrUsers=Users with Emails
MailingModuleDescThirdPartiesByCategories=Third parties (by categories) MailingModuleDescThirdPartiesByCategories=Third parties (by categories)
SendingFromWebInterfaceIsNotAllowed=Sending from web interface is not allowed. SendingFromWebInterfaceIsNotAllowed=Sending from web interface is not allowed.
EmailCollectorFilterDesc=All filters must match to have an email being collected
# Libelle des modules de liste de destinataires mailing # Libelle des modules de liste de destinataires mailing
LineInFile=Line %s in file LineInFile=Line %s in file

View File

@ -437,6 +437,7 @@ RemainToPay=Remain to pay
Module=Module/Application Module=Module/Application
Modules=Modules/Applications Modules=Modules/Applications
Option=Option Option=Option
Filters=Filters
List=List List=List
FullList=Full list FullList=Full list
FullConversation=Full conversation FullConversation=Full conversation