28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
33include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
34include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollector.class.php';
36include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollectorfilter.class.php';
37include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollectoraction.class.php';
38include_once DOL_DOCUMENT_ROOT.
'/emailcollector/lib/emailcollector.lib.php';
40use Webklex\PHPIMAP\ClientManager;
41use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
44use OAuth\Common\Storage\DoliStorage;
45use OAuth\Common\Consumer\Credentials;
63$langs->loadLangs(array(
"admin",
"mails",
"other"));
68$action =
GETPOST(
'action',
'aZ09');
69$confirm =
GETPOST(
'confirm',
'alpha');
70$cancel =
GETPOST(
'cancel',
'alpha');
71$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'emailcollectorcard';
72$backtopage =
GETPOST(
'backtopage',
'alpha');
79$diroutputmassaction = $conf->emailcollector->dir_output.
'/temp/massgeneration/'.$user->id;
80$hookmanager->initHooks(array(
'emailcollectorcard'));
83$extrafields->fetch_name_optionals_label(
$object->table_element);
85$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
88$search_all =
GETPOST(
"search_all",
'alpha');
90foreach (
$object->fields as $key => $val) {
91 if (
GETPOST(
'search_'.$key,
'alpha')) {
92 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
97 $action =
'updateoperation';
99if (empty($action) && empty($id) && empty($ref)) {
104include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
112$permissionnote = $user->admin;
113$permissiondellink = $user->admin;
114$permissiontoadd = $user->admin;
124$parameters = array();
125$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
131if (empty($reshook)) {
132 $permissiontoadd = 1;
133 $permissiontodelete = 1;
134 if (empty($backtopage)) {
135 $backtopage = DOL_URL_ROOT.
'/admin/emailcollector_card.php?id='.(
$id > 0 ?
$id :
'__ID__');
137 $backurlforlist = DOL_URL_ROOT.
'/admin/emailcollector_list.php';
140 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
143 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
146 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
149if (
GETPOST(
'addfilter',
'alpha')) {
151 $emailcollectorfilter->type =
GETPOST(
'filtertype',
'aZ09');
152 $emailcollectorfilter->rulevalue =
GETPOST(
'rulevalue',
'alpha');
153 $emailcollectorfilter->fk_emailcollector =
$object->id;
154 $emailcollectorfilter->status = 1;
156 $result = $emailcollectorfilter->create($user);
161 setEventMessages($emailcollectorfilter->error, $emailcollectorfilter->errors,
'errors');
165if ($action ==
'deletefilter') {
167 $emailcollectorfilter->fetch(
GETPOSTINT(
'filterid'));
168 if ($emailcollectorfilter->id > 0) {
169 $result = $emailcollectorfilter->delete($user);
173 setEventMessages($emailcollectorfilter->error, $emailcollectorfilter->errors,
'errors');
178if (
GETPOST(
'addoperation',
'alpha')) {
180 $emailcollectoroperation->type =
GETPOST(
'operationtype',
'aZ09');
181 $emailcollectoroperation->actionparam =
GETPOST(
'operationparam',
'alphawithlgt');
182 $emailcollectoroperation->fk_emailcollector =
$object->id;
183 $emailcollectoroperation->status = 1;
184 $emailcollectoroperation->position = 50;
186 if ($emailcollectoroperation->type ==
'-1') {
188 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Operation")),
null,
'errors');
191 if (in_array($emailcollectoroperation->type, array(
'loadthirdparty',
'loadandcreatethirdparty'))
192 && empty($emailcollectoroperation->actionparam)) {
194 setEventMessages($langs->trans(
"ErrorAParameterIsRequiredForThisOperation"),
null,
'errors');
198 $result = $emailcollectoroperation->create($user);
204 setEventMessages($emailcollectoroperation->error, $emailcollectoroperation->errors,
'errors');
209if ($action ==
'updateoperation') {
211 $emailcollectoroperation->fetch(
GETPOSTINT(
'rowidoperation2'));
213 $emailcollectoroperation->actionparam =
GETPOST(
'operationparam2',
'alphawithlgt');
215 if (in_array($emailcollectoroperation->type, array(
'loadthirdparty',
'loadandcreatethirdparty'))
216 && empty($emailcollectoroperation->actionparam)) {
218 setEventMessages($langs->trans(
"ErrorAParameterIsRequiredForThisOperation"),
null,
'errors');
222 $result = $emailcollectoroperation->update($user);
228 setEventMessages($emailcollectoroperation->error, $emailcollectoroperation->errors,
'errors');
232if ($action ==
'deleteoperation') {
234 $emailcollectoroperation->fetch(
GETPOSTINT(
'operationid'));
235 if ($emailcollectoroperation->id > 0) {
236 $result = $emailcollectoroperation->delete($user);
240 setEventMessages($emailcollectoroperation->error, $emailcollectoroperation->errors,
'errors');
245if ($action ==
'collecttest') {
248 $res =
$object->doCollectOneCollector(1);
250 $debuginfo =
$object->debuginfo;
253 $debuginfo =
$object->debuginfo;
260if ($action ==
'confirm_collect') {
263 $res =
$object->doCollectOneCollector(0);
265 $debuginfo =
$object->debuginfo;
268 $debuginfo =
$object->debuginfo;
281$form =
new Form($db);
284$help_url =
"EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
286llxHeader(
'',
'EmailCollector', $help_url,
'', 0, 0,
'',
'',
'',
'mod-admin page-emailcollector_card');
289if ($action ==
'create') {
290 print
load_fiche_titre($langs->trans(
"NewEmailCollector", $langs->transnoentitiesnoconv(
"EmailCollector")));
292 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
293 print
'<input type="hidden" name="token" value="'.newToken().
'">';
294 print
'<input type="hidden" name="action" value="add">';
295 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
299 print
'<table class="border centpercent tableforfield">'.
"\n";
304 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
307 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
309 print
'</table>'.
"\n";
313 print $form->buttonsSaveCancel(
"Create");
319if (($id || $ref) && $action ==
'edit') {
322 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
323 print
'<input type="hidden" name="token" value="'.newToken().
'">';
324 print
'<input type="hidden" name="action" value="update">';
325 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
326 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
330 print
'<table class="border centpercent tableforfield">'.
"\n";
333 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
336 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
342 print $form->buttonsSaveCancel();
348if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
349 $res =
$object->fetch_optionals();
355 print
dol_get_fiche_head($head,
'card', $langs->trans(
"EmailCollector"), -1,
'email');
360 if ($action ==
'delete') {
361 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteEmailCollector'), $langs->trans(
'ConfirmDeleteEmailCollector'),
'confirm_delete',
'', 0, 1);
365 if ($action ==
'clone') {
367 $formquestion = array();
368 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEmailCollector',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
372 if ($action ==
'collect') {
373 $formquestion = array();
374 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'EmailCollectorConfirmCollectTitle'), $langs->trans(
'EmailCollectorConfirmCollect'),
'confirm_collect', $formquestion, 0, 1, 220);
378 $parameters = array(
'formConfirm' => $formconfirm);
379 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
380 if (empty($reshook)) {
381 $formconfirm .= $hookmanager->resPrint;
382 } elseif ($reshook > 0) {
383 $formconfirm = $hookmanager->resPrint;
391 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/emailcollector_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
393 $morehtmlref =
'<div class="refidno">';
394 $morehtmlref .=
'</div>';
398 $sourcedir =
$object->source_directory;
399 $targetdir = (
$object->target_directory ?
$object->target_directory :
'');
402 $connectstringserver =
$object->getConnectStringIMAP();
403 $connectstringsource =
'';
404 $connectstringtarget =
'';
407 if ($action ==
'scan') {
409 require_once DOL_DOCUMENT_ROOT.
'/includes/webklex/php-imap/vendor/autoload.php';
411 if (
$object->acces_type == 1) {
412 dol_syslog(
"Scan IMAP with authentication mode = OAUTH2");
415 require_once DOL_DOCUMENT_ROOT.
'/core/lib/oauth.lib.php';
419 $keyforsupportedoauth2array =
$object->oauth_service;
420 if (preg_match(
'/^.*-/', $keyforsupportedoauth2array)) {
421 $keyforprovider = preg_replace(
'/^.*-/',
'', $keyforsupportedoauth2array);
423 $keyforprovider =
'';
425 $keyforsupportedoauth2array = preg_replace(
'/-.*$/',
'', strtoupper($keyforsupportedoauth2array));
426 $keyforsupportedoauth2array =
'OAUTH_'.$keyforsupportedoauth2array.
'_NAME';
428 if (!empty($supportedoauth2array)) {
429 $nameofservice = ucfirst(strtolower(empty($supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']) ?
'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']));
430 $nameofservice .= ($keyforprovider ?
'-'.$keyforprovider :
'');
431 $OAUTH_SERVICENAME = $nameofservice;
433 $OAUTH_SERVICENAME =
'Unknown';
436 $keyforparamtenant =
'OAUTH_'.strtoupper(empty($supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']) ?
'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']).($keyforprovider ?
'-'.$keyforprovider :
'').
'_TENANT';
438 require_once DOL_DOCUMENT_ROOT.
'/includes/OAuth/bootstrap.php';
444 $storage =
new DoliStorage($db, $conf, $keyforprovider,
getDolGlobalString($keyforparamtenant));
447 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
455 if (is_object($tokenobj) && $expire) {
456 $credentials =
new Credentials(
461 $serviceFactory = new \OAuth\ServiceFactory();
462 $oauthname = explode(
'-', $OAUTH_SERVICENAME);
465 $apiService = $serviceFactory->createService($oauthname[0], $credentials, $storage, array());
466 '@phan-var-force OAuth\OAuth2\Service\AbstractService|OAuth\OAuth1\Service\AbstractService $apiService';
469 $refreshtoken = $tokenobj->getRefreshToken();
473 $tokenobj = $apiService->refreshAccessToken($tokenobj);
475 throw new Exception(
"Failed to refresh access token: ".$e->getMessage());
479 $tokenobj->setRefreshToken($refreshtoken);
480 $storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj);
483 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
484 if (is_object($tokenobj)) {
485 $token = $tokenobj->getAccessToken();
488 $morehtml .=
"Token not found";
492 $morehtml .= $e->getMessage();
497 $morehtml .=
'Error: Login is empty. Must be email owner when using MAIN_IMAP_USE_PHPIMAP and OAuth.';
500 $cm =
new ClientManager();
501 $client = $cm->make([
504 'encryption' =>
'ssl',
505 'validate_cert' =>
true,
506 'protocol' =>
'imap',
508 'password' => $token,
509 'authentication' =>
"oauth",
512 dol_syslog(
"Scan IMAP with authentication mode = PASS");
515 $cm =
new ClientManager();
516 $client = $cm->make([
519 'encryption' =>
'ssl',
520 'validate_cert' =>
true,
521 'protocol' =>
'imap',
523 'password' =>
$object->password,
524 'authentication' =>
"login",
544 $f = $client->getFolders(
false,
$object->source_directory);
547 if ($folder instanceof Webklex\PHPIMAP\Folder) {
548 $nbemail = $folder->examine()[
"exists"];
555 $morehtml .= $nbemail;
556 }
catch (ConnectionFailedException $e) {
557 $morehtml .=
'ConnectionFailedException '.$e->getMessage();
561 if (function_exists(
'imap_open')) {
565 $connectstringsource = $connectstringserver.$object->getEncodedUtf7($sourcedir);
569 $connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir);
575 dol_syslog(
"imap_open connectstring=".$connectstringsource.
" login=".
$object->login.
" password=".
$object->password.
" timeoutconnect=".$timeoutconnect.
" timeoutread=".$timeoutread);
577 $result1 = imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect);
578 $result2 = imap_timeout(IMAP_READTIMEOUT, $timeoutread);
579 $result3 = imap_timeout(IMAP_WRITETIMEOUT, 5);
580 $result4 = imap_timeout(IMAP_CLOSETIMEOUT, 5);
582 dol_syslog(
"result1=".$result1.
" result2=".$result2.
" result3=".$result3.
" result4=".$result4);
584 $connection = imap_open($connectstringsource,
$object->login,
$object->password);
588 $morehtml .= $e->getMessage();
592 $morehtml .=
'Failed to open IMAP connection '.$connectstringsource;
593 if (function_exists(
'imap_last_error')) {
594 $morehtml .=
'<br>'.imap_last_error();
599 dol_syslog(
"Imap connected. Now we call imap_num_msg()");
600 $morehtml .= imap_num_msg($connection);
605 imap_close($connection);
608 $morehtml .=
'IMAP functions not available on your PHP. ';
613 $morehtml = $form->textwithpicto($langs->trans(
"NbOfEmailsInInbox"),
'Connect string = '.$connectstringserver.
'<br>Option MAIN_IMAP_USE_PHPIMAP = '.
getDolGlobalInt(
'MAIN_IMAP_USE_PHPIMAP')).
': '.($morehtml !==
'' ? $morehtml :
'?');
614 $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>';
616 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref.
'<div class="refidno">'.$morehtml.
'</div>',
'', 0,
'',
'', 0,
'');
618 print
'<div class="fichecenter">';
619 print
'<div class="fichehalfleft">';
620 print
'<div class="underbanner clearboth"></div>';
621 print
'<table class="border centpercent tableforfield">'.
"\n";
624 if (
$object->acces_type == 0) {
626 unset(
$object->fields[
'oauth_service']);
628 if (
$object->acces_type == 1) {
630 unset(
$object->fields[
'password']);
636 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
639 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
644 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
645 print
'<input type="hidden" name="token" value="'.newToken().
'">';
646 print
'<input type="hidden" name="action" value="updatefiltersactions">';
647 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
648 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
651 print
'<div class="div-table-responsive-no-min">';
652 print
'<table id="tablelineoffilters" class="noborder noshadow">';
653 print
'<tr class="liste_titre nodrag nodrop">';
654 print
'<td>'.img_picto(
'',
'filter',
'class="pictofixedwidth opacitymedium"').$form->textwithpicto($langs->trans(
"Filters"), $langs->trans(
"EmailCollectorFilterDesc")).
'</td><td></td><td></td>';
657 print
'<tr class="oddeven nodrag nodrop">';
659 $arrayoftypes = array(
660 'from' => array(
'label' =>
'MailFrom',
'data-placeholder' => $langs->trans(
'SearchString')),
661 'to' => array(
'label' =>
'MailTo',
'data-placeholder' => $langs->trans(
'SearchString')),
662 'cc' => array(
'label' =>
'Cc',
'data-placeholder' => $langs->trans(
'SearchString')),
663 'bcc' => array(
'label' =>
'Bcc',
'data-placeholder' => $langs->trans(
'SearchString')),
664 'replyto' => array(
'label' =>
'ReplyTo',
'data-placeholder' => $langs->trans(
'SearchString')),
665 'subject' => array(
'label' =>
'Subject',
'data-placeholder' => $langs->trans(
'SearchString')),
666 'body' => array(
'label' =>
'Body',
'data-placeholder' => $langs->trans(
'SearchString')),
671 'seen' => array(
'label' =>
'AlreadyRead',
'data-noparam' => 1),
672 'unseen' => array(
'label' =>
'NotRead',
'data-noparam' => 1),
673 'unanswered' => array(
'label' =>
'Unanswered',
'data-noparam' => 1),
674 'answered' => array(
'label' =>
'Answered',
'data-noparam' => 1),
675 'smaller' => array(
'label' => $langs->trans(
"Size").
' ('.$langs->trans(
"SmallerThan").
")",
'data-placeholder' => $langs->trans(
'NumberOfBytes')),
676 'larger' => array(
'label' => $langs->trans(
"Size").
' ('.$langs->trans(
"LargerThan").
")",
'data-placeholder' => $langs->trans(
'NumberOfBytes')),
678 'withtrackingid' => array(
'label' =>
'WithDolTrackingID',
'data-noparam' => 1),
679 'withouttrackingid' => array(
'label' =>
'WithoutDolTrackingID',
'data-noparam' => 1),
680 'withtrackingidinmsgid' => array(
'label' =>
'WithDolTrackingIDInMsgId',
'data-noparam' => 1),
681 'withouttrackingidinmsgid' => array(
'label' =>
'WithoutDolTrackingIDInMsgId',
'data-noparam' => 1),
683 'isnotanswer' => array(
'label' =>
'IsNotAnAnswer',
'data-noparam' => 1),
684 'isanswer' => array(
'label' =>
'IsAnAnswer',
'data-noparam' => 1)
686 print $form->selectarray(
'filtertype', $arrayoftypes,
'', 1, 0, 0,
'', 1, 0, 0,
'',
'maxwidth300', 1,
'', 2);
690 print
'jQuery("#filtertype").change(function() {
691 console.log("We change a filter");
692 if (jQuery("#filtertype option:selected").attr("data-noparam")) {
693 jQuery("#rulevalue").attr("placeholder", "");
694 jQuery("#rulevalue").text("");
695 jQuery("#rulevalue").prop("disabled", true);
696 jQuery("#rulevaluehelp").addClass("unvisible");
698 jQuery("#rulevalue").prop("disabled", false);
699 jQuery("#rulevaluehelp").removeClass("unvisible");
701 jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder")));
709 print
'</script>'.
"\n";
711 print
'</td><td class="nowraponall">';
712 print
'<div class="nowraponall">';
713 print
'<input type="text" name="rulevalue" id="rulevalue" class="inline-block valignmiddle">';
714 print
'<div class="inline-block valignmiddle unvisible" id="rulevaluehelp">';
715 print
img_warning($langs->trans(
"FilterSearchImapHelp"),
'',
'pictowarning classfortooltip');
719 print
'<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button smallpaddingimp" value="'.$langs->trans(
"Add").
'"></td>';
722 foreach (
$object->filters as $rulefilter) {
724 $rulefilterobj->fetch($rulefilter[
'id']);
726 print
'<tr class="oddeven">';
727 print
'<td title="'.dol_escape_htmltag($langs->trans(
"Filter").
': '.$rulefilter[
'type']).
'">';
728 print $langs->trans($arrayoftypes[$rulefilter[
'type']][
'label']);
730 print
'<td>'.$rulefilter[
'rulevalue'].
'</td>';
731 print
'<td class="right">';
732 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletefilter&token='.urlencode(
newToken()).
'&filterid='.$rulefilter[
'id'].
'">'.
img_delete().
'</a>';
741 print
'<div class="clearboth"></div><br><br>';
744 print
'<div class="div-table-responsive-no-min">';
745 print
'<table id="tablelines" class="noborder noshadow">';
746 print
'<tr class="liste_titre nodrag nodrop">';
747 print
'<td>'.img_picto(
'',
'technic',
'class="pictofixedwidth"').$form->textwithpicto($langs->trans(
"EmailcollectorOperations"), $langs->trans(
"EmailcollectorOperationsDesc")).
'</td>';
749 $htmltext = $langs->transnoentitiesnoconv(
"OperationParamDesc");
750 print $form->textwithpicto($langs->trans(
"Parameters"), $htmltext, 1,
'help',
'', 0, 2,
'operationparamtt');
756 $arrayoftypes = array(
757 'loadthirdparty' => $langs->trans(
'LoadThirdPartyFromName', $langs->transnoentities(
"ThirdPartyName").
'/'.$langs->transnoentities(
"AliasNameShort").
'/'.$langs->transnoentities(
"Email").
'/'.$langs->transnoentities(
"ID")),
758 'loadandcreatethirdparty' => $langs->trans(
'LoadThirdPartyFromNameOrCreate', $langs->transnoentities(
"ThirdPartyName").
'/'.$langs->transnoentities(
"AliasNameShort").
'/'.$langs->transnoentities(
"Email").
'/'.$langs->transnoentities(
"ID")),
759 'recordjoinpiece' =>
'AttachJoinedDocumentsToObject',
760 'recordevent' =>
'RecordEvent'
762 $arrayoftypesnocondition = $arrayoftypes;
764 $arrayoftypes[
'project'] =
'CreateLeadAndThirdParty';
766 $arrayoftypesnocondition[
'project'] =
'CreateLeadAndThirdParty';
768 $arrayoftypes[
'ticket'] =
'CreateTicketAndThirdParty';
770 $arrayoftypesnocondition[
'ticket'] =
'CreateTicketAndThirdParty';
772 $arrayoftypes[
'candidature'] =
'CreateCandidature';
774 $arrayoftypesnocondition[
'candidature'] =
'CreateCandidature';
777 $parameters = array(
'arrayoftypes' => $arrayoftypes);
778 $res = $hookmanager->executeHooks(
'addMoreActionsEmailCollector', $parameters, $object, $action);
781 $arrayoftypes = $hookmanager->resArray;
783 foreach ($hookmanager->resArray as $k => $desc) {
784 $arrayoftypes[$k] = $desc;
789 print
'<tr class="oddeven nodrag nodrop">';
791 print $form->selectarray(
'operationtype', $arrayoftypes,
'', 1, 0, 0,
'', 1, 0, 0,
'',
'minwidth150 maxwidth250', 1);
793 print
'<textarea class="centpercent" name="operationparam" rows="3"></textarea>';
797 print
'<td class="right"><input type="submit" name="addoperation" id="addoperation" class="flat button smallpaddingimp" value="'.$langs->trans(
"Add").
'"></td>';
800 $nboflines = count(
$object->actions);
801 $table_element_line =
'emailcollector_emailcollectoraction';
802 $fk_element =
'position';
804 foreach (
$object->actions as $ruleaction) {
806 $ruleactionobj->fetch($ruleaction[
'id']);
808 print
'<tr class="drag drop oddeven" id="row-'.$ruleaction[
'id'].
'">';
809 print
'<td title="'.dol_escape_htmltag($langs->trans(
"Operation").
': '.$ruleaction[
'type']).
'">';
810 print
'<!-- type of action: '.$ruleaction[
'type'].
' -->';
811 if (array_key_exists($ruleaction[
'type'], $arrayoftypes)) {
812 print $langs->trans($arrayoftypes[$ruleaction[
'type']]);
814 if (array_key_exists($ruleaction[
'type'], $arrayoftypesnocondition)) {
815 print
'<span class="opacitymedium">'.$langs->trans($arrayoftypesnocondition[$ruleaction[
'type']]).
' - '.$langs->trans(
"Disabled").
'</span>';
819 if (in_array($ruleaction[
'type'], array(
'recordevent'))) {
820 print $form->textwithpicto(
'', $langs->transnoentitiesnoconv(
'IfTrackingIDFoundEventWillBeLinked'));
821 } elseif (in_array($ruleaction[
'type'], array(
'loadthirdparty',
'loadandcreatethirdparty'))) {
822 print $form->textwithpicto(
'', $langs->transnoentitiesnoconv(
'EmailCollectorLoadThirdPartyHelp'));
825 print
'<td class="wordbreak minwidth300 small">';
826 if ($action ==
'editoperation' && $ruleaction[
'id'] == $operationid) {
828 print
'<textarea class="centpercent" name="operationparam2" rows="3">';
831 print
'<input type="hidden" name="rowidoperation2" value="'.$ruleaction[
'id'].
'">';
832 print
'<input type="submit" class="button small button-save" name="saveoperation2" value="'.$langs->trans(
"Save").
'">';
833 print
'<input type="submit" class="button small button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
839 print
'<td class="center linecolmove tdlineupdown">';
841 print
'<a class="lineupdown" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'up',
'rowid' => $ruleaction[
'id']],
true).
'">'.
img_up(
'default', 0,
'imgupforline').
'</a>';
843 if ($i < count(
$object->actions) - 1) {
844 print
'<a class="lineupdown" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'down',
'rowid' => $ruleaction[
'id']],
true).
'">'.
img_down(
'default', 0,
'imgdownforline').
'</a>';
848 print
'<td class="right nowraponall">';
849 print
'<a class="editfielda marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editoperation&token='.
newToken().
'&operationid='.$ruleaction[
'id'].
'">'.
img_edit().
'</a>';
850 print
' <a href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'deleteoperation',
'operationid' => $ruleaction[
'id']],
true).
'">'.
img_delete().
'</a>';
860 if (!empty($conf->use_javascript_ajax)) {
861 $urltorefreshaftermove = DOL_URL_ROOT.
'/admin/emailcollector_card.php?id='.
$id;
862 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
871 print
'<div class="clearboth"></div><br>';
876 if ($action !=
'presend' && $action !=
'editline') {
877 print
'<div class="tabsAction">'.
"\n";
878 $parameters = array();
879 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
884 if (empty($reshook)) {
886 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>';
889 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken().
'&object=order">'.$langs->trans(
"ToClone").
'</a></div>';
892 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>';
894 if (count(
$object->actions) > 0) {
895 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>';
897 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoOperations")).
'">'.$langs->trans(
"CollectNow").
'</a></div>';
900 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.urlencode(
newToken()).
'">'.$langs->trans(
'Delete').
'</a></div>';
905 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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
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)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.