28require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
42include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
43include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollector.class.php';
45include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollectorfilter.class.php';
46include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollectoraction.class.php';
47include_once DOL_DOCUMENT_ROOT.
'/emailcollector/lib/emailcollector.lib.php';
49use Webklex\PHPIMAP\ClientManager;
50use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
53use OAuth\Common\Storage\DoliStorage;
54use OAuth\Common\Consumer\Credentials;
64$langs->loadLangs(array(
"admin",
"mails",
"other"));
69$action =
GETPOST(
'action',
'aZ09');
70$confirm =
GETPOST(
'confirm',
'alpha');
71$cancel =
GETPOST(
'cancel',
'alpha');
72$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'emailcollectorcard';
73$backtopage =
GETPOST(
'backtopage',
'alpha');
80$diroutputmassaction =
$conf->emailcollector->dir_output.
'/temp/massgeneration/'.$user->id;
81$hookmanager->initHooks(array(
'emailcollectorcard'));
84$extrafields->fetch_name_optionals_label(
$object->table_element);
86$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
89$search_all =
GETPOST(
"search_all",
'alpha');
91foreach (
$object->fields as $key => $val) {
92 if (
GETPOST(
'search_'.$key,
'alpha')) {
93 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
98 $action =
'updateoperation';
100if (empty($action) && empty($id) && empty($ref)) {
105include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
113$permissionnote = $user->admin;
114$permissiondellink = $user->admin;
115$permissiontoadd = $user->admin;
125$parameters = array();
126$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
129 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
132if (empty($reshook)) {
133 $permissiontoadd = 1;
134 $permissiontodelete = 1;
135 if (empty($backtopage)) {
136 $backtopage = DOL_URL_ROOT.
'/admin/emailcollector_card.php?id='.(
$id > 0 ?
$id :
'__ID__');
138 $backurlforlist = DOL_URL_ROOT.
'/admin/emailcollector_list.php';
141 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
144 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
147 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
150if (
GETPOST(
'addfilter',
'alpha')) {
152 $emailcollectorfilter->type =
GETPOST(
'filtertype',
'aZ09');
153 $emailcollectorfilter->rulevalue =
GETPOST(
'rulevalue',
'alpha');
154 $emailcollectorfilter->fk_emailcollector =
$object->id;
155 $emailcollectorfilter->status = 1;
157 $result = $emailcollectorfilter->create($user);
162 setEventMessages($emailcollectorfilter->error, $emailcollectorfilter->errors,
'errors');
166if ($action ==
'deletefilter') {
168 $emailcollectorfilter->fetch(
GETPOSTINT(
'filterid'));
169 if ($emailcollectorfilter->id > 0) {
170 $result = $emailcollectorfilter->delete($user);
174 setEventMessages($emailcollectorfilter->error, $emailcollectorfilter->errors,
'errors');
179if (
GETPOST(
'addoperation',
'alpha')) {
181 $emailcollectoroperation->type =
GETPOST(
'operationtype',
'aZ09');
182 $emailcollectoroperation->actionparam =
GETPOST(
'operationparam',
'alphawithlgt');
183 $emailcollectoroperation->fk_emailcollector =
$object->id;
184 $emailcollectoroperation->status = 1;
185 $emailcollectoroperation->position = 50;
187 if ($emailcollectoroperation->type ==
'-1') {
189 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Operation")),
null,
'errors');
192 if (in_array($emailcollectoroperation->type, array(
'loadthirdparty',
'loadandcreatethirdparty'))
193 && empty($emailcollectoroperation->actionparam)) {
195 setEventMessages($langs->trans(
"ErrorAParameterIsRequiredForThisOperation"),
null,
'errors');
199 $result = $emailcollectoroperation->create($user);
205 setEventMessages($emailcollectoroperation->error, $emailcollectoroperation->errors,
'errors');
210if ($action ==
'updateoperation') {
212 $emailcollectoroperation->fetch(
GETPOSTINT(
'rowidoperation2'));
214 $emailcollectoroperation->actionparam =
GETPOST(
'operationparam2',
'alphawithlgt');
216 if (in_array($emailcollectoroperation->type, array(
'loadthirdparty',
'loadandcreatethirdparty'))
217 && empty($emailcollectoroperation->actionparam)) {
219 setEventMessages($langs->trans(
"ErrorAParameterIsRequiredForThisOperation"),
null,
'errors');
223 $result = $emailcollectoroperation->update($user);
229 setEventMessages($emailcollectoroperation->error, $emailcollectoroperation->errors,
'errors');
233if ($action ==
'deleteoperation') {
235 $emailcollectoroperation->fetch(
GETPOSTINT(
'operationid'));
236 if ($emailcollectoroperation->id > 0) {
237 $result = $emailcollectoroperation->delete($user);
241 setEventMessages($emailcollectoroperation->error, $emailcollectoroperation->errors,
'errors');
246if ($action ==
'collecttest') {
249 $res =
$object->doCollectOneCollector(1);
251 $debuginfo =
$object->debuginfo;
252 setEventMessages(
$object->lastresult,
null,
'mesgs');
254 $debuginfo =
$object->debuginfo;
261if ($action ==
'confirm_collect') {
264 $res =
$object->doCollectOneCollector(0);
266 $debuginfo =
$object->debuginfo;
267 setEventMessages(
$object->lastresult,
null,
'mesgs');
269 $debuginfo =
$object->debuginfo;
282$form =
new Form($db);
285$help_url =
"EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
287llxHeader(
'',
'EmailCollector', $help_url,
'', 0, 0,
'',
'',
'',
'mod-admin page-emailcollector_card');
290if ($action ==
'create') {
291 print
load_fiche_titre($langs->trans(
"NewEmailCollector", $langs->transnoentitiesnoconv(
"EmailCollector")));
293 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
294 print
'<input type="hidden" name="token" value="'.newToken().
'">';
295 print
'<input type="hidden" name="action" value="add">';
296 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
300 print
'<table class="border centpercent tableforfield">'.
"\n";
305 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
308 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
310 print
'</table>'.
"\n";
314 print $form->buttonsSaveCancel(
"Create");
320if (($id || $ref) && $action ==
'edit') {
323 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
324 print
'<input type="hidden" name="token" value="'.newToken().
'">';
325 print
'<input type="hidden" name="action" value="update">';
326 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
327 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
331 print
'<table class="border centpercent tableforfield">'.
"\n";
334 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
337 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
343 print $form->buttonsSaveCancel();
349if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
350 $res =
$object->fetch_optionals();
356 print
dol_get_fiche_head($head,
'card', $langs->trans(
"EmailCollector"), -1,
'email');
361 if ($action ==
'delete') {
362 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteEmailCollector'), $langs->trans(
'ConfirmDeleteEmailCollector'),
'confirm_delete',
'', 0, 1);
366 if ($action ==
'clone') {
368 $formquestion = array();
369 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEmailCollector',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
373 if ($action ==
'collect') {
374 $formquestion = array();
375 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'EmailCollectorConfirmCollectTitle'), $langs->trans(
'EmailCollectorConfirmCollect'),
'confirm_collect', $formquestion, 0, 1, 220);
379 $parameters = array(
'formConfirm' => $formconfirm);
380 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
381 if (empty($reshook)) {
382 $formconfirm .= $hookmanager->resPrint;
383 } elseif ($reshook > 0) {
384 $formconfirm = $hookmanager->resPrint;
392 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/emailcollector_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
394 $morehtmlref =
'<div class="refidno">';
395 $morehtmlref .=
'</div>';
399 $sourcedir =
$object->source_directory;
400 $targetdir = (
$object->target_directory ?
$object->target_directory :
'');
403 $connectstringserver =
$object->getConnectStringIMAP();
404 $connectstringsource =
'';
405 $connectstringtarget =
'';
408 if ($action ==
'scan') {
410 require_once DOL_DOCUMENT_ROOT.
'/includes/webklex/php-imap/vendor/autoload.php';
412 if (
$object->acces_type == 1) {
413 dol_syslog(
"Scan IMAP with authentication mode = OAUTH2");
416 require_once DOL_DOCUMENT_ROOT.
'/core/lib/oauth.lib.php';
420 $keyforsupportedoauth2array =
$object->oauth_service;
421 if (preg_match(
'/^.*-/', $keyforsupportedoauth2array)) {
422 $keyforprovider = preg_replace(
'/^.*-/',
'', $keyforsupportedoauth2array);
424 $keyforprovider =
'';
426 $keyforsupportedoauth2array = preg_replace(
'/-.*$/',
'', strtoupper($keyforsupportedoauth2array));
427 $keyforsupportedoauth2array =
'OAUTH_'.$keyforsupportedoauth2array.
'_NAME';
429 if (!empty($supportedoauth2array)) {
430 $nameofservice = ucfirst(strtolower(empty($supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']) ?
'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']));
431 $nameofservice .= ($keyforprovider ?
'-'.$keyforprovider :
'');
432 $OAUTH_SERVICENAME = $nameofservice;
434 $OAUTH_SERVICENAME =
'Unknown';
437 $keyforparamtenant =
'OAUTH_'.strtoupper(empty($supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']) ?
'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']).($keyforprovider ?
'-'.$keyforprovider :
'').
'_TENANT';
439 require_once DOL_DOCUMENT_ROOT.
'/includes/OAuth/bootstrap.php';
448 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
456 if (is_object($tokenobj) && $expire) {
457 $credentials =
new Credentials(
462 $serviceFactory = new \OAuth\ServiceFactory();
463 $oauthname = explode(
'-', $OAUTH_SERVICENAME);
466 $apiService = $serviceFactory->createService($oauthname[0], $credentials, $storage, array());
467 '@phan-var-force OAuth\OAuth2\Service\AbstractService|OAuth\OAuth1\Service\AbstractService $apiService';
470 $refreshtoken = $tokenobj->getRefreshToken();
474 $tokenobj = $apiService->refreshAccessToken($tokenobj);
476 throw new Exception(
"Failed to refresh access token: ".$e->getMessage());
480 $tokenobj->setRefreshToken($refreshtoken);
481 $storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj);
484 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
485 if (is_object($tokenobj)) {
486 $token = $tokenobj->getAccessToken();
489 $morehtml .=
"Token not found";
493 $morehtml .= $e->getMessage();
498 $morehtml .=
'Error: Login is empty. Must be email owner when using MAIN_IMAP_USE_PHPIMAP and OAuth.';
501 $cm =
new ClientManager();
502 $client = $cm->make([
505 'encryption' =>
'ssl',
506 'validate_cert' =>
true,
507 'protocol' =>
'imap',
509 'password' => $token,
510 'authentication' =>
"oauth",
513 dol_syslog(
"Scan IMAP with authentication mode = PASS");
516 $cm =
new ClientManager();
517 $client = $cm->make([
520 'encryption' =>
'ssl',
521 'validate_cert' =>
true,
522 'protocol' =>
'imap',
524 'password' =>
$object->password,
525 'authentication' =>
"login",
545 $f = $client->getFolders(
false,
$object->source_directory);
548 if ($folder instanceof Webklex\PHPIMAP\Folder) {
549 $nbemail = $folder->examine()[
"exists"];
556 $morehtml .= $nbemail;
557 }
catch (ConnectionFailedException $e) {
558 $morehtml .=
'ConnectionFailedException '.$e->getMessage();
562 if (function_exists(
'imap_open')) {
566 $connectstringsource = $connectstringserver.$object->getEncodedUtf7($sourcedir);
570 $connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir);
576 dol_syslog(
"imap_open connectstring=".$connectstringsource.
" login=".
$object->login.
" password=".
$object->password.
" timeoutconnect=".$timeoutconnect.
" timeoutread=".$timeoutread);
578 $result1 = imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect);
579 $result2 = imap_timeout(IMAP_READTIMEOUT, $timeoutread);
580 $result3 = imap_timeout(IMAP_WRITETIMEOUT, 5);
581 $result4 = imap_timeout(IMAP_CLOSETIMEOUT, 5);
583 dol_syslog(
"result1=".$result1.
" result2=".$result2.
" result3=".$result3.
" result4=".$result4);
585 $connection = imap_open($connectstringsource,
$object->login,
$object->password);
589 $morehtml .= $e->getMessage();
593 $morehtml .=
'Failed to open IMAP connection '.$connectstringsource;
594 if (function_exists(
'imap_last_error')) {
595 $morehtml .=
'<br>'.imap_last_error();
600 dol_syslog(
"Imap connected. Now we call imap_num_msg()");
601 $morehtml .= imap_num_msg($connection);
606 imap_close($connection);
609 $morehtml .=
'IMAP functions not available on your PHP. ';
614 $morehtml = $form->textwithpicto($langs->trans(
"NbOfEmailsInInbox"),
'Connect string = '.$connectstringserver.
'<br>Option MAIN_IMAP_USE_PHPIMAP = '.
getDolGlobalInt(
'MAIN_IMAP_USE_PHPIMAP')).
': '.($morehtml !==
'' ? $morehtml :
'?');
615 $morehtml .=
'<a class="flat paddingleft marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=scan&token='.
newToken().
'">'.img_picto(
'',
'refresh',
'class="paddingrightonly"').$langs->trans(
"Refresh").
'</a>';
617 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref.
'<div class="refidno">'.$morehtml.
'</div>',
'', 0,
'',
'', 0,
'');
619 print
'<div class="fichecenter">';
620 print
'<div class="fichehalfleft">';
621 print
'<div class="underbanner clearboth"></div>';
622 print
'<table class="border centpercent tableforfield">'.
"\n";
625 if (
$object->acces_type == 0) {
627 unset(
$object->fields[
'oauth_service']);
629 if (
$object->acces_type == 1) {
631 unset(
$object->fields[
'password']);
637 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
640 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
645 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
646 print
'<input type="hidden" name="token" value="'.newToken().
'">';
647 print
'<input type="hidden" name="action" value="updatefiltersactions">';
648 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
649 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
652 print
'<div class="div-table-responsive-no-min">';
653 print
'<table id="tablelineoffilters" class="noborder noshadow">';
654 print
'<tr class="liste_titre nodrag nodrop">';
655 print
'<td>'.img_picto(
'',
'filter',
'class="pictofixedwidth opacitymedium"').$form->textwithpicto($langs->trans(
"Filters"), $langs->trans(
"EmailCollectorFilterDesc")).
'</td><td></td><td></td>';
658 print
'<tr class="oddeven nodrag nodrop">';
660 $arrayoftypes = array(
661 'from' => array(
'label' =>
'MailFrom',
'data-placeholder' => $langs->trans(
'SearchString')),
662 'to' => array(
'label' =>
'MailTo',
'data-placeholder' => $langs->trans(
'SearchString')),
663 'cc' => array(
'label' =>
'Cc',
'data-placeholder' => $langs->trans(
'SearchString')),
664 'bcc' => array(
'label' =>
'Bcc',
'data-placeholder' => $langs->trans(
'SearchString')),
665 'replyto' => array(
'label' =>
'ReplyTo',
'data-placeholder' => $langs->trans(
'SearchString')),
666 'excludeemail' => array(
'label' =>
'EmailCollectorExcludeEmails',
'data-placeholder' => $langs->trans(
'EmailCollectorExcludeEmailsPlaceholder')),
667 'excludedomain' => array(
'label' =>
'EmailCollectorExcludeDomains',
'data-placeholder' => $langs->trans(
'EmailCollectorExcludeDomainsPlaceholder')),
668 'subject' => array(
'label' =>
'Subject',
'data-placeholder' => $langs->trans(
'SearchString')),
669 'body' => array(
'label' =>
'Body',
'data-placeholder' => $langs->trans(
'SearchString')),
674 'seen' => array(
'label' =>
'AlreadyRead',
'data-noparam' => 1),
675 'unseen' => array(
'label' =>
'NotRead',
'data-noparam' => 1),
676 'unanswered' => array(
'label' =>
'Unanswered',
'data-noparam' => 1),
677 'answered' => array(
'label' =>
'Answered',
'data-noparam' => 1),
678 'smaller' => array(
'label' => $langs->trans(
"Size").
' ('.$langs->trans(
"SmallerThan").
")",
'data-placeholder' => $langs->trans(
'NumberOfBytes')),
679 'larger' => array(
'label' => $langs->trans(
"Size").
' ('.$langs->trans(
"LargerThan").
")",
'data-placeholder' => $langs->trans(
'NumberOfBytes')),
681 'withtrackingid' => array(
'label' =>
'WithDolTrackingID',
'data-noparam' => 1),
682 'withouttrackingid' => array(
'label' =>
'WithoutDolTrackingID',
'data-noparam' => 1),
683 'withtrackingidinmsgid' => array(
'label' =>
'WithDolTrackingIDInMsgId',
'data-noparam' => 1),
684 'withouttrackingidinmsgid' => array(
'label' =>
'WithoutDolTrackingIDInMsgId',
'data-noparam' => 1),
686 'isnotanswer' => array(
'label' =>
'IsNotAnAnswer',
'data-noparam' => 1),
687 'isanswer' => array(
'label' =>
'IsAnAnswer',
'data-noparam' => 1)
689 print $form->selectarray(
'filtertype', $arrayoftypes,
'', 1, 0, 0,
'', 1, 0, 0,
'',
'maxwidth300', 1,
'', 2);
693 print
'jQuery("#filtertype").change(function() {
694 console.log("We change a filter");
695 if (jQuery("#filtertype option:selected").attr("data-noparam")) {
696 jQuery("#rulevalue").attr("placeholder", "");
697 jQuery("#rulevalue").text("");
698 jQuery("#rulevalue").prop("disabled", true);
699 jQuery("#rulevaluehelp").addClass("unvisible");
701 jQuery("#rulevalue").prop("disabled", false);
702 jQuery("#rulevaluehelp").removeClass("unvisible");
704 jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder")));
712 print
'</script>'.
"\n";
714 print
'</td><td class="nowraponall">';
715 print
'<div class="nowraponall">';
716 print
'<input type="text" name="rulevalue" id="rulevalue" class="inline-block valignmiddle">';
717 print
'<div class="inline-block valignmiddle unvisible" id="rulevaluehelp">';
718 print img_warning($langs->trans(
"FilterSearchImapHelp"),
'',
'pictowarning classfortooltip');
722 print
'<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button smallpaddingimp" value="'.$langs->trans(
"Add").
'"></td>';
725 foreach (
$object->filters as $rulefilter) {
727 $rulefilterobj->fetch($rulefilter[
'id']);
729 print
'<tr class="oddeven">';
730 print
'<td title="'.dol_escape_htmltag($langs->trans(
"Filter").
': '.$rulefilter[
'type']).
'">';
731 print $langs->trans($arrayoftypes[$rulefilter[
'type']][
'label']);
733 print
'<td>'.$rulefilter[
'rulevalue'].
'</td>';
734 print
'<td class="right">';
735 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletefilter&token='.urlencode(
newToken()).
'&filterid='.$rulefilter[
'id'].
'">'.img_delete().
'</a>';
744 print
'<div class="clearboth"></div><br><br>';
747 print
'<div class="div-table-responsive-no-min">';
748 print
'<table id="tablelines" class="noborder noshadow">';
749 print
'<tr class="liste_titre nodrag nodrop">';
750 print
'<td>'.img_picto(
'',
'technic',
'class="pictofixedwidth"').$form->textwithpicto($langs->trans(
"EmailcollectorOperations"), $langs->trans(
"EmailcollectorOperationsDesc")).
'</td>';
752 $htmltext = $langs->transnoentitiesnoconv(
"OperationParamDesc");
753 print $form->textwithpicto($langs->trans(
"Parameters"), $htmltext, 1,
'help',
'', 0, 2,
'operationparamtt');
759 $arrayoftypes = array(
760 'loadthirdparty' => $langs->trans(
'LoadThirdPartyFromName', $langs->transnoentities(
"ThirdPartyName").
'/'.$langs->transnoentities(
"AliasNameShort").
'/'.$langs->transnoentities(
"Email").
'/'.$langs->transnoentities(
"ID")),
761 'loadandcreatethirdparty' => $langs->trans(
'LoadThirdPartyFromNameOrCreate', $langs->transnoentities(
"ThirdPartyName").
'/'.$langs->transnoentities(
"AliasNameShort").
'/'.$langs->transnoentities(
"Email").
'/'.$langs->transnoentities(
"ID")),
762 'recordjoinpiece' =>
'AttachJoinedDocumentsToObject',
763 'recordevent' =>
'RecordEvent'
765 $arrayoftypesnocondition = $arrayoftypes;
767 $arrayoftypes[
'project'] =
'CreateLeadAndThirdParty';
769 $arrayoftypesnocondition[
'project'] =
'CreateLeadAndThirdParty';
771 $arrayoftypes[
'ticket'] =
'CreateTicketAndThirdParty';
773 $arrayoftypesnocondition[
'ticket'] =
'CreateTicketAndThirdParty';
775 $arrayoftypes[
'candidature'] =
'CreateCandidature';
777 $arrayoftypesnocondition[
'candidature'] =
'CreateCandidature';
780 $parameters = array(
'arrayoftypes' => $arrayoftypes);
781 $res = $hookmanager->executeHooks(
'addMoreActionsEmailCollector', $parameters, $object, $action);
784 $arrayoftypes = $hookmanager->resArray;
786 foreach ($hookmanager->resArray as $k => $desc) {
787 $arrayoftypes[$k] = $desc;
792 print
'<tr class="oddeven nodrag nodrop">';
794 print $form->selectarray(
'operationtype', $arrayoftypes,
'', 1, 0, 0,
'', 1, 0, 0,
'',
'minwidth150 maxwidth250', 1);
796 print
'<textarea class="centpercent" name="operationparam" rows="3"></textarea>';
800 print
'<td class="right"><input type="submit" name="addoperation" id="addoperation" class="flat button smallpaddingimp" value="'.$langs->trans(
"Add").
'"></td>';
803 $nboflines = count(
$object->actions);
804 $table_element_line =
'emailcollector_emailcollectoraction';
805 $fk_element =
'position';
807 foreach (
$object->actions as $ruleaction) {
809 $ruleactionobj->fetch($ruleaction[
'id']);
811 print
'<tr class="drag drop oddeven" id="row-'.$ruleaction[
'id'].
'">';
812 print
'<td title="'.dol_escape_htmltag($langs->trans(
"Operation").
': '.$ruleaction[
'type']).
'">';
813 print
'<!-- type of action: '.$ruleaction[
'type'].
' -->';
814 if (array_key_exists($ruleaction[
'type'], $arrayoftypes)) {
815 print $langs->trans($arrayoftypes[$ruleaction[
'type']]);
817 if (array_key_exists($ruleaction[
'type'], $arrayoftypesnocondition)) {
818 print
'<span class="opacitymedium">'.$langs->trans($arrayoftypesnocondition[$ruleaction[
'type']]).
' - '.$langs->trans(
"Disabled").
'</span>';
822 if (in_array($ruleaction[
'type'], array(
'recordevent'))) {
823 print $form->textwithpicto(
'', $langs->transnoentitiesnoconv(
'IfTrackingIDFoundEventWillBeLinked'));
824 } elseif (in_array($ruleaction[
'type'], array(
'loadthirdparty',
'loadandcreatethirdparty'))) {
825 print $form->textwithpicto(
'', $langs->transnoentitiesnoconv(
'EmailCollectorLoadThirdPartyHelp'));
828 print
'<td class="wordbreak minwidth300 small">';
829 if ($action ==
'editoperation' && $ruleaction[
'id'] == $operationid) {
831 print
'<textarea class="centpercent" name="operationparam2" rows="3">';
834 print
'<input type="hidden" name="rowidoperation2" value="'.$ruleaction[
'id'].
'">';
835 print
'<input type="submit" class="button small button-save" name="saveoperation2" value="'.$langs->trans(
"Save").
'">';
836 print
'<input type="submit" class="button small button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
842 print
'<td class="center linecolmove tdlineupdown">';
844 print
'<a class="lineupdown" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'up',
'rowid' => $ruleaction[
'id']],
true).
'">'.
img_up(
'default', 0,
'imgupforline').
'</a>';
846 if ($i < count(
$object->actions) - 1) {
847 print
'<a class="lineupdown" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'down',
'rowid' => $ruleaction[
'id']],
true).
'">'.
img_down(
'default', 0,
'imgdownforline').
'</a>';
851 print
'<td class="right nowraponall">';
852 print
'<a class="editfielda marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editoperation&token='.
newToken().
'&operationid='.$ruleaction[
'id'].
'">'.img_edit().
'</a>';
853 print
' <a href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'deleteoperation',
'operationid' => $ruleaction[
'id']],
true).
'">'.img_delete().
'</a>';
863 if (!empty(
$conf->use_javascript_ajax)) {
864 $urltorefreshaftermove = DOL_URL_ROOT.
'/admin/emailcollector_card.php?id='.
$id;
865 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
874 print
'<div class="clearboth"></div><br>';
879 if ($action !=
'presend' && $action !=
'editline') {
880 print
'<div class="tabsAction">'.
"\n";
881 $parameters = array();
882 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
884 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
887 if (empty($reshook)) {
889 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Edit").
'</a></div>';
892 print
'<div class="inline-block divButAction">'.dolGetButtonAction($langs->trans(
"ToClone"), $langs->trans(
"ToClone"),
'clone', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken(),
'', $permissiontoadd, array(
'attr' => array(
'class' =>
'reposition'))).
'</div>';
895 print
'<div class="inline-block divButAction"><a class="butAction reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=collecttest&token='.
newToken().
'">'.$langs->trans(
"TestCollectNow").
'</a></div>';
897 if (count(
$object->actions) > 0) {
898 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=collect&token='.
newToken().
'">'.$langs->trans(
"CollectNow").
'</a></div>';
900 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoOperations")).
'">'.$langs->trans(
"CollectNow").
'</a></div>';
903 print
'<div class="inline-block divButAction">'.dolGetButtonAction($langs->trans(
'Delete'), $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.urlencode(
newToken()),
'',
true, array(
'attr' => array(
'class' =>
'reposition'))).
'</div>'.
"\n";
908 if (!empty($debuginfo)) {
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class for EmailCollectorAction.
Class for EmailCollectorFilter.
Class for EmailCollector.
emailcollectorPrepareHead($object)
Prepare array of tabs for EmailCollector.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
getSupportedOauth2Array()
Return array of tabs to use on pages to setup cron module.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.