diff --git a/htdocs/multicompany/sql/init/llx_const.sql b/htdocs/multicompany/sql/init/llx_const.sql index 4250625422e..efe8db37249 100644 --- a/htdocs/multicompany/sql/init/llx_const.sql +++ b/htdocs/multicompany/sql/init/llx_const.sql @@ -17,5 +17,33 @@ -- $Id$ -- +-- +-- Constantes communes de configuration +-- +UPDATE llx_const SET entity=0 WHERE name='MAIN_MODULE_MULTICOMPANY' AND entity=1; UPDATE llx_const SET entity=0 WHERE name='MAIN_MODULE_USER' AND entity=1; -UPDATE llx_const SET entity=0 WHERE name='MAIN_MODULE_MULTICOMPANY' AND entity=1; \ No newline at end of file +UPDATE llx_const SET entity=0 WHERE name='MAIN_POPUP_CALENDAR' AND entity=1; +UPDATE llx_const SET entity=0 WHERE name='MAIN_MAIL_SMTP_SERVER' AND entity=1; +UPDATE llx_const SET entity=0 WHERE name='MAIN_MAIL_SMTP_PORT' AND entity=1; +UPDATE llx_const SET entity=0 WHERE name='MAIN_UPLOAD_DOC' AND entity=1; +UPDATE llx_const SET entity=0 WHERE name='MAIN_FEATURES_LEVEL' AND entity=1; +UPDATE llx_const SET entity=0 WHERE name='MAIN_SEARCHFORM_SOCIETE' AND entity=1; +UPDATE llx_const SET entity=0 WHERE name='MAIN_SEARCHFORM_CONTACT' AND entity=1; +UPDATE llx_const SET entity=0 WHERE name='MAIN_SEARCHFORM_PRODUITSERVICE' AND entity=1; +UPDATE llx_const SET entity=0 WHERE name='MAIN_SEARCHFORM_ADHERENT' AND entity=1; + +-- +-- IHM +-- +UPDATE llx_const SET entity=0 WHERE name='MAIN_SIZE_LISTE_LIMIT' AND entity=1; +UPDATE llx_const SET entity=0 WHERE name='MAIN_SHOW_WORKBOARD' AND entity=1; + +-- +-- Tiers +-- +UPDATE llx_const SET entity=0 WHERE name='SOCIETE_NOLIST_COURRIER' AND entity=1; + +-- +-- Barcode +-- +UPDATE llx_const SET entity=0 WHERE name='GENBARCODE_LOCATION' AND entity=1; \ No newline at end of file diff --git a/htdocs/multicompany/sql/remove/llx_const.sql b/htdocs/multicompany/sql/remove/llx_const.sql index 05f3fe28a1c..cfb93554bf1 100644 --- a/htdocs/multicompany/sql/remove/llx_const.sql +++ b/htdocs/multicompany/sql/remove/llx_const.sql @@ -17,5 +17,33 @@ -- $Id$ -- +-- +-- Constantes communes de configuration +-- +DELETE FROM llx_const WHERE name='MAIN_MODULE_MULTICOMPANY'; UPDATE llx_const SET entity=1 WHERE name='MAIN_MODULE_USER' AND entity=0; -DELETE FROM llx_const WHERE name='MAIN_MODULE_MULTICOMPANY'; \ No newline at end of file +UPDATE llx_const SET entity=1 WHERE name='MAIN_POPUP_CALENDAR' AND entity=0; +UPDATE llx_const SET entity=1 WHERE name='MAIN_MAIL_SMTP_SERVER' AND entity=0; +UPDATE llx_const SET entity=1 WHERE name='MAIN_MAIL_SMTP_PORT' AND entity=0; +UPDATE llx_const SET entity=1 WHERE name='MAIN_UPLOAD_DOC' AND entity=0; +UPDATE llx_const SET entity=1 WHERE name='MAIN_FEATURES_LEVEL' AND entity=0; +UPDATE llx_const SET entity=1 WHERE name='MAIN_SEARCHFORM_SOCIETE' AND entity=0; +UPDATE llx_const SET entity=1 WHERE name='MAIN_SEARCHFORM_CONTACT' AND entity=0; +UPDATE llx_const SET entity=1 WHERE name='MAIN_SEARCHFORM_PRODUITSERVICE' AND entity=0; +UPDATE llx_const SET entity=1 WHERE name='MAIN_SEARCHFORM_ADHERENT' AND entity=0; + +-- +-- IHM +-- +UPDATE llx_const SET entity=1 WHERE name='MAIN_SIZE_LISTE_LIMIT' AND entity=0; +UPDATE llx_const SET entity=1 WHERE name='MAIN_SHOW_WORKBOARD' AND entity=0; + +-- +-- Tiers +-- +UPDATE llx_const SET entity=1 WHERE name='SOCIETE_NOLIST_COURRIER' AND entity=0; + +-- +-- Barcode +-- +UPDATE llx_const SET entity=1 WHERE name='GENBARCODE_LOCATION' AND entity=0; diff --git a/htdocs/user.class.php b/htdocs/user.class.php index 558e762f963..629cddd3e32 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -4,7 +4,7 @@ * Copyright (c) 2004-2008 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2007 Regis Houssin + * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * * This program is free software; you can redistribute it and/or modify @@ -63,6 +63,7 @@ class User extends CommonObject var $user_mobile; var $admin; var $login; + var $entity; //! Clear password in memory var $pass; @@ -146,7 +147,7 @@ class User extends CommonObject $sql.= " u.admin, u.login, u.webcal_login, u.phenix_login, u.phenix_pass, u.note,"; $sql.= " u.pass, u.pass_crypted, u.pass_temp,"; $sql.= " u.fk_societe, u.fk_socpeople, u.fk_member, u.ldap_sid,"; - $sql.= " u.statut, u.lang,"; + $sql.= " u.statut, u.lang, u.entity,"; $sql.= " ".$this->db->pdate("u.datec")." as datec,"; $sql.= " ".$this->db->pdate("u.tms")." as datem,"; $sql.= " ".$this->db->pdate("u.datelastlogin")." as datel,"; @@ -194,6 +195,7 @@ class User extends CommonObject $this->note = $obj->note; $this->statut = $obj->statut; $this->lang = $obj->lang; + $this->entity = $obj->entity; $this->datec = $obj->datec; $this->datem = $obj->datem; @@ -980,6 +982,7 @@ class User extends CommonObject $sql.= ", phenix_login = '".addslashes($this->phenix_login)."'"; $sql.= ", phenix_pass = '".addslashes($this->phenix_pass)."'"; $sql.= ", note = '".addslashes($this->note)."'"; + //$sql.= ", entity = '".$this->entity."'"; $sql.= " WHERE rowid = ".$this->id; dol_syslog("User::update sql=".$sql, LOG_DEBUG); @@ -1027,6 +1030,8 @@ class User extends CommonObject $adh->user_id=$this->id; $adh->user_login=$this->login; + + //$adh->entity=$this->entity; $result=$adh->update($user,0,1); if ($result < 0) @@ -1702,7 +1707,7 @@ class User extends CommonObject function info($id) { $sql = "SELECT u.rowid, u.login as ref, ".$this->db->pdate("datec")." as datec,"; - $sql.= $this->db->pdate("u.tms")." as date_modification"; + $sql.= $this->db->pdate("u.tms")." as date_modification, u.entity"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE u.rowid = ".$id; @@ -1718,6 +1723,7 @@ class User extends CommonObject $this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref; $this->date_creation = $obj->datec; $this->date_modification = $obj->date_modification; + $this->entity = $obj->entity; } $this->db->free($result); diff --git a/mysql/migration/2.5.0-2.6.0.sql b/mysql/migration/2.5.0-2.6.0.sql index 9b9a2e96c13..d66363cea92 100644 --- a/mysql/migration/2.5.0-2.6.0.sql +++ b/mysql/migration/2.5.0-2.6.0.sql @@ -125,6 +125,13 @@ 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_user ADD COLUMN entity varchar(20) DEFAULT 1 NOT NULL AFTER lang; +ALTER TABLE llx_usergroup ADD COLUMN entity varchar(20) DEFAULT 1 NOT NULL AFTER note; + ALTER TABLE llx_const DROP INDEX name; +ALTER TABLE llx_user DROP INDEX uk_user_login; +ALTER TABLE llx_usergroup DROP INDEX nom; ALTER TABLE llx_const ADD UNIQUE INDEX uk_const (name, entity); +ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login, entity); +ALTER TABLE llx_usergroup ADD UNIQUE INDEX uk_usergroup_name (nom, entity); diff --git a/mysql/tables/llx_user.key.sql b/mysql/tables/llx_user.key.sql index 5038dcd693c..367d45e8525 100644 --- a/mysql/tables/llx_user.key.sql +++ b/mysql/tables/llx_user.key.sql @@ -21,7 +21,7 @@ -- =========================================================================== -ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login); +ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login, entity); ALTER TABLE llx_user ADD INDEX uk_user_fk_societe (fk_societe); diff --git a/mysql/tables/llx_user.sql b/mysql/tables/llx_user.sql index d39b53a4702..735e64f4f82 100644 --- a/mysql/tables/llx_user.sql +++ b/mysql/tables/llx_user.sql @@ -1,7 +1,7 @@ -- ============================================================================ -- Copyright (C) 2001-2003 Rodolphe Quiedeville -- Copyright (C) 2006-2007 Laurent Destailleur --- Copyright (C) 2007 Regis Houssin +-- Copyright (C) 2007-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 @@ -50,5 +50,16 @@ create table llx_user egroupware_id integer, ldap_sid varchar(255) DEFAULT NULL, statut tinyint DEFAULT 1, - lang varchar(6) + lang varchar(6), + entity varchar(20) DEFAULT 1 NOT NULL -- multi company id )type=innodb; + +-- +-- List of codes for the field entity +-- +-- 0 : common user +-- 1 : first company user +-- 2 : second company user +-- 1,3 : first and third company user +-- etc... +-- \ No newline at end of file diff --git a/mysql/tables/llx_usergroup.key.sql b/mysql/tables/llx_usergroup.key.sql new file mode 100644 index 00000000000..0033bca36bc --- /dev/null +++ b/mysql/tables/llx_usergroup.key.sql @@ -0,0 +1,22 @@ +-- ============================================================================ +-- 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$ +-- ============================================================================ + + +ALTER TABLE llx_usergroup ADD UNIQUE INDEX uk_usergroup_name (nom, entity); diff --git a/mysql/tables/llx_usergroup.sql b/mysql/tables/llx_usergroup.sql index 4965e9e665e..73ac1bde599 100644 --- a/mysql/tables/llx_usergroup.sql +++ b/mysql/tables/llx_usergroup.sql @@ -1,6 +1,7 @@ -- ============================================================================ --- Copyright (C) 2005 Rodolphe Quiedeville --- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2005 Rodolphe Quiedeville +-- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2005-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 @@ -24,7 +25,17 @@ create table llx_usergroup rowid integer AUTO_INCREMENT PRIMARY KEY, datec datetime, tms timestamp, - nom varchar(255) NOT NULL UNIQUE, - note text - + nom varchar(255) NOT NULL, + note text, + entity varchar(20) DEFAULT 1 NOT NULL -- multi company id )type=innodb; + +-- +-- List of codes for the field entity +-- +-- 0 : common group +-- 1 : first company group +-- 2 : second company group +-- 1,3 : first and third company group +-- etc... +-- \ No newline at end of file