dolibarr  16.0.5
mailing-read.php
Go to the documentation of this file.
1 <?php
28 if (!defined('NOLOGIN')) {
29  define('NOLOGIN', '1');
30 }
31 if (!defined('NOCSRFCHECK')) {
32  define('NOCSRFCHECK', '1');
33 }
34 if (!defined('NOBROWSERNOTIF')) {
35  define('NOBROWSERNOTIF', '1');
36 }
37 if (!defined('NOREQUIRETRAN')) {
38  define('NOREQUIRETRAN', '1');
39 }
40 if (!defined('NOTOKENRENEWAL')) {
41  define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test
42 }
43 if (!defined('NOREQUIREMENU')) {
44  define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
45 }
46 if (!defined('NOIPCHECK')) {
47  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
48 }
49 if (!defined("NOSESSION")) {
50  define("NOSESSION", '1');
51 }
52 
58 function llxHeader()
59 {
60 }
66 function llxFooter()
67 {
68 }
69 
70 
71 require '../../main.inc.php';
72 
73 $mtid = GETPOST('mtid');
74 $email = GETPOST('email');
75 $tag = GETPOST('tag');
76 $securitykey = GETPOST('securitykey');
77 
78 
79 /*
80  * Actions
81  */
82 
83 dol_syslog("public/emailing/mailing-read.php : tag=".$tag." securitykey=".$securitykey, LOG_DEBUG);
84 
85 if ($securitykey != $conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) {
86  print 'Bad security key value.';
87  exit;
88 }
89 
90 if (!empty($tag)) {
91  dol_syslog("public/emailing/mailing-read.php : Update status of email target and thirdparty for tag ".$tag, LOG_DEBUG);
92 
93  $sql = "SELECT mc.rowid, mc.email, mc.statut, mc.source_type, mc.source_id, m.entity";
94  $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."mailing as m";
95  $sql .= " WHERE mc.fk_mailing = m.rowid AND mc.tag='".$db->escape($tag)."'";
96 
97  $resql = $db->query($sql);
98  if (!$resql) dol_print_error($db);
99 
100  $obj = $db->fetch_object($resql);
101 
102  if (empty($obj)) {
103  print 'Email target not valid. Operation canceled.';
104  exit;
105  }
106  if (empty($obj->email)) {
107  print 'Email target not valid. Operation canceled.';
108  exit;
109  }
110  if ($obj->statut == 2 || $obj->statut == 3) {
111  print 'Email target already set to read or unsubscribe. Operation canceled.';
112  exit;
113  }
114  // TODO Test that mtid and email match also with the one found from $tag
115  /*
116  if ($obj->email != $email)
117  {
118  print 'Email does not match tagnot found. No need to unsubscribe.';
119  exit;
120  }
121  */
122 
123  //Update status of target
124  $statut = '2';
125  $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".((int) $statut)." WHERE rowid = ".((int) $obj->rowid);
126  $resql = $db->query($sql);
127  if (!$resql) dol_print_error($db);
128 
129  //Update status communication of thirdparty prospect
130  if ($obj->source_id > 0 && $obj->source_type == 'thirdparty' && $obj->entity) {
131  $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.((int) $obj->entity).' AND rowid = '.((int) $obj->source_id);
132  $resql = $db->query($sql);
133  }
134 
135  //Update status communication of contact prospect
136  if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) {
137  $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.((int) $obj->entity).' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.((int) $obj->source_id).')';
138  $resql = $db->query($sql);
139  }
140 }
141 
142 $db->close();
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
llxFooter
llxFooter()
Footer empty.
Definition: mailing-read.php:66
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
llxHeader
if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOBROWSERNOTIF')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOIPCHECK')) if(!defined("NOSESSION")) llxHeader()
Header empty.
Definition: mailing-read.php:58
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742