modImport.class.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \defgroup import Module import
  20. * \brief Module to make generic import of data into dolibarr database
  21. * \file htdocs/core/modules/modImport.class.php
  22. * \ingroup import
  23. * \brief Fichier de description et activation du module Import
  24. */
  25. include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
  26. /**
  27. * Classe de description et activation du module Import
  28. */
  29. class modImport extends DolibarrModules
  30. {
  31. /**
  32. * Constructor. Define names, constants, directories, boxes, permissions
  33. *
  34. * @param DoliDB $db Database handler
  35. */
  36. function __construct($db)
  37. {
  38. $this->db = $db;
  39. $this->numero = 250;
  40. $this->family = "technic";
  41. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  42. $this->name = preg_replace('/^mod/i','',get_class($this));
  43. $this->description = "Outils d'imports de donnees Dolibarr (via un assistant)";
  44. // Possible values for version are: 'experimental' or 'dolibarr' or version
  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 = 'technic';
  49. // Data directories to create when module is enabled
  50. $this->dirs = array("/import/temp");
  51. // Config pages
  52. $this->config_page_url = array();
  53. // D�pendances
  54. $this->depends = array();
  55. $this->requiredby = array();
  56. $this->phpmin = array(4,3,0); // Need auto_detect_line_endings php option to solve MAC pbs.
  57. $this->phpmax = array();
  58. $this->need_dolibarr_version = array(2,7,-1); // Minimum version of Dolibarr required by module
  59. $this->need_javascript_ajax = 1;
  60. // Constantes
  61. $this->const = array();
  62. // Boxes
  63. $this->boxes = array();
  64. // Permissions
  65. $this->rights = array();
  66. $this->rights_class = 'import';
  67. $r=0;
  68. $r++;
  69. $this->rights[$r][0] = 1251;
  70. $this->rights[$r][1] = 'Run mass imports of external data (data load)';
  71. $this->rights[$r][2] = 'r';
  72. $this->rights[$r][3] = 0;
  73. $this->rights[$r][4] = 'run';
  74. }
  75. /**
  76. * Function called when module is enabled.
  77. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  78. * It also creates data directories
  79. *
  80. * @param string $options Options when enabling module ('', 'noboxes')
  81. * @return int 1 if OK, 0 if KO
  82. */
  83. function init($options='')
  84. {
  85. $sql = array();
  86. return $this->_init($sql,$options);
  87. }
  88. /**
  89. * Function called when module is disabled.
  90. * Remove from database constants, boxes and permissions from Dolibarr database.
  91. * Data directories are not deleted
  92. *
  93. * @param string $options Options when enabling module ('', 'noboxes')
  94. * @return int 1 if OK, 0 if KO
  95. */
  96. function remove($options='')
  97. {
  98. $sql = array();
  99. return $this->_remove($sql,$options);
  100. }
  101. }