--- /tmp/dsg/dolibarr/htdocs/comm/mailing/github_advtargetemailing.php +++ /tmp/dsg/dolibarr/htdocs/comm/mailing/client_advtargetemailing.php @@ -46,8 +46,8 @@ // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; @@ -87,7 +87,9 @@ if ($result < 0) { setEventMessages($advTarget->error, $advTarget->errors, 'errors'); -} else { +} +else +{ if (!empty($advTarget->id)) { $array_query = json_decode($advTarget->filtervalue, true); } @@ -415,7 +417,7 @@ if ($object->fetch($id) >= 0) { $head = emailing_prepare_head($object); - print dol_get_fiche_head($head, 'advtargets', $langs->trans("Mailing"), 0, 'email'); + dol_fiche_head($head, 'advtargets', $langs->trans("Mailing"), 0, 'email'); print ''; @@ -426,7 +428,7 @@ print $form->showrefnav($object, 'id', $linkback); print ''; - print ''; + print ''; print ''; --- /tmp/dsg/dolibarr/htdocs/comm/mailing/github_card.php +++ /tmp/dsg/dolibarr/htdocs/comm/mailing/client_card.php @@ -41,7 +41,7 @@ if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) accessforbidden(); $id = (GETPOST('mailid', 'int') ? GETPOST('mailid', 'int') : GETPOST('id', 'int')); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $urlfrom = GETPOST('urlfrom'); @@ -93,17 +93,21 @@ if (!GETPOST("clone_content", 'alpha') && !GETPOST("clone_receivers", 'alpha')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); - } else { + } + else + { $result = $object->createFromClone($user, $object->id, GETPOST("clone_content", 'alpha'), GETPOST("clone_receivers", 'alpha')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit; - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } } - $action = ''; + $action = ''; } // Action send emailing for everybody @@ -116,11 +120,14 @@ setEventMessages('', null, 'warnings'); setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); $action = ''; - } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) + } + elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings'); $action = ''; - } else { + } + else + { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); if ($object->statut == 0) @@ -135,7 +142,7 @@ $from = $object->email_from; $replyto = $object->email_replyto; $errorsto = $object->email_errorsto; - // Is the message in html + // Le message est-il en html $msgishtml = -1; // Unknown by default if (preg_match('/[\s\t]*/i', $message)) $msgishtml = 1; @@ -144,8 +151,8 @@ $nbok = 0; $nbko = 0; - // We choose mails not already sent for this mailing (statut=0) - // or sent in error (statut=-1) + // On choisit les mails non deja envoyes pour ce mailing (statut=0) + // ou envoyes en erreur (statut=-1) $sql = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id; @@ -155,7 +162,7 @@ $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); // Number of possible recipients + $num = $db->num_rows($resql); // nb of possible recipients if ($num) { @@ -163,7 +170,7 @@ $now = dol_now(); - // Positioning date of start sending + // Positionne date debut envoi $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$object->id; $resql2 = $db->query($sql); if (!$resql2) @@ -188,18 +195,18 @@ // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... $other = explode(';', $obj->other); $tmpfield = explode('=', $other[0], 2); $other1 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - - $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); - - $targetobject = null; // Not defined with mass emailing - $parameters = array('mode'=>'emailing'); - $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object - - // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) + $tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); + + $targetobject = null; // Not defined with mass emailing + $parameters = array('mode'=>'emailing'); + $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object + + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; $substitutionarray['__EMAIL__'] = $obj->email; $substitutionarray['__LASTNAME__'] = $obj->lastname; @@ -211,8 +218,9 @@ $substitutionarray['__OTHER4__'] = $other4; $substitutionarray['__OTHER5__'] = $other5; $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) - $substitutionarray['__CHECK_READ__'] = ''; - $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; + $substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility + $substitutionarray['__CHECK_READ__'] = ''; + $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; $onlinepaymentenabled = 0; if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++; @@ -227,7 +235,9 @@ $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - } else { + } + else + { $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'order'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); @@ -253,7 +263,7 @@ } //$substitutionisok=true; - complete_substitutions_array($substitutionarray, $langs); + complete_substitutions_array($substitutionarray, $langs); $newsubject = make_substitutions($subject, $substitutionarray); $newmessage = make_substitutions($message, $substitutionarray); @@ -273,7 +283,7 @@ } } - // Mail making + // Fabrication du mail $trackid = 'emailing-'.$obj->fk_mailing.'-'.$obj->rowid; $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, '', 'emailing'); @@ -306,7 +316,9 @@ if (!$resql2) { dol_print_error($db); - } else { + } + else + { //if cheack read is use then update prospect contact status if (strpos($message, '__CHECK_READ__') !== false) { @@ -319,7 +331,7 @@ dol_print_error($db); } - //Update status communication of contact prospect + //Update status communication of contact prospect $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("card.php: set prospect contact status", LOG_DEBUG); @@ -331,13 +343,16 @@ } } - if (!empty($conf->global->MAILING_DELAY)) { + if (!empty($conf->global->MAILING_DELAY)) + { dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY); - usleep((float) $conf->global->MAILING_DELAY * 1000000); + sleep($conf->global->MAILING_DELAY); } - //test if CHECK READ change statut prospect contact - } else { + //test if CHECK READ change statut prospect contact + } + else + { // Mail failed $nbko++; @@ -354,7 +369,9 @@ $i++; } - } else { + } + else + { setEventMessages($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"), null, 'mesgs'); } @@ -364,12 +381,16 @@ $statut = 2; // Status 'sent partially' (because at least one error) if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); - } else { + } + else + { if ($nbok >= $num) { $statut = 3; // Send to everybody setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); - } else { + } + else + { $statut = 2; // Status 'sent partially' (because not send to everybody) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } @@ -382,7 +403,9 @@ { dol_print_error($db); } - } else { + } + else + { dol_syslog($db->error()); dol_print_error($db); } @@ -407,16 +430,16 @@ if (!$error) { - // Is the message in html - $msgishtml = -1; // Unknow by default + // Le message est-il en html + $msgishtml = -1; // Inconnu par defaut if (preg_match('/[\s\t]*/i', $object->body)) $msgishtml = 1; // other are set at begin of page $object->substitutionarrayfortest['__EMAIL__'] = $object->sendto; $object->substitutionarrayfortest['__MAILTOEMAIL__'] = ''.$object->sendto.''; - // Subject and message substitutions - complete_substitutions_array($object->substitutionarrayfortest, $langs); + // Pratique les substitutions sur le sujet et message + complete_substitutions_array($object->substitutionarrayfortest, $langs); $tmpsujet = make_substitutions($object->sujet, $object->substitutionarrayfortest); $tmpbody = make_substitutions($object->body, $object->substitutionarrayfortest); @@ -425,11 +448,11 @@ $arr_name = array(); $arr_css = array(); - // Add CSS - if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; - if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; - - // Attached files + // Ajout CSS + if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; + if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; + + // Attached files $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); if (count($listofpaths)) { @@ -449,7 +472,9 @@ { setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs'); $action = ''; - } else { + } + else + { setEventMessages($langs->trans("ResultKo").'
'.$mailfile->error.' '.$result, null, 'errors'); $action = 'test'; } @@ -461,16 +486,16 @@ { $mesgs = array(); - $object->email_from = GETPOST("from", "none"); // Must allow 'name ' - $object->email_replyto = GETPOST("replyto", "none"); // Must allow 'name ' - $object->email_errorsto = GETPOST("errorsto", "none"); // Must allow 'name ' - $object->title = GETPOST("title"); - $object->sujet = GETPOST("sujet"); - $object->body = GETPOST("bodyemail", 'restricthtml'); - $object->bgcolor = GETPOST("bgcolor"); - $object->bgimage = GETPOST("bgimage"); - - if (!$object->title) { + $object->email_from = trim($_POST["from"]); + $object->email_replyto = trim($_POST["replyto"]); + $object->email_errorsto = trim($_POST["errorsto"]); + $object->titre = trim($_POST["titre"]); + $object->sujet = trim($_POST["sujet"]); + $object->body = trim($_POST["bodyemail"]); + $object->bgcolor = trim($_POST["bgcolor"]); + $object->bgimage = trim($_POST["bgimage"]); + + if (!$object->titre) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } if (!$object->sujet) { @@ -490,20 +515,21 @@ $mesgs[] = $object->error; } - setEventMessages(null, $mesgs, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); $action = "create"; } // Action update description of emailing - if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') + if ($action == 'settitre' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); - if ($action == 'settitle') $object->title = trim(GETPOST('title', 'alpha')); - elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name ' - elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name ' - elseif ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name ' - elseif ($action == 'settitle' && empty($object->title)) { + if ($action == 'settitre') $object->titre = trim(GETPOST('titre', 'alpha')); + elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'alpha')); + elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'alpha')); + elseif ($action == 'setemail_errorsto') { + $object->email_errorsto = trim(GETPOST('email_errorsto', 'alpha')); + } elseif ($action == 'settitre' && empty($object->titre)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } elseif ($action == 'setfrom' && empty($object->email_from)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); @@ -532,25 +558,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - // Set tmp user directory - dol_add_file_process($upload_dir, 0, 0); + // Set tmp user directory + dol_add_file_process($upload_dir, 0, 0); $action = "edit"; } - // Action of file remove + // Action remove file if (!empty($_POST["removedfile"])) { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing + dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing $action = "edit"; } - // Action of emailing update + // Action update emailing if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -561,10 +587,10 @@ { $mesgs = array(); - $object->sujet = GETPOST("sujet"); - $object->body = GETPOST("bodyemail", 'restricthtml'); - $object->bgcolor = GETPOST("bgcolor"); - $object->bgimage = GETPOST("bgimage"); + $object->sujet = trim($_POST["sujet"]); + $object->body = trim($_POST["bodyemail"]); + $object->bgcolor = trim($_POST["bgcolor"]); + $object->bgimage = trim($_POST["bgimage"]); if (!$object->sujet) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic")); @@ -585,12 +611,14 @@ setEventMessages($mesg, $mesgs, 'errors'); $action = "edit"; - } else { + } + else + { $action = "edit"; } } - // Action of validation confirmation + // Action confirmation validation if ($action == 'confirm_valid' && $confirm == 'yes') { if ($object->id > 0) @@ -599,26 +627,32 @@ setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } else { + } + else + { dol_print_error($db); } } - // Action of validation confirmation + // Action confirmation validation if ($action == 'confirm_settodraft' && $confirm == 'yes') { if ($object->id > 0) { $result = $object->setStatut(0); - if ($result > 0) - { - //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } else { + if ($result > 0) + { + //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { dol_print_error($db); } } @@ -641,16 +675,20 @@ $db->commit(); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } - } else { + } + else + { dol_print_error($db); } } - // Action of delete confirmation + // Action confirmation suppression if ($action == 'confirm_delete' && $confirm == 'yes') { if ($object->delete($object->id)) @@ -706,17 +744,17 @@ // Print mail form print load_fiche_titre($langs->trans("NewMailing"), $availablelink, 'object_email'); - print dol_get_fiche_head(); + dol_fiche_head(); print '
'.$langs->trans("MailTitle").''.$object->title.'
'.$langs->trans("MailTitle").''.$object->titre.'
'.$langs->trans("MailFrom").''.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'
'; - print ''; + print ''; print ''; print ''; // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); @@ -734,18 +772,20 @@ print '
'.$langs->trans("MailTitle").'
'.$langs->trans("MailTitle").'
'.$langs->trans("MailFrom").'
'.$langs->trans("MailErrorsTo").'
'; print '
'; - // wysiwyg editor + // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'restricthtml'), '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); + $doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'none'), '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); $doleditor->Create(); print '
'; - print dol_get_fiche_end(); + dol_fiche_end(); print '
'; print ''; -} else { +} +else +{ if ($object->id > 0) { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); @@ -757,15 +797,17 @@ { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("SetToDraft"), $langs->trans("ConfirmUnvalidateEmailing"), "confirm_settodraft", '', '', 1); } - // Confirmation of mailing validation + // Confirmation validation of mailing if ($action == 'valid') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ValidMailing"), $langs->trans("ConfirmValidMailing"), "confirm_valid", '', '', 1); - } // Confirm reset + } + // Confirm reset elseif ($action == 'reset') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ResetMailing"), $langs->trans("ConfirmResetMailing", $object->ref), "confirm_reset", '', '', 2); - } // Confirm delete + } + // Confirm delete elseif ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); @@ -774,14 +816,14 @@ if ($action != 'edit' && $action != 'edithtml') { - print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); + dol_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); /* - * View mode mailing + * Mailing en mode visu */ if ($action == 'sendall') { - // Define message to recommand from command line + // Define message to recommand from command line $sendingmode = $conf->global->EMAILING_MAIL_SENDMODE; if (empty($sendingmode)) $sendingmode = $conf->global->MAIN_MAIL_SENDMODE; if (empty($sendingmode)) $sendingmode = 'mail'; // If not defined, we use php mail function @@ -799,32 +841,36 @@ setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings'); if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings'); $_GET["action"] = ''; - } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { - if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); - if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + } + elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) + { + if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); // The feature is forbidden from GUI, we show just message to use from command line. - setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); setEventMessages('', null, 'warnings'); if ($conf->file->mailing_limit_sendbyweb != '-1') // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it. { - setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... + setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... } $_GET["action"] = ''; - } else { - if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); - if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); - - $text = ''; - if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) - { - $text .= $langs->trans("MailingNeedCommand"); - $text .= '
'; - $text .= '

