Skip to content
Snippets Groups Projects
Commit 1f0ff52e authored by Regis Houssin's avatar Regis Houssin
Browse files

(Multi-Company) Works on possibility to defined global group

parent 781e806c
No related branches found
No related tags found
No related merge requests found
...@@ -105,6 +105,12 @@ ALTER TABLE llx_facturedet ADD INDEX idx_facturedet_fk_product (fk_product); ...@@ -105,6 +105,12 @@ ALTER TABLE llx_facturedet ADD INDEX idx_facturedet_fk_product (fk_product);
ALTER TABLE llx_mailing_cibles ADD COLUMN tag varchar(128) NULL AFTER other; ALTER TABLE llx_mailing_cibles ADD COLUMN tag varchar(128) NULL AFTER other;
ALTER TABLE llx_mailing ADD COLUMN tag varchar(128) NULL AFTER email_errorsto; ALTER TABLE llx_mailing ADD COLUMN tag varchar(128) NULL AFTER email_errorsto;
ALTER TABLE llx_usergroup_user DROP INDEX fk_user;
ALTER TABLE llx_usergroup_user ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_usergroup_user ADD UNIQUE INDEX uk_usergroup_entity (entity,fk_user,fk_usergroup);
ALTER TABLE llx_usergroup_user ADD CONSTRAINT fk_usergroup_user_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
ALTER TABLE llx_usergroup_user ADD CONSTRAINT fk_usergroup_user_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);
--Add Chile data (id pays=67) --Add Chile data (id pays=67)
-- Regions Chile -- Regions Chile
INSERT INTO llx_c_regions (rowid, code_region, fk_pays, cheflieu, tncc, nom, active) VALUES (6701, 6701, 67, NULL, NULL, 'Tarapacá', 1); INSERT INTO llx_c_regions (rowid, code_region, fk_pays, cheflieu, tncc, nom, active) VALUES (6701, 6701, 67, NULL, NULL, 'Tarapacá', 1);
......
-- ============================================================================
-- Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
--
-- 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_user ADD UNIQUE INDEX uk_user_group_entity (entity,fk_user,fk_usergroup);
ALTER TABLE llx_usergroup_user ADD CONSTRAINT fk_usergroup_user_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
ALTER TABLE llx_usergroup_user ADD CONSTRAINT fk_usergroup_user_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);
-- ============================================================================ -- ============================================================================
-- Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by
...@@ -21,8 +22,8 @@ ...@@ -21,8 +22,8 @@
create table llx_usergroup_user create table llx_usergroup_user
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
entity integer DEFAULT 1 NOT NULL, -- multi company id
fk_user integer NOT NULL, fk_user integer NOT NULL,
fk_usergroup integer NOT NULL, fk_usergroup integer NOT NULL
UNIQUE(fk_user,fk_usergroup)
)ENGINE=innodb; )ENGINE=innodb;
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Copyright (c) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (c) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk> * Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -1465,34 +1465,38 @@ class User extends CommonObject ...@@ -1465,34 +1465,38 @@ class User extends CommonObject
/** /**
* \brief Add user into a group * Add user into a group
* \param group id du groupe * @param group id du groupe
*/ */
function SetInGroup($group) function SetInGroup($group)
{ {
global $conf;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
$sql.= " WHERE fk_user = ".$this->id; $sql.= " WHERE fk_user = ".$this->id;
$sql.= " AND fk_usergroup = ".$group; $sql.= " AND fk_usergroup = ".$group;
$sql.= " AND entity = ".$conf->entity;
$result = $this->db->query($sql); $result = $this->db->query($sql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_user (fk_user, fk_usergroup)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_user (entity, fk_user, fk_usergroup)";
$sql .= " VALUES (".$this->id.",".$group.")"; $sql.= " VALUES (".$conf->entity.",".$this->id.",".$group.")";
$result = $this->db->query($sql); $result = $this->db->query($sql);
} }
/** /**
* \brief Remove a user from a group * Remove a user from a group
* \param group id du groupe * @param group id du groupe
*/ */
function RemoveFromGroup($group) function RemoveFromGroup($group)
{ {
global $conf;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
$sql.= " WHERE fk_user = ".$this->id; $sql.= " WHERE fk_user = ".$this->id;
$sql.= " AND fk_usergroup = ".$group; $sql.= " AND fk_usergroup = ".$group;
$sql.= " AND entity = ".$conf->entity;
$result = $this->db->query($sql); $result = $this->db->query($sql);
} }
......
<?php <?php
/* Copyright (c) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (c) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (c) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (c) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -494,7 +495,7 @@ class UserGroup extends CommonObject ...@@ -494,7 +495,7 @@ class UserGroup extends CommonObject
$now=dol_now(); $now=dol_now();
$sql = "INSERT into ".MAIN_DB_PREFIX."usergroup (datec, nom, entity)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup (datec, nom, entity)";
$sql.= " VALUES('".$this->db->idate($now)."','".$this->db->escape($this->nom)."',".$conf->entity.")"; $sql.= " VALUES('".$this->db->idate($now)."','".$this->db->escape($this->nom)."',".$conf->entity.")";
dol_syslog("UserGroup::Create sql=".$sql, LOG_DEBUG); dol_syslog("UserGroup::Create sql=".$sql, LOG_DEBUG);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment