modMailing.class.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \defgroup mailing Module emailing
  21. * \brief Module to manage EMailings
  22. * \file htdocs/core/modules/modMailing.class.php
  23. * \ingroup mailing
  24. * \brief Fichier de description et activation du module Mailing
  25. */
  26. include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
  27. /**
  28. * Class to describe and enable module Mailing
  29. */
  30. class modMailing extends DolibarrModules
  31. {
  32. /**
  33. * Constructor. Define names, constants, directories, boxes, permissions
  34. *
  35. * @param DoliDB $db Database handler
  36. */
  37. function __construct($db)
  38. {
  39. $this->db = $db;
  40. $this->numero = 22;
  41. $this->family = "technic";
  42. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  43. $this->name = preg_replace('/^mod/i','',get_class($this));
  44. $this->description = "Gestion des EMailings";
  45. $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
  46. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  47. $this->special = 0;
  48. $this->picto='email';
  49. // Data directories to create when module is enabled
  50. $this->dirs = array("/mailing/temp");
  51. // Dependencies
  52. $this->depends = array();
  53. $this->requiredby = array();
  54. $this->langfiles = array("mails");
  55. // Config pages
  56. $this->config_page_url = array("mailing.php");
  57. // Constants
  58. $this->const = array();
  59. // Boxes
  60. $this->boxes = array();
  61. // Permissions
  62. $this->rights = array();
  63. $this->rights_class = 'mailing';
  64. $r=0;
  65. $r++;
  66. $this->rights[$r][0] = 221; // id de la permission
  67. $this->rights[$r][1] = 'Consulter les mailings'; // libelle de la permission
  68. $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
  69. $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
  70. $this->rights[$r][4] = 'lire';
  71. $r++;
  72. $this->rights[$r][0] = 222;
  73. $this->rights[$r][1] = 'Creer/modifier les mailings (sujet, destinataires...)';
  74. $this->rights[$r][2] = 'w';
  75. $this->rights[$r][3] = 0;
  76. $this->rights[$r][4] = 'creer';
  77. $r++;
  78. $this->rights[$r][0] = 223;
  79. $this->rights[$r][1] = 'Valider les mailings (permet leur envoi)';
  80. $this->rights[$r][2] = 'w';
  81. $this->rights[$r][3] = 0;
  82. $this->rights[$r][4] = 'valider';
  83. $r++;
  84. $this->rights[$r][0] = 229;
  85. $this->rights[$r][1] = 'Supprimer les mailings';
  86. $this->rights[$r][2] = 'd';
  87. $this->rights[$r][3] = 0;
  88. $this->rights[$r][4] = 'supprimer';
  89. $r++;
  90. $this->rights[$r][0] = 237;
  91. $this->rights[$r][1] = 'View recipients and info';
  92. $this->rights[$r][2] = 'r';
  93. $this->rights[$r][3] = 0;
  94. $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  95. $this->rights[$r][5] = 'recipient';
  96. $r++;
  97. $this->rights[$r][0] = 238;
  98. $this->rights[$r][1] = 'Manually send mailings';
  99. $this->rights[$r][2] = 'w';
  100. $this->rights[$r][3] = 0;
  101. $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  102. $this->rights[$r][5] = 'send';
  103. $r++;
  104. $this->rights[$r][0] = 239;
  105. $this->rights[$r][1] = 'Delete mailings after validation and/or sent';
  106. $this->rights[$r][2] = 'd';
  107. $this->rights[$r][3] = 0;
  108. $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  109. $this->rights[$r][5] = 'delete';
  110. }
  111. /**
  112. * Function called when module is enabled.
  113. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  114. * It also creates data directories
  115. *
  116. * @param string $options Options when enabling module ('', 'noboxes')
  117. * @return int 1 if OK, 0 if KO
  118. */
  119. function init($options='')
  120. {
  121. // Permissions
  122. $this->remove($options);
  123. $sql = array();
  124. return $this->_init($sql,$options);
  125. }
  126. }