* 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 public/emailing/mailing-unsubscribe.php * \ingroup mailing * \brief Script use to update unsubcribe contact to prospect mailing list */ 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'; require_once DOL_DOCUMENT_ROOT.'/lib/company.lib.php'; global $user, $conf, $langs; $langs->load("main"); $langs->load("mails"); $id=GETPOST('tag'); $unsuscrib=GETPOST('unsuscrib'); if (empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) accessforbidden('Option not enabled'); /* * Actions */ if (($id!='') && ($unsuscrib=='1')) { //Udate status of mail in Destinaries maling list $statut='3'; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE tag='".$id."'"; dol_syslog("public/emailing/mailing-unsubscribe.php : Mail unsubcribe : ".$sql, LOG_DEBUG); $resql=$db->query($sql); //Update status communication of thirdparty prospect $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=-1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag='".$id."' AND source_type='thirdparty' AND source_id is not null)"; dol_syslog("public/emailing/mailing-unsubscribe.php : Mail unsubcribe thirdparty : ".$sql, LOG_DEBUG); $resql=$db->query($sql); //Update status communication of contact prospect $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=-1 WHERE rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$id."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("public/emailing/mailing-unsubscribe.php : Mail unsubcribe contact : ".$sql, LOG_DEBUG); $resql=$db->query($sql); $sql = "SELECT mc.email"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.tag='".$id."'"; $resql=$db->query($sql); $obj = $db->fetch_object($resql); header("Content-type: text/html; charset=".$conf->file->character_set_client); print ''; print "\n"; print "\n"; print "\n"; print ''."\n"; print ''."\n"; print ''."\n"; print "".$langs->trans("MailUnsubcribe")."\n"; print ''."\n"; print ''; print "\n"; print ''."\n"; print '
'; print $langs->trans("YourMailUnsubcribeOK",$obj->email)."
\n"; print '
'; print "\n"; print "\n"; } $db->close(); ?>