modWebsites.class.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \defgroup websites Module websites
  19. * \brief Websites module descriptor.
  20. * \file htdocs/core/modules/modWebsites.class.php
  21. * \ingroup websites
  22. * \brief Description and activation file for module Websites
  23. */
  24. include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
  25. /**
  26. * Class to describe Websites module
  27. */
  28. class modWebsites extends DolibarrModules
  29. {
  30. /**
  31. * Constructor. Define names, constants, directories, boxes, permissions
  32. *
  33. * @param DoliDB $db Database handler
  34. */
  35. function __construct($db)
  36. {
  37. global $langs,$conf;
  38. $this->db = $db;
  39. $this->numero = 10000;
  40. // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
  41. // It is used to group modules in module setup page
  42. $this->family = "portal";
  43. $this->module_position = 50;
  44. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  45. $this->name = preg_replace('/^mod/i','',get_class($this));
  46. $this->description = "Enable the public website with CMS features";
  47. $this->version = 'development'; // 'experimental' or 'dolibarr' or version
  48. // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
  49. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  50. // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
  51. $this->special = 0;
  52. // Name of image file used for this module.
  53. $this->picto='globe';
  54. // Data directories to create when module is enabled
  55. $this->dirs = array("/websites/temp");
  56. // Config pages
  57. //-------------
  58. $this->config_page_url = array('websites.php');
  59. // Dependancies
  60. //-------------
  61. $this->hidden = ! empty($conf->global->WEBSITE_MODULE_DISABLED); // A condition to disable module
  62. $this->depends = array('modFckeditor'); // List of modules id that must be enabled if this module is enabled
  63. $this->requiredby = array(); // List of modules id to disable if this one is disabled
  64. $this->conflictwith = array(); // List of modules id this module is in conflict with
  65. $this->langfiles = array("websites");
  66. // Constants
  67. //-----------
  68. $this->const = array();
  69. // New pages on tabs
  70. // -----------------
  71. $this->tabs = array();
  72. // Boxes
  73. //------
  74. $this->boxes = array();
  75. // Permissions
  76. $this->rights = array(); // Permission array used by this module
  77. $this->rights_class = 'websites';
  78. $r=0;
  79. $this->rights[$r][0] = 10001;
  80. $this->rights[$r][1] = 'Read website content';
  81. $this->rights[$r][3] = 1;
  82. $this->rights[$r][4] = 'read';
  83. $r++;
  84. $this->rights[$r][0] = 10002;
  85. $this->rights[$r][1] = 'Create/modify website content';
  86. $this->rights[$r][3] = 0;
  87. $this->rights[$r][4] = 'write';
  88. $r++;
  89. $this->rights[$r][0] = 10003;
  90. $this->rights[$r][1] = 'Delete website content';
  91. $this->rights[$r][3] = 0;
  92. $this->rights[$r][4] = 'delete';
  93. $r++;
  94. // Main menu entries
  95. $r=0;
  96. $this->menu[$r]=array( 'fk_menu'=>'0', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
  97. 'type'=>'top', // This is a Left menu entry
  98. 'titre'=>'Websites',
  99. 'mainmenu'=>'websites',
  100. 'url'=>'/websites/index.php',
  101. 'langs'=>'websites', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  102. 'position'=>100,
  103. 'enabled'=>'$conf->websites->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
  104. 'perms'=>'$user->rights->websites->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
  105. 'target'=>'',
  106. 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
  107. $r++;
  108. }
  109. }