From 200923595f40e3385e102427e72a0d7be10b8279 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Apr 2009 18:46:26 +0000 Subject: [PATCH] Fix pb of compatibility --- htdocs/core/conf.class.php | 13 ++++++---- .../modules/DolibarrModules.class.php | 24 ++++++++++--------- mysql/migration/2.5.0-2.6.0.sql | 3 ++- mysql/tables/llx_const.key.sql | 22 +++++++++++++++++ mysql/tables/llx_const.sql | 5 ++-- 5 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 mysql/tables/llx_const.key.sql diff --git a/htdocs/core/conf.class.php b/htdocs/core/conf.class.php index 4930536c950..69aa2dc7aa2 100644 --- a/htdocs/core/conf.class.php +++ b/htdocs/core/conf.class.php @@ -45,8 +45,8 @@ class Conf var $dol_document_root; - var $monnaie; // Used to store current currency - var $css; // Used to store current css (from theme) + var $monnaie; // Used to store current currency + var $css; // Used to store current css (from theme) var $top_menu; var $left_menu; @@ -54,8 +54,8 @@ class Conf var $tabs_modules=array(); var $logbuffer=array(); - - var $entity; + + var $entity = 1; // By default for backward compatibility /** @@ -71,12 +71,15 @@ class Conf $this->global->PRODUIT_CONFIRM_DELETE_LINE=1; // Load entity cookie + /* TODO Removed: La classe conf est une classe de stockage de conf independante + de la couche presentation et de la gestion des acces IHM, donc ne doit pas acceder des cookies. $entityCookieName = "DOLENTITYID_dolibarr"; if (!$_COOKIE[$entityCookieName]){ $this->entity = 1; }else{ $this->entity = $_COOKIE[$entityCookieName]; } + */ /* * Definition de toutes les Constantes globales d'environnement @@ -155,7 +158,7 @@ class Conf $this->compta->enabled=defined("MAIN_MODULE_COMPTABILITE")?MAIN_MODULE_COMPTABILITE:0; $this->webcal->enabled=defined('MAIN_MODULE_WEBCALENDAR')?MAIN_MODULE_WEBCALENDAR:0; $this->propal->enabled=defined("MAIN_MODULE_PROPALE")?MAIN_MODULE_PROPALE:0; - + // Module agenda $this->agenda->dir_temp=DOL_DATA_ROOT."/agenda/temp"; diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index 77382bf6e62..553fa0fd6a0 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -160,7 +160,7 @@ class DolibarrModules $err=0; $this->db->begin(); - + // Remove line in activation module if (! $err) $err+=$this->_dbunactive(); @@ -185,7 +185,7 @@ class DolibarrModules // Run complementary sql requests for ($i = 0 ; $i < sizeof($array_sql) ; $i++) { - if (! $err) + if (! $err) { if (!$this->db->query($array_sql[$i])) { @@ -286,7 +286,7 @@ class DolibarrModules $sql ="SELECT active_version FROM ".MAIN_DB_PREFIX."dolibarr_modules"; $sql .= " WHERE numero=".$this->numero." AND active = 1"; - + dol_syslog("DolibarrModules::getDbVersion sql=".$sql); $resql = $this->db->query($sql); if ($resql) @@ -346,7 +346,7 @@ class DolibarrModules /** * \brief Insert line in dolibarr_modules table. * \return int Nb of errors (0 if OK) - * \remarks Storage is made for information only, table is not required for Dolibarr usage. + * \remarks Storage is made for information only, table is not required for Dolibarr usage. */ function _dbactive() { @@ -369,7 +369,7 @@ class DolibarrModules /** * \brief Remove line in dolibarr_modules table * \return int Nb of errors (0 if OK) - * \remarks Storage is made for information only, table is not required for Dolibarr usage. + * \remarks Storage is made for information only, table is not required for Dolibarr usage. */ function _dbunactive() { @@ -392,8 +392,9 @@ class DolibarrModules global $conf; $err = 0; - - if ($this->family == "base") $conf->entity = 0; // Common module + + // Removed because create pb of compatibility + // if ($this->family == "base") $conf->entity = 0; // Common module $sql = "DELETE FROM ".MAIN_DB_PREFIX."const "; $sql.= "WHERE name = '".$this->const_name."' "; @@ -402,7 +403,7 @@ class DolibarrModules $this->db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible,entity) VALUES"; - $sql.= " ('".$this->const_name."','1',0,".$conf->entity.")"; + $sql.= " ('".$this->const_name."','1',0,".$conf->entity.")"; dol_syslog("DolibarrModules::_active sql=".$sql, LOG_DEBUG); if (!$this->db->query($sql)) { @@ -420,10 +421,11 @@ class DolibarrModules function _unactive() { global $conf; - + $err = 0; - - if ($this->family == "base") $conf->entity = 0; // Common module + + // Removed because create pb of compatibility + // if ($this->family == "base") $conf->entity = 0; // Common module $sql = "DELETE FROM ".MAIN_DB_PREFIX."const "; $sql.= "WHERE name = '".$this->const_name."'"; diff --git a/mysql/migration/2.5.0-2.6.0.sql b/mysql/migration/2.5.0-2.6.0.sql index a52153656b7..9b9a2e96c13 100644 --- a/mysql/migration/2.5.0-2.6.0.sql +++ b/mysql/migration/2.5.0-2.6.0.sql @@ -126,4 +126,5 @@ ALTER TABLE llx_categorie_association ADD UNIQUE INDEX uk_categorie_association_ -- Multi company ALTER TABLE llx_const ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER tms; ALTER TABLE llx_const DROP INDEX name; -ALTER TABLE llx_const ADD UNIQUE INDEX(name, entity); \ No newline at end of file + +ALTER TABLE llx_const ADD UNIQUE INDEX uk_const (name, entity); diff --git a/mysql/tables/llx_const.key.sql b/mysql/tables/llx_const.key.sql new file mode 100644 index 00000000000..51234007ee1 --- /dev/null +++ b/mysql/tables/llx_const.key.sql @@ -0,0 +1,22 @@ +-- ============================================================================ +-- Copyright (C) 2009 Laurent Destailleur +-- +-- 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$ +-- ============================================================================ + + +ALTER TABLE llx_const ADD UNIQUE INDEX uk_const (name, entity); diff --git a/mysql/tables/llx_const.sql b/mysql/tables/llx_const.sql index 9dead9c3dbc..f9ea667fee5 100644 --- a/mysql/tables/llx_const.sql +++ b/mysql/tables/llx_const.sql @@ -34,9 +34,8 @@ create table llx_const visible tinyint DEFAULT 1 NOT NULL, note text, tms timestamp, - entity integer DEFAULT 1 NOT NULL, -- multi company id - UNIQUE INDEX(name) -)type=innodb; + entity integer DEFAULT 1 NOT NULL -- multi company id +) type=innodb; -- -- List of codes for the field entity