'; - } - $text .= $langs->trans('ConfirmSendingEmailing').'
'; + } + else + { + if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + + $text = ''; + if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) + { + $text .= $langs->trans("MailingNeedCommand"); + $text .= '
'; + $text .= '

'; + } + $text .= $langs->trans('ConfirmSendingEmailing').'
'; $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', '', '', 1, 330, 600); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', $formquestion, '', 1, 330, 600); } } @@ -851,9 +897,9 @@ // Description print ''; - print $form->editfieldkey("MailTitle", 'title', $object->title, $object, $user->rights->mailing->creer && $object->statut < 3, 'string'); + print $form->editfieldkey("MailTitle", 'titre', $object->titre, $object, $user->rights->mailing->creer && $object->statut < 3, 'string'); print ''; - print $form->editfieldval("MailTitle", 'title', $object->title, $object, $user->rights->mailing->creer && $object->statut < 3, 'string'); + print $form->editfieldval("MailTitle", 'titre', $object->titre, $object, $user->rights->mailing->creer && $object->statut < 3, 'string'); print ''; // From @@ -865,11 +911,7 @@ if ($email && !isValidEmail($email)) { $langs->load("errors"); print img_warning($langs->trans("ErrorBadEMail", $email)); - } elseif ($email && !isValidMailDomain($email)) { - $langs->load("errors"); - print img_warning($langs->trans("ErrorBadMXDomain", $email)); - } - + } print ''; // Errors to @@ -881,36 +923,37 @@ if ($email && !isValidEmail($email)) { $langs->load("errors"); print img_warning($langs->trans("ErrorBadEMail", $email)); - } elseif ($email && !isValidMailDomain($email)) { - $langs->load("errors"); - print img_warning($langs->trans("ErrorBadMXDomain", $email)); } print ''; - // Number of distinct emails + // Nb of distinct emails print ''; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { - $text = ''; - if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) - { - if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) - { - $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - } else { - $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); - } - } - if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + $text = ''; + if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) + { + if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) + { + $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); + } + else + { + $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); + } + } + if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; if ($text) - { - print $form->textwithpicto($nbemail, $text, 1, 'warning'); - } else { - print $nbemail; - } + { + print $form->textwithpicto($nbemail, $text, 1, 'warning'); + } + else + { + print $nbemail; + } } print ''; @@ -921,7 +964,7 @@ print ""; - print dol_get_fiche_end(); + dol_fiche_end(); // Clone confirmation @@ -933,12 +976,12 @@ array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContent"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers"), 'value' => 0) ); - // Incomplete payment. On demande si motif = escompte ou autre + // Paiement incomplet. On demande si motif = escompte ou autre print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneEMailing', $object->ref), 'confirm_clone', $formquestion, 'yes', 2, 240); } /* - * Actions Buttons + * Boutons d'action */ if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) @@ -955,7 +998,9 @@ if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) { print ''.$langs->trans("EditWithEditor").''; - } else { + } + else + { print ''.$langs->trans("EditWithTextEditor").''; } @@ -967,7 +1012,9 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("TestMailing").''; - } else { + } + else + { print ''.$langs->trans("TestMailing").''; } @@ -976,10 +1023,13 @@ if ($object->nbemail <= 0) { print ''.$langs->trans("ValidMailing").''; - } elseif (empty($user->rights->mailing->valider)) + } + elseif (empty($user->rights->mailing->valider)) { print ''.$langs->trans("ValidMailing").''; - } else { + } + else + { print ''.$langs->trans("ValidMailing").''; } } @@ -989,10 +1039,13 @@ if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { print ''.$langs->trans("SendMailing").''; - } elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) + } + elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("SendMailing").''; - } else { + } + else + { print ''.$langs->trans("SendMailing").''; } } @@ -1007,7 +1060,9 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("ResetMailing").''; - } else { + } + else + { print ''.$langs->trans("ResetMailing").''; } } @@ -1017,23 +1072,25 @@ if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) { print ''.$langs->trans("DeleteMailing").''; - } else { - print ''.$langs->trans("DeleteMailing").''; + } + else + { + print ''.$langs->trans("DeleteMailing").''; } } print ''; } - // Display of the TEST form + // Affichage formulaire de TEST if ($action == 'test') { - print '
'; - print load_fiche_titre($langs->trans("TestMailing")); - - print dol_get_fiche_head(null, '', '', -1); - - // Create mail form object + print '
'; + print load_fiche_titre($langs->trans("TestMailing")); + + dol_fiche_head(null, '', '', -1); + + // Create l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->fromname = $object->email_from; @@ -1050,9 +1107,9 @@ $formmail->withbodyreadonly = 1; $formmail->withcancel = 1; $formmail->withdeliveryreceipt = 0; - // Table of substitutions + // Tableau des substitutions $formmail->substit = $object->substitutionarrayfortest; - // Table of post's complementary params + // Tableau des parametres complementaires du post $formmail->param["action"] = "send"; $formmail->param["models"] = 'none'; $formmail->param["mailid"] = $object->id; @@ -1062,7 +1119,7 @@ print '
'; - print dol_get_fiche_end(); + dol_fiche_end(); print dol_set_focus('#sendto'); } @@ -1078,7 +1135,7 @@ // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto(''.$langs->trans("AvailableVariables").'', $htmltext, 1, 'helpclickable', '', 0, 2, 'emailsubstitionhelp'), 'generic'); - print dol_get_fiche_head('', '', '', -1); + dol_fiche_head('', '', '', -1); print ''; @@ -1096,37 +1153,42 @@ print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; print '
'; } - } else { + } + else + { print ''.$langs->trans("NoAttachedFiles").'
'; } print ''; - // Background color - /*print '';*/ print '
'.$langs->trans("BackgroundColorByDefault").''; + // Background color + /*print '
'.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($object->bgcolor,'bgcolor','',0); print '
'; - // Message + // Message print '
'; if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') // CKEditor does not apply the color of the div into its content area { $readonly = 1; - // wysiwyg editor + // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20, '90%', $readonly); $doleditor->Create(); - } else print dol_htmlentitiesbr($object->body); + } + else print dol_htmlentitiesbr($object->body); print '
'; - print dol_get_fiche_end(); - } else { + dol_fiche_end(); + } + else + { /* - * Edition mode mailing (CKeditor or HTML source) + * Mailing en mode edition (CKeditor or HTML source) */ - print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); + dol_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); $linkback = ''.$langs->trans("BackToList").''; @@ -1148,13 +1210,13 @@ */ // Topic - print ''.$langs->trans("MailTitle").''.$object->title.''; + print ''.$langs->trans("MailTitle").''.$object->titre.''; // From print ''.$langs->trans("MailFrom").''.dol_print_email($object->email_from, 0, 0, 0, 0, 1).''; // To print ''.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).''; - // Number of distinct emails + // Nb of distinct emails print ''; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; @@ -1167,7 +1229,9 @@ if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - } else { + } + else + { $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } @@ -1175,7 +1239,9 @@ if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); - } else { + } + else + { print $nbemail; } } @@ -1184,7 +1250,7 @@ // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); @@ -1193,7 +1259,7 @@ print ''; print ''; - print dol_get_fiche_end(); + dol_fiche_end(); @@ -1214,7 +1280,7 @@ // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'generic'); - print dol_get_fiche_head(null, '', '', -1); + dol_fiche_head(null, '', '', -1); print ''; @@ -1249,7 +1315,9 @@ $out .= ' '; $out .= '
'; } - } else { + } + else + { $out .= $langs->trans("NoAttachedFiles").'
'; } // Add link to add file @@ -1259,7 +1327,7 @@ print $out; print ''; - // Background color + // Background color print ''; @@ -1271,14 +1339,14 @@ if ($action == 'edit') { - // wysiwyg editor + // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); $doleditor->Create(); } if ($action == 'edithtml') { - // HTML source editor + // Editor HTML source require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, 'ace', 20, '90%'); $doleditor->Create(0, '', false, 'HTML Source', 'php'); @@ -1287,18 +1355,20 @@ print ''; - print dol_get_fiche_end(); + dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; print '
'; } - } else { + } + else + { dol_print_error($db, $object->error); } } --- /tmp/dsg/dolibarr/htdocs/comm/mailing/github_cibles.php +++ /tmp/dsg/dolibarr/htdocs/comm/mailing/client_cibles.php @@ -41,8 +41,8 @@ // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; @@ -78,13 +78,13 @@ foreach ($modulesdir as $dir) { - // Load modules attributes in arrays (name, numero, orders) from dir directory - //print $dir."\n
"; - dol_syslog("Scan directory ".$dir." for modules"); - - // Loading Class - $file = $dir."/".$module.".modules.php"; - $classname = "mailing_".$module; + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
"; + dol_syslog("Scan directory ".$dir." for modules"); + + // Loading Class + $file = $dir."/".$module.".modules.php"; + $classname = "mailing_".$module; if (file_exists($file)) { @@ -131,8 +131,8 @@ header('Content-Disposition: attachment;filename='.$completefilename); // List of selected targets - $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,"; - $sql .= " mc.source_id, mc.source_type, mc.error_text"; + $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms,"; + $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.fk_mailing=".$object->id; $sql .= $db->order($sortfield, $sortorder); @@ -146,21 +146,23 @@ while ($obj = $db->fetch_object($resql)) { print $obj->rowid.$sep; - print '"'.$obj->lastname.'"'.$sep; - print '"'.$obj->firstname.'"'.$sep; + print $obj->lastname.$sep; + print $obj->firstname.$sep; print $obj->email.$sep; print $obj->other.$sep; + print $obj->date_envoi.$sep; print $obj->tms.$sep; + print $obj->source_url.$sep; + print $obj->source_id.$sep; print $obj->source_type.$sep; - print $obj->source_id.$sep; - print $obj->date_envoi.$sep; - print $obj->status.$sep; - print '"'.$obj->error_text.'"'.$sep; + print $obj->error_text.$sep; print "\n"; } exit; - } else { + } + else + { dol_print_error($db); } exit; @@ -179,11 +181,15 @@ $obj->update_nb($id); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - } else { + } + else + { header("Location: list.php"); exit; } - } else { + } + else + { dol_print_error($db); } } @@ -213,7 +219,7 @@ { $head = emailing_prepare_head($object); - print dol_get_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, 'email'); + dol_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, 'email'); $linkback = ''.$langs->trans("BackToList").''; @@ -237,7 +243,7 @@ print '
'.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($object->bgcolor, 'bgcolor', '', 0); print '
'; - print ''; + print ''; print ''; print ''; print ''; // Date last update @@ -678,7 +676,9 @@ print ''; - } else { + } + else + { // Date sent print ''; @@ -692,7 +692,7 @@ if ($obj->statut == 0) // Not sent yet { if ($user->rights->mailing->creer && $allowaddtarget) { - print ''.img_delete($langs->trans("RemoveRecipient")).''; + print ''.img_delete($langs->trans("RemoveRecipient")).''; } } /*if ($obj->statut == -1) // Sent with error @@ -704,12 +704,14 @@ $i++; } - } else { + } + else + { if ($object->statut < 2) { - print ''; + print ''; } } print "
'.$langs->trans("MailTitle").''.$object->title.'
'.$langs->trans("MailTitle").''.$object->titre.'
'.$langs->trans("MailFrom").''; $emailarray = CMailFile::getArrayAddress($object->email_from); @@ -287,7 +293,9 @@ if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - } else { + } + else + { $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } @@ -295,7 +303,9 @@ if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); - } else { + } + else + { print $nbemail; } } @@ -305,7 +315,7 @@ print ""; - print dol_get_fiche_end(); + dol_fiche_end(); print '
'; @@ -337,12 +347,12 @@ foreach ($modulesdir as $dir) { - $modulenames = array(); - - // Load modules attributes in arrays (name, numero, orders) from dir directory - //print $dir."\n
"; - dol_syslog("Scan directory ".$dir." for modules"); - $handle = @opendir($dir); + $modulenames = array(); + + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
"; + dol_syslog("Scan directory ".$dir." for modules"); + $handle = @opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) @@ -395,8 +405,10 @@ { print '
'; print ''; - } else { - print '
'; + } + else + { + print '
'; } print '
'; @@ -408,7 +420,8 @@ try { $nbofrecipient = $obj->getNbOfRecipients(''); - } catch (Exception $e) + } + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -417,7 +430,9 @@ if ($nbofrecipient >= 0) { print $nbofrecipient; - } else { + } + else + { print $langs->trans("Error").' '.img_error($obj->error); } print '
'; @@ -425,14 +440,15 @@ print '
'; if ($allowaddtarget) { - try { - $filter = $obj->formFilter(); - } catch (Exception $e) - { - dol_syslog($e->getMessage(), LOG_ERR); - } - if ($filter) print $filter; - else print $langs->trans("None"); + try { + $filter = $obj->formFilter(); + } + catch (Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } + if ($filter) print $filter; + else print $langs->trans("None"); } print '
'; @@ -440,8 +456,10 @@ if ($allowaddtarget) { print ''; - } else { - print ''; + } + else + { + print ''; //print $langs->trans("MailNoChangePossible"); print " "; } @@ -463,27 +481,11 @@ $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.fk_mailing=".$object->id; - $asearchcriteriahasbeenset = 0; - if ($search_lastname) { - $sql .= natural_search("mc.lastname", $search_lastname); - $asearchcriteriahasbeenset++; - } - if ($search_firstname) { - $sql .= natural_search("mc.firstname", $search_firstname); - $asearchcriteriahasbeenset++; - } - if ($search_email) { - $sql .= natural_search("mc.email", $search_email); - $asearchcriteriahasbeenset++; - } - if ($search_other) { - $sql .= natural_search("mc.other", $search_other); - $asearchcriteriahasbeenset++; - } - if ($search_dest_status != '' && $search_dest_status >= -1) { - $sql .= " AND mc.statut=".$db->escape($search_dest_status)." "; - $asearchcriteriahasbeenset++; - } + if ($search_lastname) $sql .= natural_search("mc.lastname", $search_lastname); + if ($search_firstname) $sql .= natural_search("mc.firstname", $search_firstname); + if ($search_email) $sql .= natural_search("mc.email", $search_email); + if ($search_other) $sql .= natural_search("mc.other", $search_other); + if ($search_dest_status != '' && $search_dest_status >= -1) $sql .= " AND mc.statut=".$db->escape($search_dest_status)." "; $sql .= $db->order($sortfield, $sortorder); // Count total nb of records @@ -492,21 +494,10 @@ { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { $page = 0; $offset = 0; - } - - // Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly) - if (empty($asearchcriteriahasbeenset)) { - if ($nbtotalofrecords != $object->nbemail) { - dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail"); - //print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords; - $resultrefresh = $object->refreshNbOfTargets(); - if ($resultrefresh < 0) { - dol_print_error($db, $object->error, $object->errors); - } - } } } @@ -530,7 +521,7 @@ print ''; print ''; print ''; - print ''; + print ''; print ''; $morehtmlcenter = ''; @@ -548,7 +539,7 @@ print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -638,30 +629,37 @@ print '
'.$obj->firstname.''.$obj->other.''; - if (empty($obj->source_id) || empty($obj->source_type)) - { - print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility - } else { - if ($obj->source_type == 'member') - { + if (empty($obj->source_id) || empty($obj->source_type)) + { + print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility + } + else + { + if ($obj->source_type == 'member') + { $objectstaticmember->fetch($obj->source_id); - print $objectstaticmember->getNomUrl(1); - } elseif ($obj->source_type == 'user') - { + print $objectstaticmember->getNomUrl(1); + } + elseif ($obj->source_type == 'user') + { $objectstaticuser->fetch($obj->source_id); - print $objectstaticuser->getNomUrl(1); - } elseif ($obj->source_type == 'thirdparty') - { + print $objectstaticuser->getNomUrl(1); + } + elseif ($obj->source_type == 'thirdparty') + { $objectstaticcompany->fetch($obj->source_id); - print $objectstaticcompany->getNomUrl(1); - } elseif ($obj->source_type == 'contact') - { - $objectstaticcontact->fetch($obj->source_id); - print $objectstaticcontact->getNomUrl(1); - } else { - print $obj->source_url; - } - } + print $objectstaticcompany->getNomUrl(1); + } + elseif ($obj->source_type == 'contact') + { + $objectstaticcontact->fetch($obj->source_id); + print $objectstaticcontact->getNomUrl(1); + } + else + { + print $obj->source_url; + } + } print ''; print $object::libStatutDest($obj->statut, 2, ''); print ''.$obj->date_envoi.'
'; - print $langs->trans("NoTargetYet"); - print '
'; + print $langs->trans("NoTargetYet"); + print '

