only update last_msg_date if a message is really sent.
This commit is contained in:
parent
26648e4f12
commit
b6b5eb633b
@ -280,9 +280,11 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|||||||
dol_syslog($mailfile->error, LOG_DEBUG);
|
dol_syslog($mailfile->error, LOG_DEBUG);
|
||||||
} else {
|
} else {
|
||||||
$result = $mailfile->sendfile();
|
$result = $mailfile->sendfile();
|
||||||
// update last_msg_sent date
|
if ($result) {
|
||||||
$object->date_last_msg_sent = dol_now();
|
// update last_msg_sent date
|
||||||
$object->update($user);
|
$object->date_last_msg_sent = dol_now();
|
||||||
|
$object->update($user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
||||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
||||||
|
|||||||
@ -2756,13 +2756,14 @@ class Ticket extends CommonObject
|
|||||||
|
|
||||||
// altairis: dont try to send email when no recipient
|
// altairis: dont try to send email when no recipient
|
||||||
if (!empty($sendto)) {
|
if (!empty($sendto)) {
|
||||||
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
|
$result = $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
|
||||||
|
if ($result) {
|
||||||
|
// update last_msg_sent date
|
||||||
|
$object->date_last_msg_sent = dol_now();
|
||||||
|
$object->update($user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update last_msg_sent date
|
|
||||||
$object->date_last_msg_sent = dol_now();
|
|
||||||
$object->update($user);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2793,7 +2794,7 @@ class Ticket extends CommonObject
|
|||||||
* @param array $filename_list List of files to attach (full path of filename on file system)
|
* @param array $filename_list List of files to attach (full path of filename on file system)
|
||||||
* @param array $mimetype_list List of MIME type of attached files
|
* @param array $mimetype_list List of MIME type of attached files
|
||||||
* @param array $mimefilename_list List of attached file name in message
|
* @param array $mimefilename_list List of attached file name in message
|
||||||
* @return void
|
* @return boolean True if mail sent to at least one receiver, false otherwise
|
||||||
*/
|
*/
|
||||||
public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
|
public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
|
||||||
{
|
{
|
||||||
@ -2801,7 +2802,7 @@ class Ticket extends CommonObject
|
|||||||
|
|
||||||
if ($conf->global->TICKET_DISABLE_ALL_MAILS) {
|
if ($conf->global->TICKET_DISABLE_ALL_MAILS) {
|
||||||
dol_syslog(get_class($this).'::sendTicketMessageByEmail: Emails are disable into ticket setup by option TICKET_DISABLE_ALL_MAILS', LOG_WARNING);
|
dol_syslog(get_class($this).'::sendTicketMessageByEmail: Emails are disable into ticket setup by option TICKET_DISABLE_ALL_MAILS', LOG_WARNING);
|
||||||
return '';
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$langs->load("mails");
|
$langs->load("mails");
|
||||||
@ -2820,6 +2821,7 @@ class Ticket extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM;
|
$from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM;
|
||||||
|
$is_sent = false;
|
||||||
if (is_array($array_receiver) && count($array_receiver) > 0) {
|
if (is_array($array_receiver) && count($array_receiver) > 0) {
|
||||||
foreach ($array_receiver as $key => $receiver) {
|
foreach ($array_receiver as $key => $receiver) {
|
||||||
$deliveryreceipt = 0;
|
$deliveryreceipt = 0;
|
||||||
@ -2841,6 +2843,7 @@ class Ticket extends CommonObject
|
|||||||
$result = $mailfile->sendfile();
|
$result = $mailfile->sendfile();
|
||||||
if ($result) {
|
if ($result) {
|
||||||
setEventMessages($langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($receiver, 2)), null, 'mesgs');
|
setEventMessages($langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($receiver, 2)), null, 'mesgs');
|
||||||
|
$is_sent = true;
|
||||||
} else {
|
} else {
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
if ($mailfile->error) {
|
if ($mailfile->error) {
|
||||||
@ -2859,6 +2862,7 @@ class Ticket extends CommonObject
|
|||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
setEventMessages($langs->trans('ErrorMailRecipientIsEmptyForSendTicketMessage'), null, 'warnings');
|
setEventMessages($langs->trans('ErrorMailRecipientIsEmptyForSendTicketMessage'), null, 'warnings');
|
||||||
}
|
}
|
||||||
|
return $is_sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user