Fix pb of compatibility

This commit is contained in:
Laurent Destailleur 2009-04-16 18:46:26 +00:00
parent 2efd3db4c8
commit 200923595f
5 changed files with 47 additions and 20 deletions

View File

@ -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";

View File

@ -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."'";

View File

@ -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);
ALTER TABLE llx_const ADD UNIQUE INDEX uk_const (name, entity);

View File

@ -0,0 +1,22 @@
-- ============================================================================
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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);

View File

@ -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