"; @@ -718,7 +720,9 @@ print ''; $db->free($resql); - } else { + } + else + { dol_print_error($db); } --- /tmp/dsg/dolibarr/htdocs/comm/mailing/github_index.php +++ /tmp/dsg/dolibarr/htdocs/comm/mailing/client_index.php @@ -57,19 +57,19 @@ //if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo //{ - // Recherche emails - print '
'; - print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - - print "
'.$langs->trans("SearchAMailing").'
'; - print $langs->trans("Ref").':
'; - print $langs->trans("Other").':

\n"; + // Recherche emails + print '
'; + print ''; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "
'.$langs->trans("SearchAMailing").'
'; + print $langs->trans("Ref").':
'; + print $langs->trans("Other").':

\n"; //} @@ -82,63 +82,65 @@ if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) - { - $modulename = $reg[1]; - if ($modulename == 'example') continue; - - // Loading Class - $file = $dir."/".$modulename.".modules.php"; - $classname = "mailing_".$modulename; - require_once $file; - $mailmodule = new $classname($db); - - $qualified = 1; - foreach ($mailmodule->require_module as $key) - { - if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) - { - $qualified = 0; - //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; - break; - } - } - - // Si le module mailing est qualifi� - if ($qualified) - { - foreach ($mailmodule->getSqlArrayForStats() as $sql) - { - print ''; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - - $i = 0; - - while ($i < $num) - { - $obj = $db->fetch_object($result); - print ''.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; - $i++; - } - - $db->free($result); - } else { - dol_print_error($db); - } - print ''; - } - } - } - } - } - closedir($handle); + while (($file = readdir($handle)) !== false) + { + if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) + { + $modulename = $reg[1]; + if ($modulename == 'example') continue; + + // Loading Class + $file = $dir."/".$modulename.".modules.php"; + $classname = "mailing_".$modulename; + require_once $file; + $mailmodule = new $classname($db); + + $qualified = 1; + foreach ($mailmodule->require_module as $key) + { + if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) + { + $qualified = 0; + //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; + break; + } + } + + // Si le module mailing est qualifi� + if ($qualified) + { + foreach ($mailmodule->getSqlArrayForStats() as $sql) + { + print ''; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $i = 0; + + while ($i < $num) + { + $obj = $db->fetch_object($result); + print ''.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; + $i++; + } + + $db->free($result); + } + else + { + dol_print_error($db); + } + print ''; + } + } + } + } + } + closedir($handle); } @@ -160,42 +162,46 @@ $sql .= " LIMIT ".$limit; $result = $db->query($sql); if ($result) { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $num = $db->num_rows($result); - if ($num > 0) - { - $i = 0; - - while ($i < $num) - { - $obj = $db->fetch_object($result); + print '
'; + print '
'.$langs->trans("LastMailings", $limit).''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $num = $db->num_rows($result); + if ($num > 0) + { + $i = 0; + + while ($i < $num) + { + $obj = $db->fetch_object($result); $mailstatic = new Mailing($db); $mailstatic->id = $obj->rowid; $mailstatic->ref = $obj->rowid; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - } else { - print ''; - } - print "
'.$langs->trans("LastMailings", $limit).''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
'.$mailstatic->getNomUrl(1).''.dol_trunc($obj->title, 38).''.dol_print_date($db->jdate($obj->date_creat), 'day').''.($obj->nbemail ? $obj->nbemail : "0").''.$mailstatic->LibStatut($obj->statut, 5).'
'.$langs->trans("None").'

