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