mailing-read.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  4. * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file public/emailing/mailing-read.php
  22. * \ingroup mailing
  23. * \brief Script use to update mail status if destinaries read it (if images during mail read are display)
  24. */
  25. if (!defined('NOLOGIN')) define("NOLOGIN", 1); // This means this output page does not require to be logged.
  26. if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
  27. if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
  28. if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test
  29. if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
  30. /**
  31. * Header empty
  32. *
  33. * @return void
  34. */
  35. function llxHeader()
  36. {
  37. }
  38. /**
  39. * Footer empty
  40. *
  41. * @return void
  42. */
  43. function llxFooter()
  44. {
  45. }
  46. require '../../main.inc.php';
  47. $tag = GETPOST('tag');
  48. $securitykey = GETPOST('securitykey');
  49. /*
  50. * Actions
  51. */
  52. dol_syslog("public/emailing/mailing-read.php : tag=".$tag." securitykey=".$securitykey, LOG_DEBUG);
  53. if ($securitykey != $conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY)
  54. {
  55. print 'Bad security key value.';
  56. exit;
  57. }
  58. if (!empty($tag))
  59. {
  60. $statut = '2';
  61. $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE tag='".$db->escape($tag)."'";
  62. dol_syslog("public/emailing/mailing-read.php : Mail read : ".$sql, LOG_DEBUG);
  63. $resql = $db->query($sql);
  64. //Update status communication of thirdparty prospect
  65. $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=3 WHERE fk_stcomm != -1 AND rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag='".$db->escape($tag)."' AND source_type='thirdparty' AND source_id is not null)";
  66. dol_syslog("public/emailing/mailing-read.php : Mail read thirdparty : ".$sql, LOG_DEBUG);
  67. $resql = $db->query($sql);
  68. //Update status communication of contact prospect
  69. $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=3 WHERE fk_stcomm != -1 AND rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)";
  70. dol_syslog("public/emailing/mailing-read.php : Mail read contact : ".$sql, LOG_DEBUG);
  71. $resql = $db->query($sql);
  72. }
  73. $db->close();