modMailing.class.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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@inodbox.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 <https://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 Description and activation file for the 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. public function __construct($db)
  38. {
  39. $this->db = $db;
  40. $this->numero = 22;
  41. // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
  42. // It is used to group modules by family in module setup page
  43. $this->family = "interface";
  44. // Module position in the family on 2 digits ('01', '10', '20', ...)
  45. $this->module_position = '23';
  46. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  47. $this->name = preg_replace('/^mod/i', '', get_class($this));
  48. $this->description = "Gestion des EMailings";
  49. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  50. $this->version = 'dolibarr';
  51. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  52. $this->picto = 'email';
  53. // Data directories to create when module is enabled
  54. $this->dirs = array("/mailing/temp");
  55. // Dependencies
  56. $this->hidden = false; // A condition to hide module
  57. $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
  58. $this->requiredby = array(); // List of module ids to disable if this one is disabled
  59. $this->conflictwith = array(); // List of module class names as string this module is in conflict with
  60. $this->phpmin = array(5, 6); // Minimum version of PHP required by module
  61. $this->langfiles = array("mails");
  62. // Config pages
  63. $this->config_page_url = array("mailing.php");
  64. // Constants
  65. $this->const = array();
  66. $r = 0;
  67. $this->const[$r][0] = "MAILING_CONTACT_DEFAULT_BULK_STATUS";
  68. $this->const[$r][1] = "chaine";
  69. $this->const[$r][2] = "0";
  70. $this->const[$r][3] = 'Default value for field "Refuse bulk email" when creating a contact';
  71. $this->const[$r][4] = 0;
  72. $r++;
  73. // Boxes
  74. $this->boxes = array();
  75. // Permissions
  76. $this->rights = array();
  77. $this->rights_class = 'mailing';
  78. $r = 0;
  79. $r++;
  80. $this->rights[$r][0] = 221; // id de la permission
  81. $this->rights[$r][1] = 'Consulter les mailings'; // libelle de la permission
  82. $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
  83. $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
  84. $this->rights[$r][4] = 'lire';
  85. $r++;
  86. $this->rights[$r][0] = 222;
  87. $this->rights[$r][1] = 'Creer/modifier les mailings (sujet, destinataires...)';
  88. $this->rights[$r][2] = 'w';
  89. $this->rights[$r][3] = 0;
  90. $this->rights[$r][4] = 'creer';
  91. $r++;
  92. $this->rights[$r][0] = 223;
  93. $this->rights[$r][1] = 'Valider les mailings (permet leur envoi)';
  94. $this->rights[$r][2] = 'w';
  95. $this->rights[$r][3] = 0;
  96. $this->rights[$r][4] = 'valider';
  97. $r++;
  98. $this->rights[$r][0] = 229;
  99. $this->rights[$r][1] = 'Supprimer les mailings';
  100. $this->rights[$r][2] = 'd';
  101. $this->rights[$r][3] = 0;
  102. $this->rights[$r][4] = 'supprimer';
  103. $r++;
  104. $this->rights[$r][0] = 237;
  105. $this->rights[$r][1] = 'View recipients and info';
  106. $this->rights[$r][2] = 'r';
  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] = 'recipient';
  110. $r++;
  111. $this->rights[$r][0] = 238;
  112. $this->rights[$r][1] = 'Manually send mailings';
  113. $this->rights[$r][2] = 'w';
  114. $this->rights[$r][3] = 0;
  115. $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  116. $this->rights[$r][5] = 'send';
  117. $r++;
  118. $this->rights[$r][0] = 239;
  119. $this->rights[$r][1] = 'Delete mailings after validation and/or sent';
  120. $this->rights[$r][2] = 'd';
  121. $this->rights[$r][3] = 0;
  122. $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  123. $this->rights[$r][5] = 'delete';
  124. // Menus
  125. //-------
  126. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
  127. }
  128. /**
  129. * Function called when module is enabled.
  130. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  131. * It also creates data directories
  132. *
  133. * @param string $options Options when enabling module ('', 'noboxes')
  134. * @return int 1 if OK, 0 if KO
  135. */
  136. public function init($options = '')
  137. {
  138. // Permissions
  139. $this->remove($options);
  140. $sql = array();
  141. return $this->_init($sql, $options);
  142. }
  143. }