modExternalSite.class.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2012 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 externalsite Module externalsite
  21. * \brief Module to include an external web site/tools into Dolibarr menu and into a frame page.
  22. * \file htdocs/core/modules/modExternalSite.class.php
  23. * \ingroup externalsite
  24. * \brief Description and activation file for module ExternalSite
  25. */
  26. include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
  27. /**
  28. * Description and activation class for module ExternalSite
  29. */
  30. class modExternalSite 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. // Id for module (must be unique).
  41. // Use here a free id.
  42. $this->numero = 100;
  43. // Family can be 'crm','financial','hr','projects','product','technic','other'
  44. // It is used to sort modules in module setup page
  45. $this->family = "other";
  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. // Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value)
  49. $this->description = "This module include an external web site or page into Dolibarr menus and view it into a Dolibarr frame.";
  50. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  51. $this->version = 'dolibarr';
  52. // Key used in llx_const table to save module status enabled/disabled (XXX is id value)
  53. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  54. // Where to store the module in setup page (0=common,1=interface,2=other)
  55. $this->special = 1;
  56. // Name of png file (without png) used for this module
  57. $this->picto='bookmark';
  58. // Call to inside lang's file
  59. $this->langfiles = array("externalsite");
  60. // Data directories to create when module is enabled
  61. $this->dirs = array();
  62. // Config pages. Put here list of php page names stored in admmin directory used to setup module
  63. $this->config_page_url = array("externalsite.php@externalsite");
  64. // Dependencies
  65. $this->depends = array(); // List of modules id that must be enabled if this module is enabled
  66. $this->requiredby = array(); // List of modules id to disable if this one is disabled
  67. // Constants
  68. // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
  69. // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
  70. // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0)
  71. // );
  72. $this->const = array(0=>array('EXTERNALSITE_LABEL','chaine','ExternalSite','To declare label to use into external site menu entry', 0));
  73. // Boxes
  74. $this->boxes = array(); // List of boxes
  75. $r=0;
  76. // Add here list of php file(s) stored in core/boxes that contains class to show a box.
  77. // Example:
  78. //$this->boxes[$r][1] = "myboxa.php";
  79. //$r++;
  80. //$this->boxes[$r][1] = "myboxb.php";
  81. //$r++;
  82. // Permissions
  83. $this->rights_class = 'externalsite'; // Permission key
  84. $this->rights = array(); // Permission array used by this module
  85. // Menus
  86. //------
  87. $r=0;
  88. $this->menu[$r]=array(
  89. 'fk_menu'=>0,
  90. 'type'=>'top',
  91. 'titre'=>'$conf->global->EXTERNALSITE_LABEL',
  92. 'mainmenu'=>'externalsite',
  93. 'url'=>'/externalsite/frames.php',
  94. 'langs'=>'other',
  95. 'position'=>100,
  96. 'perms'=>'',
  97. 'enabled'=>'$conf->externalsite->enabled',
  98. 'target'=>'',
  99. 'user'=>0
  100. );
  101. $r++;
  102. }
  103. /**
  104. * Function called when module is enabled.
  105. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  106. * It also creates data directories
  107. *
  108. * @param string $options Options when enabling module ('', 'noboxes')
  109. * @return int 1 if OK, 0 if KO
  110. */
  111. function init($options='')
  112. {
  113. $sql = array();
  114. return $this->_init($sql,$options);
  115. }
  116. /**
  117. * Function called when module is disabled.
  118. * Remove from database constants, boxes and permissions from Dolibarr database.
  119. * Data directories are not deleted
  120. *
  121. * @param string $options Options when enabling module ('', 'noboxes')
  122. * @return int 1 if OK, 0 if KO
  123. */
  124. function remove($options='')
  125. {
  126. $sql = array();
  127. return $this->_remove($sql,$options);
  128. }
  129. }