"; - $db->free($result); -} else { - dol_print_error($db); + print ''; + print ''.$mailstatic->getNomUrl(1).''; + print ''.dol_trunc($obj->titre, 38).''; + print ''.dol_print_date($db->jdate($obj->date_creat), 'day').''; + print ''.($obj->nbemail ? $obj->nbemail : "0").''; + print ''.$mailstatic->LibStatut($obj->statut, 5).''; + print ''; + $i++; + } + } + else + { + print ''.$langs->trans("None").''; + } + print "
"; + $db->free($result); +} +else +{ + dol_print_error($db); } @@ -204,12 +210,12 @@ if ($langs->file_exists("html/spam.html", 0)) { - print "



".$langs->trans("Note")."
"; - print '
'; - dol_print_file($langs, "html/spam.html", 0); - print '
'; - - print '
'; + print "



".$langs->trans("Note")."
"; + print '
'; + dol_print_file($langs, "html/spam.html", 0); + print '
'; + + print '
'; } $parameters = array('user' => $user); --- /tmp/dsg/dolibarr/htdocs/comm/mailing/github_info.php +++ /tmp/dsg/dolibarr/htdocs/comm/mailing/client_info.php @@ -52,7 +52,7 @@ { $head = emailing_prepare_head($object); - print dol_get_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email'); + dol_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email'); $linkback = ''.$langs->trans("BackToList").''; @@ -81,7 +81,7 @@ //print ''; - print dol_get_fiche_end(); + dol_fiche_end(); } // End of page --- /tmp/dsg/dolibarr/htdocs/comm/mailing/github_list.php +++ /tmp/dsg/dolibarr/htdocs/comm/mailing/client_list.php @@ -60,7 +60,7 @@ // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'm.titre'=>'Ref', + 'm.titre'=>'Ref', ); @@ -119,8 +119,9 @@ $form = new Form($db); -if ($filteremail) { - $sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,"; +if ($filteremail) +{ + $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,"; $sql .= " mc.statut as sendstatut"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; @@ -129,8 +130,10 @@ if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; if (!$sortorder) $sortorder = "ASC"; if (!$sortfield) $sortfield = "m.rowid"; -} else { - $sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; +} +else +{ + $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql .= " WHERE m.entity = ".$conf->entity; if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; @@ -168,7 +171,7 @@ $newcardbutton = ''; if ($user->rights->mailing->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); } $i = 0; @@ -189,8 +192,8 @@ $moreforfilter = ''; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; print ''; print ''; - // Title - print ''; - + print ''; // Date creation + print ''; @@ -272,7 +274,9 @@ if ($filteremail) { print $email::libStatutDest($obj->sendstatut, 2); - } else { + } + else + { print $email->LibStatut($obj->statut, 5); } print ''; @@ -293,7 +297,9 @@ print ''; $db->free($resql); -} else { +} +else +{ dol_print_error($db); }
'; @@ -237,10 +240,9 @@ print $email->getNomUrl(1); print ''.$obj->title.''.$obj->titre.''; print dol_print_date($db->jdate($obj->datec), 'day'); print '