From 229176ea65898abe3101c19025a48febb701b85e Mon Sep 17 00:00:00 2001 From: FHenry Date: Wed, 22 Feb 2012 20:49:55 +0100 Subject: [PATCH] Read Receipt in module emailing --- htdocs/comm/mailing/cibles.php | 1 + htdocs/comm/mailing/fiche.php | 6 +++- htdocs/langs/en_US/mails.lang | 1 + htdocs/langs/fr_FR/mails.lang | 1 + htdocs/public/emailing/mailing-read.php | 46 +++++++++++++++++++++++++ scripts/emailings/mailing-send.php | 1 + 6 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 htdocs/public/emailing/mailing-read.php diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 9f4f5087cee..45092f15267 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -515,6 +515,7 @@ if ($mil->fetch($id) >= 0) print ''; if ($obj->statut==-1) print $langs->trans("MailingStatusError").' '.img_error(); if ($obj->statut==1) print $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6'); + if ($obj->statut==2) print $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6'); print ''; } print ''; diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index e0560bd3130..7abf5287ef6 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -40,6 +40,7 @@ $message = ''; $substitutionarray=array( '__ID__' => 'IdRecord', '__EMAIL__' => 'EMail', +'__CHECK_READ__' => 'CheckMailIsRead', '__LASTNAME__' => 'Lastname', '__FIRSTNAME__' => 'Firstname', '__OTHER1__' => 'Other1', @@ -51,6 +52,7 @@ $substitutionarray=array( $substitutionarrayfortest=array( '__ID__' => 'TESTIdRecord', '__EMAIL__' => 'TESTEMail', +'__CHECK_READ__' => 'TESTCheckMailIsRead', '__LASTNAME__' => 'TESTLastname', '__FIRSTNAME__' => 'TESTFirstname', '__OTHER1__' => 'TESTOther1', @@ -178,6 +180,7 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes') $substitutionarray=array( '__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, + '__CHECK_READ__' => '', '__LASTNAME__' => $obj->nom, '__FIRSTNAME__' => $obj->prenom, '__OTHER1__' => $other1, @@ -186,7 +189,7 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes') '__OTHER4__' => $other4, '__OTHER5__' => $other5 ); - + $substitutionisok=true; complete_substitutions_array($substitutionarray, $langs); $newsubject=make_substitutions($subject,$substitutionarray); @@ -1026,6 +1029,7 @@ else print '
'.$langs->trans("CommonSubstitutions").':
'; print '__ID__ = '.$langs->trans("IdRecord").'
'; print '__EMAIL__ = '.$langs->trans("EMail").'
'; + print '__CHECK_READ__ = '.$langs->trans("CheckRead").'
'; print '__LASTNAME__ = '.$langs->trans("Lastname").'
'; print '__FIRSTNAME__ = '.$langs->trans("Firstname").'
'; print '__OTHER1__ = '.$langs->trans("Other").'1
'; diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 65d8460d442..04eddbf9791 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -39,6 +39,7 @@ MailingStatusDraft=Draft MailingStatusValidated=Validated MailingStatusApproved=Approved MailingStatusSent=Sent +MailingStatusRead=Read MailingStatusSentPartialy=Sent partialy MailingStatusSentCompletely=Sent completely MailingStatusError=Error diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index eb44be793e5..591000e00d8 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -39,6 +39,7 @@ MailingStatusDraft=Brouillon MailingStatusValidated=Validé MailingStatusApproved=Approuvé MailingStatusSent=Envoyé +MailingStatusRead=Lu MailingStatusSentPartialy=Envoyé partiellement MailingStatusSentCompletely=Envoyé complètement MailingStatusError=Erreur diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php new file mode 100644 index 00000000000..e1271a71f41 --- /dev/null +++ b/htdocs/public/emailing/mailing-read.php @@ -0,0 +1,46 @@ +#!/usr/bin/php + + * Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2012 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +/** + * \file scripts/emailings/mailing-read.php + * \ingroup mailing + * \brief Script use to update mail status if destinaries read it (if images during mail read are display) + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +require("../../main.inc.php"); + +$id=GETPOST('mail_cbl_id'); +$mail_reader=GETPOST('mail'); + + +$statut='2'; + +$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE rowid=".$id." AND email='".$mail_reader."'"; +dol_syslog("public/emailing/mailing-read.php : Mail read : ".$sql, LOG_DEBUG); + +$resql=$db->query($sql); + +$db->close(); +?> diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index aaf966eb3dc..13d28f95eda 100644 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -135,6 +135,7 @@ if ($resql) $substitutionarray=array( '__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, + '__CHECK_READ__' => '', '__LASTNAME__' => $obj->lastname, '__FIRSTNAME__' => $obj->firstname, '__OTHER1__' => $other1,