Merge pull request #15566 from frederic34/mailingcard

remove warnings
This commit is contained in:
Laurent Destailleur 2020-12-27 14:11:04 +01:00 committed by GitHub
commit 56ff2ef010
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 273 additions and 297 deletions

View File

@ -23,7 +23,9 @@
* \brief Fiche mailing, onglet general * \brief Fiche mailing, onglet general
*/ */
if (!defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); if (!defined('NOSTYLECHECK')) {
define('NOSTYLECHECK', '1');
}
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
@ -38,7 +40,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("mails"); $langs->load("mails");
if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) accessforbidden(); 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')); $id = (GETPOST('mailid', 'int') ? GETPOST('mailid', 'int') : GETPOST('id', 'int'));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -83,20 +87,18 @@ $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') if ($action == 'confirm_clone' && $confirm == 'yes') {
{ if (!GETPOST("clone_content", 'alpha') && !GETPOST("clone_receivers", 'alpha')) {
if (!GETPOST("clone_content", 'alpha') && !GETPOST("clone_receivers", 'alpha'))
{
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
} else { } else {
$result = $object->createFromClone($user, $object->id, GETPOST("clone_content", 'alpha'), GETPOST("clone_receivers", 'alpha')); $result = $object->createFromClone($user, $object->id, GETPOST("clone_content", 'alpha'), GETPOST("clone_receivers", 'alpha'));
if ($result > 0) if ($result > 0) {
{
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
exit; exit;
} else { } else {
@ -107,24 +109,20 @@ if (empty($reshook))
} }
// Action send emailing for everybody // Action send emailing for everybody
if ($action == 'sendallconfirmed' && $confirm == 'yes') if ($action == 'sendallconfirmed' && $confirm == 'yes') {
{ if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) {
if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
{
// As security measure, we don't allow send from the GUI // As security measure, we don't allow send from the GUI
setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings');
setEventMessages('<textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', null, 'warnings'); setEventMessages('<textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', null, 'warnings');
setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings');
$action = ''; $action = '';
} elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
{
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings'); setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings');
$action = ''; $action = '';
} else { } else {
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
if ($object->statut == 0) if ($object->statut == 0) {
{
dol_print_error('', 'ErrorMailIsNotValidated'); dol_print_error('', 'ErrorMailIsNotValidated');
exit; exit;
} }
@ -137,7 +135,9 @@ if (empty($reshook))
$errorsto = $object->email_errorsto; $errorsto = $object->email_errorsto;
// Is the message in html // Is the message in html
$msgishtml = -1; // Unknown by default $msgishtml = -1; // Unknown by default
if (preg_match('/[\s\t]*<html>/i', $message)) $msgishtml = 1; if (preg_match('/[\s\t]*<html>/i', $message)) {
$msgishtml = 1;
}
// Warning, we must not use begin-commit transaction here // Warning, we must not use begin-commit transaction here
// because we want to save update for each mail sent. // because we want to save update for each mail sent.
@ -153,12 +153,10 @@ if (empty($reshook))
dol_syslog("card.php: select targets", LOG_DEBUG); dol_syslog("card.php: select targets", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); // Number of possible recipients $num = $db->num_rows($resql); // Number of possible recipients
if ($num) if ($num) {
{
dol_syslog("comm/mailing/card.php: nb of targets = ".$num, LOG_DEBUG); dol_syslog("comm/mailing/card.php: nb of targets = ".$num, LOG_DEBUG);
$now = dol_now(); $now = dol_now();
@ -166,16 +164,14 @@ if (empty($reshook))
// Positioning date of start sending // Positioning date of start sending
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$object->id; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$object->id;
$resql2 = $db->query($sql); $resql2 = $db->query($sql);
if (!$resql2) if (!$resql2) {
{
dol_print_error($db); dol_print_error($db);
} }
// Loop on each email and send it // Loop on each email and send it
$i = 0; $i = 0;
while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) {
{
// Here code is common with same loop ino mailing-send.php // Here code is common with same loop ino mailing-send.php
$res = 1; $res = 1;
$now = dol_now(); $now = dol_now();
@ -215,14 +211,18 @@ if (empty($reshook))
$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>'; $substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
$onlinepaymentenabled = 0; $onlinepaymentenabled = 0;
if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++; if (!empty($conf->paypal->enabled)) {
if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++; $onlinepaymentenabled++;
if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++; }
if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) if (!empty($conf->paybox->enabled)) {
{ $onlinepaymentenabled++;
}
if (!empty($conf->stripe->enabled)) {
$onlinepaymentenabled++;
}
if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
$substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
{
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
$substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
$substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
@ -235,21 +235,32 @@ if (empty($reshook))
} }
} }
/* For backward compatibility, deprecated */ /* For backward compatibility, deprecated */
if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) {
{
$substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
} else {
$substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2);
}
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
else $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'order'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
} else {
$substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'order'.$obj->source_id, 2);
}
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
} else {
$substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'invoice'.$obj->source_id, 2);
}
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'contractline'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
} else {
$substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'contractline'.$obj->source_id, 2);
}
} }
//$substitutionisok=true; //$substitutionisok=true;
@ -263,10 +274,8 @@ if (empty($reshook))
$arr_css = array(); $arr_css = array();
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
if (count($listofpaths)) if (count($listofpaths)) {
{ foreach ($listofpaths as $key => $val) {
foreach ($listofpaths as $key => $val)
{
$arr_file[] = $listofpaths[$key]['fullname']; $arr_file[] = $listofpaths[$key]['fullname'];
$arr_mime[] = dol_mimetype($listofpaths[$key]['name']); $arr_mime[] = dol_mimetype($listofpaths[$key]['name']);
$arr_name[] = $listofpaths[$key]['name']; $arr_name[] = $listofpaths[$key]['name'];
@ -277,8 +286,7 @@ if (empty($reshook))
$trackid = 'emailing-'.$obj->fk_mailing.'-'.$obj->rowid; $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'); $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, '', 'emailing');
if ($mail->error) if ($mail->error) {
{
$res = 0; $res = 0;
} }
/*if (! $substitutionisok) /*if (! $substitutionisok)
@ -288,13 +296,11 @@ if (empty($reshook))
}*/ }*/
// Send mail // Send mail
if ($res) if ($res) {
{
$res = $mail->sendfile(); $res = $mail->sendfile();
} }
if ($res) if ($res) {
{
// Mail successful // Mail successful
$nbok++; $nbok++;
@ -303,19 +309,16 @@ if (empty($reshook))
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; $sql .= " SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid;
$resql2 = $db->query($sql); $resql2 = $db->query($sql);
if (!$resql2) if (!$resql2) {
{
dol_print_error($db); dol_print_error($db);
} else { } else {
//if cheack read is use then update prospect contact status //if cheack read is use then update prospect contact status
if (strpos($message, '__CHECK_READ__') !== false) if (strpos($message, '__CHECK_READ__') !== false) {
{
//Update status communication of thirdparty prospect //Update status communication of thirdparty prospect
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")"; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")";
dol_syslog("card.php: set prospect thirdparty status", LOG_DEBUG); dol_syslog("card.php: set prospect thirdparty status", LOG_DEBUG);
$resql2 = $db->query($sql); $resql2 = $db->query($sql);
if (!$resql2) if (!$resql2) {
{
dol_print_error($db); dol_print_error($db);
} }
@ -324,8 +327,7 @@ if (empty($reshook))
dol_syslog("card.php: set prospect contact status", LOG_DEBUG); dol_syslog("card.php: set prospect contact status", LOG_DEBUG);
$resql2 = $db->query($sql); $resql2 = $db->query($sql);
if (!$resql2) if (!$resql2) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
@ -346,8 +348,7 @@ if (empty($reshook))
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; $sql .= " SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid;
$resql2 = $db->query($sql); $resql2 = $db->query($sql);
if (!$resql2) if (!$resql2) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
@ -359,14 +360,15 @@ if (empty($reshook))
} }
// Loop finished, set global statut of mail // Loop finished, set global statut of mail
if ($nbko > 0) if ($nbko > 0) {
{
$statut = 2; // Status 'sent partially' (because at least one error) $statut = 2; // Status 'sent partially' (because at least one error)
if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); if ($nbok > 0) {
else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs');
} else { } else {
if ($nbok >= $num) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs');
{ }
} else {
if ($nbok >= $num) {
$statut = 3; // Send to everybody $statut = 3; // Send to everybody
setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs');
} else { } else {
@ -378,8 +380,7 @@ if (empty($reshook))
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id;
dol_syslog("comm/mailing/card.php: update global status", LOG_DEBUG); dol_syslog("comm/mailing/card.php: update global status", LOG_DEBUG);
$resql2 = $db->query($sql); $resql2 = $db->query($sql);
if (!$resql2) if (!$resql2) {
{
dol_print_error($db); dol_print_error($db);
} }
} else { } else {
@ -392,24 +393,23 @@ if (empty($reshook))
} }
// Action send test emailing // Action send test emailing
if ($action == 'send' && empty($_POST["cancel"])) if ($action == 'send' && empty($_POST["cancel"])) {
{
$error = 0; $error = 0;
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
$object->sendto = $_POST["sendto"]; $object->sendto = $_POST["sendto"];
if (!$object->sendto) if (!$object->sendto) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTo")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTo")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{
// Is the message in html // Is the message in html
$msgishtml = -1; // Unknow by default $msgishtml = -1; // Unknow by default
if (preg_match('/[\s\t]*<html>/i', $object->body)) $msgishtml = 1; if (preg_match('/[\s\t]*<html>/i', $object->body)) {
$msgishtml = 1;
}
// other are set at begin of page // other are set at begin of page
$object->substitutionarrayfortest['__EMAIL__'] = $object->sendto; $object->substitutionarrayfortest['__EMAIL__'] = $object->sendto;
@ -426,15 +426,17 @@ if (empty($reshook))
$arr_css = array(); $arr_css = array();
// Add CSS // Add CSS
if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; if (!empty($object->bgcolor)) {
if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor;
}
if (!empty($object->bgimage)) {
$arr_css['bgimage'] = $object->bgimage;
}
// Attached files // Attached files
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
if (count($listofpaths)) if (count($listofpaths)) {
{ foreach ($listofpaths as $key => $val) {
foreach ($listofpaths as $key => $val)
{
$arr_file[] = $listofpaths[$key]['fullname']; $arr_file[] = $listofpaths[$key]['fullname'];
$arr_mime[] = dol_mimetype($listofpaths[$key]['name']); $arr_mime[] = dol_mimetype($listofpaths[$key]['name']);
$arr_name[] = $listofpaths[$key]['name']; $arr_name[] = $listofpaths[$key]['name'];
@ -445,8 +447,7 @@ if (empty($reshook))
$mailfile = new CMailFile($tmpsujet, $object->sendto, $object->email_from, $tmpbody, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $object->email_errorsto, $arr_css, $trackid, '', 'emailing'); $mailfile = new CMailFile($tmpsujet, $object->sendto, $object->email_from, $tmpbody, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $object->email_errorsto, $arr_css, $trackid, '', 'emailing');
$result = $mailfile->sendfile(); $result = $mailfile->sendfile();
if ($result) if ($result) {
{
setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs'); setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs');
$action = ''; $action = '';
} else { } else {
@ -457,18 +458,17 @@ if (empty($reshook))
} }
// Action add emailing // Action add emailing
if ($action == 'add') if ($action == 'add') {
{
$mesgs = array(); $mesgs = array();
$object->email_from = GETPOST("from", "none"); // Must allow 'name <email>' $object->email_from = (string) GETPOST("from", "none"); // Must allow 'name <email>'
$object->email_replyto = GETPOST("replyto", "none"); // Must allow 'name <email>' $object->email_replyto = (string) GETPOST("replyto", "none"); // Must allow 'name <email>'
$object->email_errorsto = GETPOST("errorsto", "none"); // Must allow 'name <email>' $object->email_errorsto = (string) GETPOST("errorsto", "none"); // Must allow 'name <email>'
$object->title = GETPOST("title"); $object->title = (string) GETPOST("title");
$object->sujet = GETPOST("sujet"); $object->sujet = (string) GETPOST("sujet");
$object->body = GETPOST("bodyemail", 'restricthtml'); $object->body = (string) GETPOST("bodyemail", 'restricthtml');
$object->bgcolor = GETPOST("bgcolor"); $object->bgcolor = (string) GETPOST("bgcolor");
$object->bgimage = GETPOST("bgimage"); $object->bgimage = (string) GETPOST("bgimage");
if (!$object->title) { if (!$object->title) {
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
@ -480,10 +480,8 @@ if (empty($reshook))
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage")); $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage"));
} }
if (!count($mesgs)) if (!count($mesgs)) {
{ if ($object->create($user) >= 0) {
if ($object->create($user) >= 0)
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
@ -495,24 +493,25 @@ if (empty($reshook))
} }
// Action update description of emailing // Action update description of emailing
if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') {
{
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
if ($action == 'settitle') $object->title = trim(GETPOST('title', 'alpha')); if ($action == 'settitle') {
elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name <email>' $object->title = trim(GETPOST('title', 'alpha'));
elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name <email>' } elseif ($action == 'setemail_from') {
elseif ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name <email>' $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name <email>'
elseif ($action == 'settitle' && empty($object->title)) { } elseif ($action == 'setemail_replyto') {
$object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name <email>'
} elseif ($action == 'setemail_errorsto') {
$object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name <email>'
} elseif ($action == 'settitle' && empty($object->title)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
} elseif ($action == 'setfrom' && empty($object->email_from)) { } elseif ($action == 'setfrom' && empty($object->email_from)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom"));
} }
if (!$mesg) if (!$mesg) {
{ if ($object->update($user) >= 0) {
if ($object->update($user) >= 0)
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
@ -526,8 +525,7 @@ if (empty($reshook))
/* /*
* Add file in email form * Add file in email form
*/ */
if (!empty($_POST['addfile'])) if (!empty($_POST['addfile'])) {
{
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $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'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -539,8 +537,7 @@ if (empty($reshook))
} }
// Action of file remove // Action of file remove
if (!empty($_POST["removedfile"])) if (!empty($_POST["removedfile"])) {
{
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $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'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -551,20 +548,18 @@ if (empty($reshook))
} }
// Action of emailing update // Action of emailing update
if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) {
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$isupload = 0; $isupload = 0;
if (!$isupload) if (!$isupload) {
{
$mesgs = array(); $mesgs = array();
$object->sujet = GETPOST("sujet"); $object->sujet = (string) GETPOST("sujet");
$object->body = GETPOST("bodyemail", 'restricthtml'); $object->body = (string) GETPOST("bodyemail", 'restricthtml');
$object->bgcolor = GETPOST("bgcolor"); $object->bgcolor = (string) GETPOST("bgcolor");
$object->bgimage = GETPOST("bgimage"); $object->bgimage = (string) GETPOST("bgimage");
if (!$object->sujet) { if (!$object->sujet) {
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic")); $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic"));
@ -573,10 +568,8 @@ if (empty($reshook))
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage")); $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage"));
} }
if (!count($mesgs)) if (!count($mesgs)) {
{ if ($object->update($user) >= 0) {
if ($object->update($user) >= 0)
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
@ -591,10 +584,8 @@ if (empty($reshook))
} }
// Action of validation confirmation // Action of validation confirmation
if ($action == 'confirm_valid' && $confirm == 'yes') if ($action == 'confirm_valid' && $confirm == 'yes') {
{ if ($object->id > 0) {
if ($object->id > 0)
{
$object->valid($user); $object->valid($user);
setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@ -605,13 +596,10 @@ if (empty($reshook))
} }
// Action of validation confirmation // Action of validation confirmation
if ($action == 'confirm_settodraft' && $confirm == 'yes') if ($action == 'confirm_settodraft' && $confirm == 'yes') {
{ if ($object->id > 0) {
if ($object->id > 0)
{
$result = $object->setStatut(0); $result = $object->setStatut(0);
if ($result > 0) if ($result > 0) {
{
//setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
@ -624,20 +612,16 @@ if (empty($reshook))
} }
// Resend // Resend
if ($action == 'confirm_reset' && $confirm == 'yes') if ($action == 'confirm_reset' && $confirm == 'yes') {
{ if ($object->id > 0) {
if ($object->id > 0)
{
$db->begin(); $db->begin();
$result = $object->valid($user); $result = $object->valid($user);
if ($result > 0) if ($result > 0) {
{
$result = $object->reset_targets_status($user); $result = $object->reset_targets_status($user);
} }
if ($result > 0) if ($result > 0) {
{
$db->commit(); $db->commit();
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
@ -651,18 +635,15 @@ if (empty($reshook))
} }
// Action of delete confirmation // Action of delete confirmation
if ($action == 'confirm_delete' && $confirm == 'yes') if ($action == 'confirm_delete' && $confirm == 'yes') {
{ if ($object->delete($object->id)) {
if ($object->delete($object->id))
{
$url = (!empty($urlfrom) ? $urlfrom : 'list.php'); $url = (!empty($urlfrom) ? $urlfrom : 'list.php');
header("Location: ".$url); header("Location: ".$url);
exit; exit;
} }
} }
if (!empty($_POST["cancel"])) if (!empty($_POST["cancel"])) {
{
$action = ''; $action = '';
} }
} }
@ -676,24 +657,30 @@ $form = new Form($db);
$htmlother = new FormOther($db); $htmlother = new FormOther($db);
$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing'; $help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
llxHeader('', $langs->trans("Mailing"), $help_url, '', 0, 0, llxHeader(
'',
$langs->trans("Mailing"),
$help_url,
'',
0,
0,
array( array(
'/includes/ace/src/ace.js', '/includes/ace/src/ace.js',
'/includes/ace/src/ext-statusbar.js', '/includes/ace/src/ext-statusbar.js',
'/includes/ace/src/ext-language_tools.js', '/includes/ace/src/ext-language_tools.js',
//'/includes/ace/src/ext-chromevox.js' //'/includes/ace/src/ext-chromevox.js'
), array()); ),
array()
);
if ($action == 'create') if ($action == 'create') {
{
// EMailing in creation mode // EMailing in creation mode
print '<form name="new_mailing" action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n"; print '<form name="new_mailing" action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>'; $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach ($object->substitutionarray as $key => $val) foreach ($object->substitutionarray as $key => $val) {
{
$htmltext .= $key.' = '.$langs->trans($val).'<br>'; $htmltext .= $key.' = '.$langs->trans($val).'<br>';
} }
$htmltext .= '</i>'; $htmltext .= '</i>';
@ -717,8 +704,7 @@ if ($action == 'create')
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $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)) if (empty($reshook)) {
{
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
} }
@ -746,78 +732,80 @@ if ($action == 'create')
print '</form>'; print '</form>';
} else { } else {
if ($object->id > 0) if ($object->id > 0) {
{
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
$head = emailing_prepare_head($object); $head = emailing_prepare_head($object);
if ($action == 'settodraft') {
// Confirmation back to draft // Confirmation back to draft
if ($action == 'settodraft')
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("SetToDraft"), $langs->trans("ConfirmUnvalidateEmailing"), "confirm_settodraft", '', '', 1); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("SetToDraft"), $langs->trans("ConfirmUnvalidateEmailing"), "confirm_settodraft", '', '', 1);
} } elseif ($action == 'valid') {
// Confirmation of mailing validation // Confirmation of mailing validation
if ($action == 'valid')
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ValidMailing"), $langs->trans("ConfirmValidMailing"), "confirm_valid", '', '', 1); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ValidMailing"), $langs->trans("ConfirmValidMailing"), "confirm_valid", '', '', 1);
} // Confirm reset } elseif ($action == 'reset') {
elseif ($action == 'reset') // Confirm reset
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ResetMailing"), $langs->trans("ConfirmResetMailing", $object->ref), "confirm_reset", '', '', 2); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ResetMailing"), $langs->trans("ConfirmResetMailing", $object->ref), "confirm_reset", '', '', 2);
} // Confirm delete } elseif ($action == 'delete') {
elseif ($action == 'delete') // Confirm delete
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1);
} }
if ($action != 'edit' && $action != 'edithtml') {
if ($action != 'edit' && $action != 'edithtml')
{
print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email');
/* /*
* View mode mailing * View mode mailing
*/ */
if ($action == 'sendall') if ($action == 'sendall') {
{
// Define message to recommand from command line // Define message to recommand from command line
$sendingmode = $conf->global->EMAILING_MAIL_SENDMODE; $sendingmode = $conf->global->EMAILING_MAIL_SENDMODE;
if (empty($sendingmode)) $sendingmode = $conf->global->MAIN_MAIL_SENDMODE; if (empty($sendingmode)) {
if (empty($sendingmode)) $sendingmode = 'mail'; // If not defined, we use php mail function $sendingmode = $conf->global->MAIN_MAIL_SENDMODE;
}
if (empty($sendingmode)) {
$sendingmode = 'mail'; // If not defined, we use php mail function
}
// MAILING_NO_USING_PHPMAIL may be defined or not. // MAILING_NO_USING_PHPMAIL may be defined or not.
// MAILING_LIMIT_SENDBYWEB is always defined to something != 0 (-1=forbidden). // MAILING_LIMIT_SENDBYWEB is always defined to something != 0 (-1=forbidden).
// MAILING_LIMIT_SENDBYCLI may be defined ot not (-1=forbidden, 0 or undefined=no limit). // MAILING_LIMIT_SENDBYCLI may be defined ot not (-1=forbidden, 0 or undefined=no limit).
if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') {
{
// EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent. // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
// You ensure that every user is using its own SMTP server when using the mass emailing module. // You ensure that every user is using its own SMTP server when using the mass emailing module.
$linktoadminemailbefore = '<a href="'.DOL_URL_ROOT.'/admin/mails_emailing.php">'; $linktoadminemailbefore = '<a href="'.DOL_URL_ROOT.'/admin/mails_emailing.php">';
$linktoadminemailend = '</a>'; $linktoadminemailend = '</a>';
setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, 'warnings'); setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, 'warnings');
setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings'); 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'); 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"] = ''; $_GET["action"] = '';
} elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { } 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_PHPMAIL) && $sendingmode == 'mail') {
if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); 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. // 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('<textarea cols="60" rows="'.ROWS_1.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', null, 'warnings'); setEventMessages('<textarea cols="60" rows="'.ROWS_1.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', 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. 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"] = ''; $_GET["action"] = '';
} else { } 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_PHPMAIL) && $sendingmode == 'mail') {
if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); 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 = ''; $text = '';
if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) {
{
$text .= $langs->trans("MailingNeedCommand"); $text .= $langs->trans("MailingNeedCommand");
$text .= '<br><textarea cols="60" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.' '.$user->login.'</textarea>'; $text .= '<br><textarea cols="60" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.' '.$user->login.'</textarea>';
$text .= '<br><br>'; $text .= '<br><br>';
@ -832,13 +820,14 @@ if ($action == 'create')
$morehtmlright = ''; $morehtmlright = '';
$nbtry = $nbok = 0; $nbtry = $nbok = 0;
if ($object->statut == 2 || $object->statut == 3) if ($object->statut == 2 || $object->statut == 3) {
{
$nbtry = $object->countNbOfTargets('alreadysent'); $nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko'); $nbko = $object->countNbOfTargets('alreadysentko');
$morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail;
if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); if ($nbko) {
$morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
}
$morehtmlright .= ') &nbsp; '; $morehtmlright .= ') &nbsp; ';
} }
@ -892,21 +881,19 @@ if ($action == 'create')
print $langs->trans("TotalNbOfDistinctRecipients"); print $langs->trans("TotalNbOfDistinctRecipients");
print '</td><td colspan="3">'; print '</td><td colspan="3">';
$nbemail = ($object->nbemail ? $object->nbemail : 0); $nbemail = ($object->nbemail ? $object->nbemail : 0);
if (is_numeric($nbemail)) if (is_numeric($nbemail)) {
{
$text = ''; $text = '';
if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) 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) {
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
{
$text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
} else { } else {
$text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
} }
} }
if (empty($nbemail)) $nbemail .= ' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>'; if (empty($nbemail)) {
if ($text) $nbemail .= ' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>';
{ }
if ($text) {
print $form->textwithpicto($nbemail, $text, 1, 'warning'); print $form->textwithpicto($nbemail, $text, 1, 'warning');
} else { } else {
print $nbemail; print $nbemail;
@ -925,8 +912,7 @@ if ($action == 'create')
// Clone confirmation // Clone confirmation
if ($action == 'clone') if ($action == 'clone') {
{
// Create an array for form // Create an array for form
$formquestion = array( $formquestion = array(
'text' => $langs->trans("ConfirmClone"), 'text' => $langs->trans("ConfirmClone"),
@ -941,81 +927,67 @@ if ($action == 'create')
* Actions Buttons * Actions Buttons
*/ */
if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) {
{
print "\n\n<div class=\"tabsAction\">\n"; print "\n\n<div class=\"tabsAction\">\n";
if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id)) if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id)) {
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=settodraft&amp;id='.$object->id.'">'.$langs->trans("SetToDraft").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=settodraft&amp;id='.$object->id.'">'.$langs->trans("SetToDraft").'</a>';
} }
if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->rights->mailing->creer) if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->rights->mailing->creer) {
{ if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) {
if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING))
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("EditWithEditor").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("EditWithEditor").'</a>';
} else { } else {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("EditWithTextEditor").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("EditWithTextEditor").'</a>';
} }
if (!empty($conf->use_javascript_ajax)) print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edithtml&amp;id='.$object->id.'">'.$langs->trans("EditHTMLSource").'</a>'; if (!empty($conf->use_javascript_ajax)) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edithtml&amp;id='.$object->id.'">'.$langs->trans("EditHTMLSource").'</a>';
}
} }
//print '<a class="butAction" href="card.php?action=test&amp;id='.$object->id.'">'.$langs->trans("PreviewMailing").'</a>'; //print '<a class="butAction" href="card.php?action=test&amp;id='.$object->id.'">'.$langs->trans("PreviewMailing").'</a>';
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("TestMailing").'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("TestMailing").'</a>';
} else { } else {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=test&amp;id='.$object->id.'">'.$langs->trans("TestMailing").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=test&amp;id='.$object->id.'">'.$langs->trans("TestMailing").'</a>';
} }
if ($object->statut == 0) if ($object->statut == 0) {
{ if ($object->nbemail <= 0) {
if ($object->nbemail <= 0)
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoTargetYet")).'">'.$langs->trans("ValidMailing").'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoTargetYet")).'">'.$langs->trans("ValidMailing").'</a>';
} elseif (empty($user->rights->mailing->valider)) } elseif (empty($user->rights->mailing->valider)) {
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("ValidMailing").'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("ValidMailing").'</a>';
} else { } else {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=valid&amp;id='.$object->id.'">'.$langs->trans("ValidMailing").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=valid&amp;id='.$object->id.'">'.$langs->trans("ValidMailing").'</a>';
} }
} }
if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider) if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider) {
{ if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("SendingFromWebInterfaceIsNotAllowed")).'">'.$langs->trans("SendMailing").'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("SendingFromWebInterfaceIsNotAllowed")).'">'.$langs->trans("SendMailing").'</a>';
} 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 '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("SendMailing").'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("SendMailing").'</a>';
} else { } else {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=sendall&amp;id='.$object->id.'">'.$langs->trans("SendMailing").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=sendall&amp;id='.$object->id.'">'.$langs->trans("SendMailing").'</a>';
} }
} }
if ($user->rights->mailing->creer) if ($user->rights->mailing->creer) {
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=clone&amp;object=emailing&amp;id='.$object->id.'">'.$langs->trans("ToClone").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=clone&amp;object=emailing&amp;id='.$object->id.'">'.$langs->trans("ToClone").'</a>';
} }
if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider) if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider) {
{ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send)
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("ResetMailing").'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("ResetMailing").'</a>';
} else { } else {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=reset&amp;id='.$object->id.'">'.$langs->trans("ResetMailing").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=reset&amp;id='.$object->id.'">'.$langs->trans("ResetMailing").'</a>';
} }
} }
if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer) if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer) {
{ if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) {
if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete))
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("DeleteMailing").'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("DeleteMailing").'</a>';
} else { } else {
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;token='.newToken().'&amp;id='.$object->id.(!empty($urlfrom) ? '&urlfrom='.$urlfrom : '').'">'.$langs->trans("DeleteMailing").'</a>'; print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;token='.newToken().'&amp;id='.$object->id.(!empty($urlfrom) ? '&urlfrom='.$urlfrom : '').'">'.$langs->trans("DeleteMailing").'</a>';
@ -1026,8 +998,7 @@ if ($action == 'create')
} }
// Display of the TEST form // Display of the TEST form
if ($action == 'test') if ($action == 'test') {
{
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>'; print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print load_fiche_titre($langs->trans("TestMailing")); print load_fiche_titre($langs->trans("TestMailing"));
@ -1069,8 +1040,7 @@ if ($action == 'create')
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>'; $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach ($object->substitutionarray as $key => $val) foreach ($object->substitutionarray as $key => $val) {
{
$htmltext .= $key.' = '.$langs->trans($val).'<br>'; $htmltext .= $key.' = '.$langs->trans($val).'<br>';
} }
$htmltext .= '</i>'; $htmltext .= '</i>';
@ -1089,10 +1059,8 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans("MailFile").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("MailFile").'</td><td colspan="3">';
// List of files // List of files
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
if (count($listofpaths)) if (count($listofpaths)) {
{ foreach ($listofpaths as $key => $val) {
foreach ($listofpaths as $key => $val)
{
print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name'];
print '<br>'; print '<br>';
} }
@ -1110,14 +1078,15 @@ if ($action == 'create')
// Message // Message
print '<div style="padding-top: 10px; background: '.($object->bgcolor ? (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor : 'white').'">'; print '<div style="padding-top: 10px; background: '.($object->bgcolor ? (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor : 'white').'">';
if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') // CKEditor does not apply the color of the div into its content area if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') { // CKEditor does not apply the color of the div into its content area
{
$readonly = 1; $readonly = 1;
// wysiwyg editor // wysiwyg editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; 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 = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20, '90%', $readonly);
$doleditor->Create(); $doleditor->Create();
} else print dol_htmlentitiesbr($object->body); } else {
print dol_htmlentitiesbr($object->body);
}
print '</div>'; print '</div>';
print dol_get_fiche_end(); print dol_get_fiche_end();
@ -1131,7 +1100,9 @@ if ($action == 'create')
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlright = ''; $morehtmlright = '';
if ($object->statut == 2) $morehtmlright .= ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; if ($object->statut == 2) {
$morehtmlright .= ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') ';
}
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
@ -1159,21 +1130,19 @@ if ($action == 'create')
print $langs->trans("TotalNbOfDistinctRecipients"); print $langs->trans("TotalNbOfDistinctRecipients");
print '</td><td colspan="3">'; print '</td><td colspan="3">';
$nbemail = ($object->nbemail ? $object->nbemail : 0); $nbemail = ($object->nbemail ? $object->nbemail : 0);
if (is_numeric($nbemail)) if (is_numeric($nbemail)) {
{
$text = ''; $text = '';
if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) {
{ if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
{
$text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
} else { } else {
$text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
} }
} }
if (empty($nbemail)) $nbemail .= ' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>'; if (empty($nbemail)) {
if ($text) $nbemail .= ' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>';
{ }
if ($text) {
print $form->textwithpicto($nbemail, $text, 1, 'warning'); print $form->textwithpicto($nbemail, $text, 1, 'warning');
} else { } else {
print $nbemail; print $nbemail;
@ -1185,8 +1154,7 @@ if ($action == 'create')
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $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)) if (empty($reshook)) {
{
print $object->showOptionals($extrafields, 'edit', $parameters); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
@ -1205,8 +1173,7 @@ if ($action == 'create')
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>'; $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach ($object->substitutionarray as $key => $val) foreach ($object->substitutionarray as $key => $val) {
{
$htmltext .= $key.' = '.$langs->trans($val).'<br>'; $htmltext .= $key.' = '.$langs->trans($val).'<br>';
} }
$htmltext .= '</i>'; $htmltext .= '</i>';
@ -1240,10 +1207,8 @@ if ($action == 'create')
$out .= ' });'; $out .= ' });';
$out .= '})'; $out .= '})';
$out .= '</script>'."\n"; $out .= '</script>'."\n";
if (count($listofpaths)) if (count($listofpaths)) {
{ foreach ($listofpaths as $key => $val) {
foreach ($listofpaths as $key => $val)
{
$out .= '<div id="attachfile_'.$key.'">'; $out .= '<div id="attachfile_'.$key.'">';
$out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; $out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name'];
$out .= ' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans("Search"), 'delete.png', '', '', 1).'" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />'; $out .= ' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans("Search"), 'delete.png', '', '', 1).'" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
@ -1269,15 +1234,13 @@ if ($action == 'create')
// Message // Message
print '<div style="padding-top: 10px">'; print '<div style="padding-top: 10px">';
if ($action == 'edit') if ($action == 'edit') {
{
// wysiwyg editor // wysiwyg editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; 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 = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%');
$doleditor->Create(); $doleditor->Create();
} }
if ($action == 'edithtml') if ($action == 'edithtml') {
{
// HTML source editor // HTML source editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; 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 = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, 'ace', 20, '90%');

View File

@ -118,36 +118,48 @@ class Mailing extends CommonObject
/** /**
* @var int id of user create * @var int id of user create
* @deprecated
*/ */
public $user_creation; public $user_creation;
/** /**
* @var int id of user create * @var int id of user create
* @deprecated
*/ */
public $user_creat; public $user_creat;
/** /**
* @var int id of user validate * @var int id of user validate
* @deprecated
*/ */
public $user_validation; public $user_validation;
/** /**
* @var int id of user validate * @var int id of user validate
* @deprecated
*/ */
public $user_valid; public $user_valid;
/** /**
* @var integer|string date_creation * @var integer|string date_creation
* @deprecated
*/ */
public $date_creat; public $date_creat;
/**
* @var integer|string date_creation
*/
public $date_creation;
/** /**
* @var int date validate * @var int date validate
* @deprecated
*/ */
public $date_valid; public $date_valid;
/**
* @var int date validate
*/
public $date_validation;
/** /**
* @var array extraparams * @var array extraparams
*/ */
@ -314,10 +326,14 @@ class Mailing extends CommonObject
$this->email_errorsto = $obj->email_errorsto; $this->email_errorsto = $obj->email_errorsto;
$this->user_creat = $obj->fk_user_creat; $this->user_creat = $obj->fk_user_creat;
$this->user_creation = $obj->fk_user_creat;
$this->user_valid = $obj->fk_user_valid; $this->user_valid = $obj->fk_user_valid;
$this->user_validation = $obj->fk_user_valid;
$this->date_creat = $this->db->jdate($obj->date_creat); $this->date_creat = $this->db->jdate($obj->date_creat);
$this->date_creation = $this->db->jdate($obj->date_creat);
$this->date_valid = $this->db->jdate($obj->date_valid); $this->date_valid = $this->db->jdate($obj->date_valid);
$this->date_validation = $this->db->jdate($obj->date_valid);
$this->date_envoi = $this->db->jdate($obj->date_envoi); $this->date_envoi = $this->db->jdate($obj->date_envoi);
$this->extraparams = (array) json_decode($obj->extraparams, true); $this->extraparams = (array) json_decode($obj->extraparams, true);

View File

@ -33,8 +33,9 @@ $id = GETPOST('id', 'int');
$langs->load("mails"); $langs->load("mails");
// Security check // Security check
if (!$user->rights->mailing->lire || $user->socid > 0) if (!$user->rights->mailing->lire || $user->socid > 0) {
accessforbidden(); accessforbidden();
}
@ -48,8 +49,7 @@ $form = new Form($db);
$object = new Mailing($db); $object = new Mailing($db);
if ($object->fetch($id) >= 0) if ($object->fetch($id) >= 0) {
{
$head = emailing_prepare_head($object); $head = emailing_prepare_head($object);
print dol_get_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email'); print dol_get_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email');
@ -58,13 +58,14 @@ if ($object->fetch($id) >= 0)
$morehtmlright = ''; $morehtmlright = '';
$nbtry = $nbok = 0; $nbtry = $nbok = 0;
if ($object->statut == 2 || $object->statut == 3) if ($object->statut == 2 || $object->statut == 3) {
{
$nbtry = $object->countNbOfTargets('alreadysent'); $nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko'); $nbko = $object->countNbOfTargets('alreadysentko');
$morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail;
if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); if ($nbko) {
$morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
}
$morehtmlright .= ') &nbsp; '; $morehtmlright .= ') &nbsp; ';
} }
@ -73,10 +74,6 @@ if ($object->fetch($id) >= 0)
print '<div class="underbanner clearboth"></div><br>'; print '<div class="underbanner clearboth"></div><br>';
//print '<table width="100%"><tr><td>'; //print '<table width="100%"><tr><td>';
$object->user_creation = $object->user_creat;
$object->date_creation = $object->date_creat;
$object->user_validation = $object->user_valid;
$object->date_validation = $object->date_valid;
dol_print_object_info($object, 0); dol_print_object_info($object, 0);
//print '</td></tr></table>'; //print '</td></tr></table>';