From 115a0f5bfee054e6660c224a48b05041da3912bf Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 4 May 2009 13:13:01 +0000 Subject: [PATCH] New: early development of multi-company module --- htdocs/admin/modules.php | 2 +- .../modules/DolibarrModules.class.php | 5 +++- .../modules/modMultiCompany.class.php | 19 +-------------- htdocs/multicompany/sql/init/llx_const.sql | 23 ------------------- htdocs/multicompany/sql/remove/llx_const.sql | 23 ------------------- 5 files changed, 6 insertions(+), 66 deletions(-) delete mode 100644 htdocs/multicompany/sql/init/llx_const.sql delete mode 100644 htdocs/multicompany/sql/remove/llx_const.sql diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 7b015a68fc0..b9c513289f0 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -429,7 +429,7 @@ foreach ($orders as $key => $value) if (! empty($conf->global->$const_name)) { // Module actif - if (! empty($objMod->always_enabled)) print $langs->trans("Required"); + if (! empty($objMod->always_enabled) || ($conf->global->MAIN_MODULE_MULTICOMPANY && $conf->entity!=1 && $objMod->core_enabled)) print $langs->trans("Required"); else print "numero."&action=reset&value=" . $modName . "&mode=" . $mode . "\">" . $langs->trans("Disable") . "\n"; if (! empty($objMod->config_page_url)) diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index 61e2312e74b..4312a69be2d 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -442,10 +442,13 @@ class DolibarrModules global $conf; $err = 0; + + // Common module + $entity = (isset($this->core_enabled) ? 0 : $conf->entity); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; $sql.= " WHERE name = '".$this->const_name."'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".$entity; dol_syslog("DolibarrModules::_unactive sql=".$sql); $this->db->query($sql); diff --git a/htdocs/includes/modules/modMultiCompany.class.php b/htdocs/includes/modules/modMultiCompany.class.php index 7aef2682ff6..c0673828c9a 100644 --- a/htdocs/includes/modules/modMultiCompany.class.php +++ b/htdocs/includes/modules/modMultiCompany.class.php @@ -204,11 +204,7 @@ class modMultiCompany extends DolibarrModules { $sql = array(); - $init = $this->_init($sql); - - $result=$this->load_tables('/multicompany/sql/init/'); - - return $init; + return $this->_init($sql); } /** @@ -221,25 +217,12 @@ class modMultiCompany extends DolibarrModules { $sql = array(); - $result=$this->load_tables('/multicompany/sql/remove/'); $result = $this->destroy_cookie(); return $this->_remove($sql); } - /** - * \brief Create tables and keys required by module - * Files mymodule.sql and mymodule.key.sql with create table and create keys - * commands must be stored in directory /mymodule/sql/ - * This function is called by this->init. - * \return int <=0 if KO, >0 if OK - */ - function load_tables($path) - { - return $this->_load_tables($path); - } - /** * \brief Destroy a cookie */ diff --git a/htdocs/multicompany/sql/init/llx_const.sql b/htdocs/multicompany/sql/init/llx_const.sql deleted file mode 100644 index e822f7b575c..00000000000 --- a/htdocs/multicompany/sql/init/llx_const.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Copyright (C) 2009 Regis Houssin --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --- --- $Id$ --- - --- --- Constantes communes de configuration --- --- UPDATE llx_const SET entity=0 WHERE name='MAIN_MODULE_MULTICOMPANY' AND entity=1; diff --git a/htdocs/multicompany/sql/remove/llx_const.sql b/htdocs/multicompany/sql/remove/llx_const.sql deleted file mode 100644 index d9eb3ebc7db..00000000000 --- a/htdocs/multicompany/sql/remove/llx_const.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Copyright (C) 2009 Regis Houssin --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --- --- $Id$ --- - --- --- Constantes communes de configuration --- --- DELETE FROM llx_const WHERE name='MAIN_MODULE_MULTICOMPANY';