27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
32include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
33include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
34include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollector.class.php';
35include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollectorfilter.class.php';
36include_once DOL_DOCUMENT_ROOT.
'/emailcollector/class/emailcollectoraction.class.php';
37include_once DOL_DOCUMENT_ROOT.
'/emailcollector/lib/emailcollector.lib.php';
39use Webklex\PHPIMAP\ClientManager;
40use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
43use OAuth\Common\Storage\DoliStorage;
44use OAuth\Common\Consumer\Credentials;
49if (!isModEnabled(
'emailcollector')) {
54$langs->loadLangs(array(
"admin",
"mails",
"other"));
59$action =
GETPOST(
'action',
'aZ09');
60$confirm =
GETPOST(
'confirm',
'alpha');
61$cancel =
GETPOST(
'cancel',
'aZ09');
62$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'emailcollectorcard';
63$backtopage =
GETPOST(
'backtopage',
'alpha');
70$diroutputmassaction = $conf->emailcollector->dir_output.
'/temp/massgeneration/'.$user->id;
71$hookmanager->initHooks(array(
'emailcollectorcard'));
74$extrafields->fetch_name_optionals_label(
$object->table_element);
76$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
79$search_all =
GETPOST(
"search_all",
'alpha');
81foreach (
$object->fields as $key => $val) {
82 if (
GETPOST(
'search_'.$key,
'alpha')) {
83 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
88 $action =
'updateoperation';
90if (empty($action) && empty($id) && empty($ref)) {
95include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
103$permissionnote = $user->admin;
104$permissiondellink = $user->admin;
105$permissiontoadd = $user->admin;
115$parameters = array();
116$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
122if (empty($reshook)) {
123 $permissiontoadd = 1;
124 $permissiontodelete = 1;
125 if (empty($backtopage)) {
126 $backtopage = DOL_URL_ROOT.
'/admin/emailcollector_card.php?id='.(
$id > 0 ?
$id :
'__ID__');
128 $backurlforlist = DOL_URL_ROOT.
'/admin/emailcollector_list.php';
131 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
134 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
137 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
140if (
GETPOST(
'addfilter',
'alpha')) {
142 $emailcollectorfilter->type =
GETPOST(
'filtertype',
'aZ09');
143 $emailcollectorfilter->rulevalue =
GETPOST(
'rulevalue',
'alpha');
144 $emailcollectorfilter->fk_emailcollector =
$object->id;
145 $emailcollectorfilter->status = 1;
147 $result = $emailcollectorfilter->create($user);
152 setEventMessages($emailcollectorfilter->error, $emailcollectorfilter->errors,
'errors');
156if ($action ==
'deletefilter') {
158 $emailcollectorfilter->fetch(
GETPOSTINT(
'filterid'));
159 if ($emailcollectorfilter->id > 0) {
160 $result = $emailcollectorfilter->delete($user);
164 setEventMessages($emailcollectorfilter->error, $emailcollectorfilter->errors,
'errors');
169if (
GETPOST(
'addoperation',
'alpha')) {
171 $emailcollectoroperation->type =
GETPOST(
'operationtype',
'aZ09');
172 $emailcollectoroperation->actionparam =
GETPOST(
'operationparam',
'restricthtml');
173 $emailcollectoroperation->fk_emailcollector =
$object->id;
174 $emailcollectoroperation->status = 1;
175 $emailcollectoroperation->position = 50;
177 if ($emailcollectoroperation->type ==
'-1') {
179 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Operation")),
null,
'errors');
182 if (in_array($emailcollectoroperation->type, array(
'loadthirdparty',
'loadandcreatethirdparty'))
183 && empty($emailcollectoroperation->actionparam)) {
185 setEventMessages($langs->trans(
"ErrorAParameterIsRequiredForThisOperation"),
null,
'errors');
189 $result = $emailcollectoroperation->create($user);
195 setEventMessages($emailcollectoroperation->error, $emailcollectoroperation->errors,
'errors');
200if ($action ==
'updateoperation') {
202 $emailcollectoroperation->fetch(
GETPOSTINT(
'rowidoperation2'));
204 $emailcollectoroperation->actionparam =
GETPOST(
'operationparam2',
'alphawithlgt');
206 if (in_array($emailcollectoroperation->type, array(
'loadthirdparty',
'loadandcreatethirdparty'))
207 && empty($emailcollectoroperation->actionparam)) {
209 setEventMessages($langs->trans(
"ErrorAParameterIsRequiredForThisOperation"),
null,
'errors');
213 $result = $emailcollectoroperation->update($user);
219 setEventMessages($emailcollectoroperation->error, $emailcollectoroperation->errors,
'errors');
223if ($action ==
'deleteoperation') {
225 $emailcollectoroperation->fetch(
GETPOSTINT(
'operationid'));
226 if ($emailcollectoroperation->id > 0) {
227 $result = $emailcollectoroperation->delete($user);
231 setEventMessages($emailcollectoroperation->error, $emailcollectoroperation->errors,
'errors');
236if ($action ==
'collecttest') {
239 $res =
$object->doCollectOneCollector(1);
241 $debuginfo =
$object->debuginfo;
244 $debuginfo =
$object->debuginfo;
251if ($action ==
'confirm_collect') {
254 $res =
$object->doCollectOneCollector(0);
256 $debuginfo =
$object->debuginfo;
259 $debuginfo =
$object->debuginfo;
272$form =
new Form($db);
275$help_url =
"EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
277llxHeader(
'',
'EmailCollector', $help_url,
'', 0, 0,
'',
'',
'',
'mod-admin page-emailcollector_card');
280if ($action ==
'create') {
281 print
load_fiche_titre($langs->trans(
"NewEmailCollector", $langs->transnoentitiesnoconv(
"EmailCollector")));
283 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
284 print
'<input type="hidden" name="token" value="'.newToken().
'">';
285 print
'<input type="hidden" name="action" value="add">';
286 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
290 print
'<table class="border centpercent tableforfield">'.
"\n";
295 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
298 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
300 print
'</table>'.
"\n";
304 print $form->buttonsSaveCancel(
"Create");
310if (($id || $ref) && $action ==
'edit') {
313 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
314 print
'<input type="hidden" name="token" value="'.newToken().
'">';
315 print
'<input type="hidden" name="action" value="update">';
316 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
317 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
321 print
'<table class="border centpercent tableforfield">'.
"\n";
324 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
327 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
333 print $form->buttonsSaveCancel();
339if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
340 $res =
$object->fetch_optionals();
346 print
dol_get_fiche_head($head,
'card', $langs->trans(
"EmailCollector"), -1,
'email');
351 if ($action ==
'delete') {
352 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteEmailCollector'), $langs->trans(
'ConfirmDeleteEmailCollector'),
'confirm_delete',
'', 0, 1);
356 if ($action ==
'clone') {
358 $formquestion = array();
359 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEmailCollector',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
363 if ($action ==
'collect') {
364 $formquestion = array();
365 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'EmailCollectorConfirmCollectTitle'), $langs->trans(
'EmailCollectorConfirmCollect'),
'confirm_collect', $formquestion, 0, 1, 220);
369 $parameters = array(
'formConfirm' => $formconfirm);
370 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
371 if (empty($reshook)) {
372 $formconfirm .= $hookmanager->resPrint;
373 } elseif ($reshook > 0) {
374 $formconfirm = $hookmanager->resPrint;
382 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/emailcollector_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
384 $morehtmlref =
'<div class="refidno">';
385 $morehtmlref .=
'</div>';
389 $sourcedir =
$object->source_directory;
390 $targetdir = (
$object->target_directory ?
$object->target_directory :
'');
393 $connectstringserver =
$object->getConnectStringIMAP();
394 $connectstringsource =
'';
395 $connectstringtarget =
'';
398 if ($action ==
'scan') {
400 require_once DOL_DOCUMENT_ROOT.
'/includes/webklex/php-imap/vendor/autoload.php';
402 if (
$object->acces_type == 1) {
403 dol_syslog(
"Scan IMAP with authentication mode = OAUTH2");
406 require_once DOL_DOCUMENT_ROOT.
'/core/lib/oauth.lib.php';
410 $keyforsupportedoauth2array =
$object->oauth_service;
411 if (preg_match(
'/^.*-/', $keyforsupportedoauth2array)) {
412 $keyforprovider = preg_replace(
'/^.*-/',
'', $keyforsupportedoauth2array);
414 $keyforprovider =
'';
416 $keyforsupportedoauth2array = preg_replace(
'/-.*$/',
'', strtoupper($keyforsupportedoauth2array));
417 $keyforsupportedoauth2array =
'OAUTH_'.$keyforsupportedoauth2array.
'_NAME';
419 if (!empty($supportedoauth2array)) {
420 $nameofservice = ucfirst(strtolower(empty($supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']) ?
'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']));
421 $nameofservice .= ($keyforprovider ?
'-'.$keyforprovider :
'');
422 $OAUTH_SERVICENAME = $nameofservice;
424 $OAUTH_SERVICENAME =
'Unknown';
427 $keyforparamtenant =
'OAUTH_'.strtoupper(empty($supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']) ?
'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array][
'callbackfile']).($keyforprovider ?
'-'.$keyforprovider :
'').
'_TENANT';
429 require_once DOL_DOCUMENT_ROOT.
'/includes/OAuth/bootstrap.php';
435 $storage =
new DoliStorage($db, $conf, $keyforprovider,
getDolGlobalString($keyforparamtenant));
438 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
446 if (is_object($tokenobj) && $expire) {
447 $credentials =
new Credentials(
452 $serviceFactory = new \OAuth\ServiceFactory();
453 $oauthname = explode(
'-', $OAUTH_SERVICENAME);
456 $apiService = $serviceFactory->createService($oauthname[0], $credentials, $storage, array());
457 '@phan-var-force OAuth\OAuth2\Service\AbstractService|OAuth\OAuth1\Service\AbstractService $apiService';
460 $refreshtoken = $tokenobj->getRefreshToken();
464 $tokenobj = $apiService->refreshAccessToken($tokenobj);
466 throw new Exception(
"Failed to refresh access token: ".$e->getMessage());
470 $tokenobj->setRefreshToken($refreshtoken);
471 $storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj);
474 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
475 if (is_object($tokenobj)) {
476 $token = $tokenobj->getAccessToken();
479 $morehtml .=
"Token not found";
483 $morehtml .= $e->getMessage();
488 $morehtml .=
'Error: Login is empty. Must be email owner when using MAIN_IMAP_USE_PHPIMAP and OAuth.';
491 $cm =
new ClientManager();
492 $client = $cm->make([
495 'encryption' =>
'ssl',
496 'validate_cert' =>
true,
497 'protocol' =>
'imap',
499 'password' => $token,
500 'authentication' =>
"oauth",
503 dol_syslog(
"Scan IMAP with authentication mode = PASS");
506 $cm =
new ClientManager();
507 $client = $cm->make([
510 'encryption' =>
'ssl',
511 'validate_cert' =>
true,
512 'protocol' =>
'imap',
514 'password' =>
$object->password,
515 'authentication' =>
"login",
535 $f = $client->getFolders(
false,
$object->source_directory);
538 if ($folder instanceof Webklex\PHPIMAP\Folder) {
539 $nbemail = $folder->examine()[
"exists"];
546 $morehtml .= $nbemail;
547 }
catch (ConnectionFailedException $e) {
548 $morehtml .=
'ConnectionFailedException '.$e->getMessage();
552 if (function_exists(
'imap_open')) {
556 $connectstringsource = $connectstringserver.$object->getEncodedUtf7($sourcedir);
560 $connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir);
566 dol_syslog(
"imap_open connectstring=".$connectstringsource.
" login=".
$object->login.
" password=".
$object->password.
" timeoutconnect=".$timeoutconnect.
" timeoutread=".$timeoutread);
568 $result1 = imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect);
569 $result2 = imap_timeout(IMAP_READTIMEOUT, $timeoutread);
570 $result3 = imap_timeout(IMAP_WRITETIMEOUT, 5);
571 $result4 = imap_timeout(IMAP_CLOSETIMEOUT, 5);
573 dol_syslog(
"result1=".$result1.
" result2=".$result2.
" result3=".$result3.
" result4=".$result4);
575 $connection = imap_open($connectstringsource,
$object->login,
$object->password);
579 $morehtml .= $e->getMessage();
583 $morehtml .=
'Failed to open IMAP connection '.$connectstringsource;
584 if (function_exists(
'imap_last_error')) {
585 $morehtml .=
'<br>'.imap_last_error();
590 dol_syslog(
"Imap connected. Now we call imap_num_msg()");
591 $morehtml .= imap_num_msg($connection);
596 imap_close($connection);
599 $morehtml .=
'IMAP functions not available on your PHP. ';
604 $morehtml = $form->textwithpicto($langs->trans(
"NbOfEmailsInInbox"),
'Connect string = '.$connectstringserver.
'<br>Option MAIN_IMAP_USE_PHPIMAP = '.
getDolGlobalInt(
'MAIN_IMAP_USE_PHPIMAP')).
': '.($morehtml !==
'' ? $morehtml :
'?');
605 $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>';
607 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref.
'<div class="refidno">'.$morehtml.
'</div>',
'', 0,
'',
'', 0,
'');
609 print
'<div class="fichecenter">';
610 print
'<div class="fichehalfleft">';
611 print
'<div class="underbanner clearboth"></div>';
612 print
'<table class="border centpercent tableforfield">'.
"\n";
615 if (
$object->acces_type == 0) {
617 unset(
$object->fields[
'oauth_service']);
619 if (
$object->acces_type == 1) {
621 unset(
$object->fields[
'password']);
627 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
630 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
635 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
636 print
'<input type="hidden" name="token" value="'.newToken().
'">';
637 print
'<input type="hidden" name="action" value="updatefiltersactions">';
638 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
639 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
642 print
'<div class="div-table-responsive-no-min">';
643 print
'<table id="tablelineoffilters" class="noborder noshadow">';
644 print
'<tr class="liste_titre nodrag nodrop">';
645 print
'<td>'.img_picto(
'',
'filter',
'class="pictofixedwidth opacitymedium"').$form->textwithpicto($langs->trans(
"Filters"), $langs->trans(
"EmailCollectorFilterDesc")).
'</td><td></td><td></td>';
648 print
'<tr class="oddeven nodrag nodrop">';
650 $arrayoftypes = array(
651 'from' => array(
'label' =>
'MailFrom',
'data-placeholder' => $langs->trans(
'SearchString')),
652 'to' => array(
'label' =>
'MailTo',
'data-placeholder' => $langs->trans(
'SearchString')),
653 'cc' => array(
'label' =>
'Cc',
'data-placeholder' => $langs->trans(
'SearchString')),
654 'bcc' => array(
'label' =>
'Bcc',
'data-placeholder' => $langs->trans(
'SearchString')),
655 'replyto' => array(
'label' =>
'ReplyTo',
'data-placeholder' => $langs->trans(
'SearchString')),
656 'subject' => array(
'label' =>
'Subject',
'data-placeholder' => $langs->trans(
'SearchString')),
657 'body' => array(
'label' =>
'Body',
'data-placeholder' => $langs->trans(
'SearchString')),
662 'seen' => array(
'label' =>
'AlreadyRead',
'data-noparam' => 1),
663 'unseen' => array(
'label' =>
'NotRead',
'data-noparam' => 1),
664 'unanswered' => array(
'label' =>
'Unanswered',
'data-noparam' => 1),
665 'answered' => array(
'label' =>
'Answered',
'data-noparam' => 1),
666 'smaller' => array(
'label' => $langs->trans(
"Size").
' ('.$langs->trans(
"SmallerThan").
")",
'data-placeholder' => $langs->trans(
'NumberOfBytes')),
667 'larger' => array(
'label' => $langs->trans(
"Size").
' ('.$langs->trans(
"LargerThan").
")",
'data-placeholder' => $langs->trans(
'NumberOfBytes')),
669 'withtrackingid' => array(
'label' =>
'WithDolTrackingID',
'data-noparam' => 1),
670 'withouttrackingid' => array(
'label' =>
'WithoutDolTrackingID',
'data-noparam' => 1),
671 'withtrackingidinmsgid' => array(
'label' =>
'WithDolTrackingIDInMsgId',
'data-noparam' => 1),
672 'withouttrackingidinmsgid' => array(
'label' =>
'WithoutDolTrackingIDInMsgId',
'data-noparam' => 1),
674 'isnotanswer' => array(
'label' =>
'IsNotAnAnswer',
'data-noparam' => 1),
675 'isanswer' => array(
'label' =>
'IsAnAnswer',
'data-noparam' => 1)
677 print $form->selectarray(
'filtertype', $arrayoftypes,
'', 1, 0, 0,
'', 1, 0, 0,
'',
'maxwidth300', 1,
'', 2);
681 print
'jQuery("#filtertype").change(function() {
682 console.log("We change a filter");
683 if (jQuery("#filtertype option:selected").attr("data-noparam")) {
684 jQuery("#rulevalue").attr("placeholder", "");
685 jQuery("#rulevalue").text("");
686 jQuery("#rulevalue").prop("disabled", true);
687 jQuery("#rulevaluehelp").addClass("unvisible");
689 jQuery("#rulevalue").prop("disabled", false);
690 jQuery("#rulevaluehelp").removeClass("unvisible");
692 jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder")));
700 print
'</script>'.
"\n";
702 print
'</td><td class="nowraponall">';
703 print
'<div class="nowraponall">';
704 print
'<input type="text" name="rulevalue" id="rulevalue" class="inline-block valignmiddle">';
705 print
'<div class="inline-block valignmiddle unvisible" id="rulevaluehelp">';
706 print
img_warning($langs->trans(
"FilterSearchImapHelp"),
'',
'pictowarning classfortooltip');
710 print
'<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button smallpaddingimp" value="'.$langs->trans(
"Add").
'"></td>';
713 foreach (
$object->filters as $rulefilter) {
715 $rulefilterobj->fetch($rulefilter[
'id']);
717 print
'<tr class="oddeven">';
718 print
'<td title="'.dol_escape_htmltag($langs->trans(
"Filter").
': '.$rulefilter[
'type']).
'">';
719 print $langs->trans($arrayoftypes[$rulefilter[
'type']][
'label']);
721 print
'<td>'.$rulefilter[
'rulevalue'].
'</td>';
722 print
'<td class="right">';
723 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletefilter&token='.urlencode(
newToken()).
'&filterid='.$rulefilter[
'id'].
'">'.
img_delete().
'</a>';
732 print
'<div class="clearboth"></div><br><br>';
735 print
'<div class="div-table-responsive-no-min">';
736 print
'<table id="tablelines" class="noborder noshadow">';
737 print
'<tr class="liste_titre nodrag nodrop">';
738 print
'<td>'.img_picto(
'',
'technic',
'class="pictofixedwidth"').$form->textwithpicto($langs->trans(
"EmailcollectorOperations"), $langs->trans(
"EmailcollectorOperationsDesc")).
'</td>';
740 $htmltext = $langs->transnoentitiesnoconv(
"OperationParamDesc");
741 print $form->textwithpicto($langs->trans(
"Parameters"), $htmltext, 1,
'help',
'', 0, 2,
'operationparamtt');
747 $arrayoftypes = array(
748 'loadthirdparty' => $langs->trans(
'LoadThirdPartyFromName', $langs->transnoentities(
"ThirdPartyName").
'/'.$langs->transnoentities(
"AliasNameShort").
'/'.$langs->transnoentities(
"Email").
'/'.$langs->transnoentities(
"ID")),
749 'loadandcreatethirdparty' => $langs->trans(
'LoadThirdPartyFromNameOrCreate', $langs->transnoentities(
"ThirdPartyName").
'/'.$langs->transnoentities(
"AliasNameShort").
'/'.$langs->transnoentities(
"Email").
'/'.$langs->transnoentities(
"ID")),
750 'recordjoinpiece' =>
'AttachJoinedDocumentsToObject',
751 'recordevent' =>
'RecordEvent'
753 $arrayoftypesnocondition = $arrayoftypes;
754 if (isModEnabled(
'project')) {
755 $arrayoftypes[
'project'] =
'CreateLeadAndThirdParty';
757 $arrayoftypesnocondition[
'project'] =
'CreateLeadAndThirdParty';
758 if (isModEnabled(
'ticket')) {
759 $arrayoftypes[
'ticket'] =
'CreateTicketAndThirdParty';
761 $arrayoftypesnocondition[
'ticket'] =
'CreateTicketAndThirdParty';
762 if (isModEnabled(
'recruitment')) {
763 $arrayoftypes[
'candidature'] =
'CreateCandidature';
765 $arrayoftypesnocondition[
'candidature'] =
'CreateCandidature';
768 $parameters = array(
'arrayoftypes' => $arrayoftypes);
769 $res = $hookmanager->executeHooks(
'addMoreActionsEmailCollector', $parameters, $object, $action);
772 $arrayoftypes = $hookmanager->resArray;
774 foreach ($hookmanager->resArray as $k => $desc) {
775 $arrayoftypes[$k] = $desc;
780 print
'<tr class="oddeven nodrag nodrop">';
782 print $form->selectarray(
'operationtype', $arrayoftypes,
'', 1, 0, 0,
'', 1, 0, 0,
'',
'minwidth150 maxwidth250', 1);
784 print
'<textarea class="centpercent" name="operationparam" rows="3"></textarea>';
788 print
'<td class="right"><input type="submit" name="addoperation" id="addoperation" class="flat button smallpaddingimp" value="'.$langs->trans(
"Add").
'"></td>';
791 $nboflines = count(
$object->actions);
792 $table_element_line =
'emailcollector_emailcollectoraction';
793 $fk_element =
'position';
795 foreach (
$object->actions as $ruleaction) {
797 $ruleactionobj->fetch($ruleaction[
'id']);
799 print
'<tr class="drag drop oddeven" id="row-'.$ruleaction[
'id'].
'">';
800 print
'<td title="'.dol_escape_htmltag($langs->trans(
"Operation").
': '.$ruleaction[
'type']).
'">';
801 print
'<!-- type of action: '.$ruleaction[
'type'].
' -->';
802 if (array_key_exists($ruleaction[
'type'], $arrayoftypes)) {
803 print $langs->trans($arrayoftypes[$ruleaction[
'type']]);
805 if (array_key_exists($ruleaction[
'type'], $arrayoftypesnocondition)) {
806 print
'<span class="opacitymedium">'.$langs->trans($arrayoftypesnocondition[$ruleaction[
'type']]).
' - '.$langs->trans(
"Disabled").
'</span>';
810 if (in_array($ruleaction[
'type'], array(
'recordevent'))) {
811 print $form->textwithpicto(
'', $langs->transnoentitiesnoconv(
'IfTrackingIDFoundEventWillBeLinked'));
812 } elseif (in_array($ruleaction[
'type'], array(
'loadthirdparty',
'loadandcreatethirdparty'))) {
813 print $form->textwithpicto(
'', $langs->transnoentitiesnoconv(
'EmailCollectorLoadThirdPartyHelp'));
816 print
'<td class="wordbreak minwidth300 small">';
817 if ($action ==
'editoperation' && $ruleaction[
'id'] == $operationid) {
819 print
'<textarea class="centpercent" name="operationparam2" rows="3">';
822 print
'<input type="hidden" name="rowidoperation2" value="'.$ruleaction[
'id'].
'">';
823 print
'<input type="submit" class="button small button-save" name="saveoperation2" value="'.$langs->trans(
"Save").
'">';
824 print
'<input type="submit" class="button small button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
830 print
'<td class="center linecolmove tdlineupdown">';
832 print
'<a class="lineupdown" href="'.$_SERVER[
'PHP_SELF'].
'?action=up&rowid='.$ruleaction[
'id'].
'">'.
img_up(
'default', 0,
'imgupforline').
'</a>';
834 if ($i < count(
$object->actions) - 1) {
835 print
'<a class="lineupdown" href="'.$_SERVER[
'PHP_SELF'].
'?action=down&rowid='.$ruleaction[
'id'].
'">'.
img_down(
'default', 0,
'imgdownforline').
'</a>';
839 print
'<td class="right nowraponall">';
840 print
'<a class="editfielda marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editoperation&token='.
newToken().
'&operationid='.$ruleaction[
'id'].
'">'.
img_edit().
'</a>';
841 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deleteoperation&token='.
newToken().
'&operationid='.$ruleaction[
'id'].
'">'.
img_delete().
'</a>';
851 if (!empty($conf->use_javascript_ajax)) {
852 $urltorefreshaftermove = DOL_URL_ROOT.
'/admin/emailcollector_card.php?id='.
$id;
853 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
862 print
'<div class="clearboth"></div><br>';
867 if ($action !=
'presend' && $action !=
'editline') {
868 print
'<div class="tabsAction">'.
"\n";
869 $parameters = array();
870 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
875 if (empty($reshook)) {
877 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>';
880 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>';
883 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>';
885 if (count(
$object->actions) > 0) {
886 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>';
888 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoOperations")).
'">'.$langs->trans(
"CollectNow").
'</a></div>';
891 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>';
896 if (!empty($debuginfo)) {
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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 used 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.