New: big refactorization of multicompany transverse mode

This commit is contained in:
Regis Houssin 2017-06-06 07:57:03 +02:00
parent 344263f53c
commit b66da3d148
39 changed files with 539 additions and 588 deletions

View File

@ -6,6 +6,7 @@ English Dolibarr ChangeLog
For developers: For developers:
NEW: Add a lot of API REST: dictionaryevents, memberstypes, ... NEW: Add a lot of API REST: dictionaryevents, memberstypes, ...
NEW: Big refactorization of multicompany transverse mode
WARNING: WARNING:
@ -21,6 +22,7 @@ Following changes may create regression for some external modules, but were nece
* Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used. * Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used.
* Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still * Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still
exists, but if an external module need action on it, it must provides itself its trigger file. exists, but if an external module need action on it, it must provides itself its trigger file.
* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode
***** ChangeLog for 5.0.3 compared to 5.0.2 ***** ***** ChangeLog for 5.0.3 compared to 5.0.2 *****
FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty

View File

@ -235,7 +235,7 @@ $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order,";
$sql.= " bd.rowid as boxid"; $sql.= " bd.rowid as boxid";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
$sql.= " WHERE b.box_id = bd.rowid"; $sql.= " WHERE b.box_id = bd.rowid";
$sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND b.entity IN (0,".$conf->entity.")";
$sql.= " AND b.fk_user=0"; $sql.= " AND b.fk_user=0";
$sql.= " ORDER by b.position, b.box_order"; $sql.= " ORDER by b.position, b.box_order";

View File

@ -131,7 +131,7 @@ print '<table class="noborder" width="100%">';
$sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault"; $sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
$sql.= " AND entity IN (".(! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND entity = ".$conf->entity;
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
$sql.= " ORDER BY r.module, r.id"; $sql.= " ORDER BY r.module, r.id";

View File

@ -324,14 +324,4 @@ $dolibarr_nocsrfcheck='0';
// External module // External module
//############################## //##############################
// multicompany_transverse_mode
// Prerequisite: Need external module "multicompany"
// Pyramidal (0): The rights and groups are managed in each entity. Each user belongs to the entity he was created into.
// Transversal (1): The user is created and managed only into master entity but can login to all entities if he is admmin
// of entity or belongs to at least one user group created into entity.
// Default value: 0 (pyramidal)
// Examples:
// $multicompany_transverse_mode='1';

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com> * Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Jean Heimburger <jean@tiaris.info> * Copyright (C) 2006 Jean Heimburger <jean@tiaris.info>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -132,14 +132,7 @@ class Conf
$sql = "SELECT ".$db->decrypt('name')." as name,"; $sql = "SELECT ".$db->decrypt('name')." as name,";
$sql.= " ".$db->decrypt('value')." as value, entity"; $sql.= " ".$db->decrypt('value')." as value, entity";
$sql.= " FROM ".MAIN_DB_PREFIX."const"; $sql.= " FROM ".MAIN_DB_PREFIX."const";
if (! empty($this->multicompany->transverse_mode))
{
$sql.= " WHERE entity IN (0,1,".$this->entity.")";
}
else
{
$sql.= " WHERE entity IN (0,".$this->entity.")"; $sql.= " WHERE entity IN (0,".$this->entity.")";
}
$sql.= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite. $sql.= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite.
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -1468,7 +1468,7 @@ class Form
} }
else else
{ {
if (! empty($conf->multicompany->transverse_mode)) if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " ON ug.fk_user = u.rowid"; $sql.= " ON ug.fk_user = u.rowid";
@ -1565,7 +1565,7 @@ class Form
$moreinfo++; $moreinfo++;
} }
} }
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{ {
if ($obj->admin && ! $obj->entity) if ($obj->admin && ! $obj->entity)
{ {
@ -6196,7 +6196,7 @@ class Form
$out.= '>'; $out.= '>';
$out.= $obj->name; $out.= $obj->name;
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)
{ {
$out.= " (".$obj->label.")"; $out.= " (".$obj->label.")";
} }

View File

@ -60,7 +60,7 @@ class InfoBox
$sql.= " d.rowid as box_id, d.file, d.note, d.tms"; $sql.= " d.rowid as box_id, d.file, d.note, d.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
$sql.= " WHERE b.box_id = d.rowid"; $sql.= " WHERE b.box_id = d.rowid";
$sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND b.entity IN (0,".$conf->entity.")";
if ($zone >= 0) $sql.= " AND b.position = ".$zone; if ($zone >= 0) $sql.= " AND b.position = ".$zone;
if (is_object($user)) $sql.= " AND b.fk_user IN (0,".$user->id.")"; if (is_object($user)) $sql.= " AND b.fk_user IN (0,".$user->id.")";
else $sql.= " AND b.fk_user = 0"; else $sql.= " AND b.fk_user = 0";
@ -70,7 +70,7 @@ class InfoBox
{ {
$sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d";
$sql.= " WHERE d.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " WHERE d.entity IN (0,".$conf->entity.")";
} }
dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG);

View File

@ -508,7 +508,7 @@ class Menubase
$sql = "SELECT m.rowid, m.type, m.module, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu, m.position"; $sql = "SELECT m.rowid, m.type, m.module, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu, m.position";
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; $sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql.= " WHERE m.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " WHERE m.entity IN (0,".$conf->entity.")";
$sql.= " AND m.menu_handler IN ('".$menu_handler."','all')"; $sql.= " AND m.menu_handler IN ('".$menu_handler."','all')";
if ($type_user == 0) $sql.= " AND m.usertype IN (0,2)"; if ($type_user == 0) $sql.= " AND m.usertype IN (0,2)";
if ($type_user == 1) $sql.= " AND m.usertype IN (1,2)"; if ($type_user == 1) $sql.= " AND m.usertype IN (1,2)";

View File

@ -1539,7 +1539,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
$sql = "SELECT nom as id, nom as lib, libelle as label, description as description"; $sql = "SELECT nom as id, nom as lib, libelle as label, description as description";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'"; $sql.= " WHERE type = '".$type."'";
$sql.= " AND entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND entity IN (0,".$conf->entity.")";
$sql.= " ORDER BY description DESC"; $sql.= " ORDER BY description DESC";
dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2010-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -238,8 +238,6 @@ function group_prepare_head($object)
return $head; return $head;
} }
/** /**
* Prepare array with list of tabs * Prepare array with list of tabs
* *
@ -283,32 +281,6 @@ function user_admin_prepare_head()
return $head; return $head;
} }
/**
* Prepare array with list of tabs
*
* @param Object $object Object related to tabs
* @param array $aEntities Entities array
* @return array Array of tabs
*/
function entity_prepare_head($object, $aEntities)
{
global $mc;
$head = array();
foreach($aEntities as $entity)
{
$mc->getInfo($entity);
$head[$entity][0] = $_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;entity='.$entity;
$head[$entity][1] = $mc->label;
$head[$entity][2] = $entity;
}
return $head;
}
/** /**
* Show list of themes. Show all thumbs of themes * Show list of themes. Show all thumbs of themes
* *
@ -782,4 +754,3 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print '</table>'; print '</table>';
} }

View File

@ -39,7 +39,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest=
// Force master entity in transversal mode // Force master entity in transversal mode
$entity=$entitytotest; $entity=$entitytotest;
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $entity=1; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1;
$login=''; $login='';

View File

@ -45,7 +45,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
// Force master entity in transversal mode // Force master entity in transversal mode
$entity=$entitytotest; $entity=$entitytotest;
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $entity=1; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1;
$login=''; $login='';
$resultFetchUser=''; $resultFetchUser='';

View File

@ -63,9 +63,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
-- Home - Menu users and groups -- Home - Menu users and groups
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 400__+MAX_llx_menu__, 'home', 'users', 1__+MAX_llx_menu__, '/user/home.php?leftmenu=users', 'MenuUsersAndGroups', 0, 'users', '', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 400__+MAX_llx_menu__, 'home', 'users', 1__+MAX_llx_menu__, '/user/home.php?leftmenu=users', 'MenuUsersAndGroups', 0, 'users', '', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 401__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/index.php?leftmenu=users', 'Users', 1, 'users', '$user->rights->user->user->lire || $user->admin', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 401__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/index.php?leftmenu=users', 'Users', 1, 'users', '$user->rights->user->user->lire || $user->admin', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 402__+MAX_llx_menu__, 'home', '', 401__+MAX_llx_menu__, '/user/card.php?leftmenu=users&amp;action=create', 'NewUser', 2, 'users', '$user->rights->user->user->creer || $user->admin', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 402__+MAX_llx_menu__, 'home', '', 401__+MAX_llx_menu__, '/user/card.php?leftmenu=users&amp;action=create', 'NewUser', 2, 'users', '($user->rights->user->user->creer || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 403__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/group/index.php?leftmenu=users', 'Groups', 1, 'users', '($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 403__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/group/index.php?leftmenu=users', 'Groups', 1, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 404__+MAX_llx_menu__, 'home', '', 403__+MAX_llx_menu__, '/user/group/card.php?leftmenu=users&amp;action=create', 'NewGroup', 2, 'users', '($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 404__+MAX_llx_menu__, 'home', '', 403__+MAX_llx_menu__, '/user/group/card.php?leftmenu=users&amp;action=create', 'NewGroup', 2, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__);
-- Third parties -- Third parties
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 501__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/card.php?action=create', 'MenuNewThirdParty', 1, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 501__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/card.php?action=create', 'MenuNewThirdParty', 1, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__);
@ -211,7 +211,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__);
-- Setup -- Setup
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__);

View File

@ -597,12 +597,12 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
if ($usemenuhider || empty($leftmenu) || $leftmenu=="users") if ($usemenuhider || empty($leftmenu) || $leftmenu=="users")
{ {
$newmenu->add("", $langs->trans("Users"), 1, $user->rights->user->user->lire || $user->admin); $newmenu->add("", $langs->trans("Users"), 1, $user->rights->user->user->lire || $user->admin);
$newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"),2, $user->rights->user->user->creer || $user->admin, '', 'home'); $newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"),2, ($user->rights->user->user->creer || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home');
$newmenu->add("/user/index.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin); $newmenu->add("/user/index.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin);
$newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, $user->rights->user->user->lire || $user->admin); $newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, $user->rights->user->user->lire || $user->admin);
$newmenu->add("", $langs->trans("Groups"), 1, $user->rights->user->user->lire || $user->admin); $newmenu->add("", $langs->trans("Groups"), 1, ($user->rights->user->user->lire || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
$newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, ($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin); $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
$newmenu->add("/user/group/index.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, ($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin); $newmenu->add("/user/group/index.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
} }
} }

View File

@ -156,9 +156,6 @@ if (empty($dolibarr_main_limit_users)) $dolibarr_main_limit_users=0;
if (empty($dolibarr_mailing_limit_sendbyweb)) $dolibarr_mailing_limit_sendbyweb=0; if (empty($dolibarr_mailing_limit_sendbyweb)) $dolibarr_mailing_limit_sendbyweb=0;
if (empty($dolibarr_mailing_limit_sendbycli)) $dolibarr_mailing_limit_sendbycli=0; if (empty($dolibarr_mailing_limit_sendbycli)) $dolibarr_mailing_limit_sendbycli=0;
if (empty($dolibarr_strict_mode)) $dolibarr_strict_mode=0; // For debug in php strict mode if (empty($dolibarr_strict_mode)) $dolibarr_strict_mode=0; // For debug in php strict mode
// TODO Multicompany Remove this. Useless.
if (empty($multicompany_transverse_mode)) $multicompany_transverse_mode=0;
if (empty($multicompany_force_entity)) $multicompany_force_entity=0; // To force entity in login page
// Security: CSRF protection // Security: CSRF protection
// This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST']) // This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST'])

View File

@ -1209,7 +1209,7 @@ class Holiday extends CommonObject
$sql = "SELECT u.rowid"; $sql = "SELECT u.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE (ug.fk_user = u.rowid"; $sql.= " WHERE (ug.fk_user = u.rowid";
@ -1305,7 +1305,7 @@ class Holiday extends CommonObject
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut"; $sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE (ug.fk_user = u.rowid"; $sql.= " WHERE (ug.fk_user = u.rowid";

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* *
@ -165,7 +165,7 @@ if (empty($user->societe_id))
DOL_DOCUMENT_ROOT."/contact/class/contact.class.php", DOL_DOCUMENT_ROOT."/contact/class/contact.class.php",
DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php", DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php",
DOL_DOCUMENT_ROOT."/product/class/product.class.php", DOL_DOCUMENT_ROOT."/product/class/product.class.php",
DOL_DOCUMENT_ROOT."/product/class/service.class.php", DOL_DOCUMENT_ROOT."/product/class/product.class.php",
DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php", DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php",
DOL_DOCUMENT_ROOT."/commande/class/commande.class.php", DOL_DOCUMENT_ROOT."/commande/class/commande.class.php",
DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php", DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",

View File

@ -379,3 +379,19 @@ create table llx_loan_schedule
fk_user_modif integer fk_user_modif integer
)ENGINE=innodb; )ENGINE=innodb;
ALTER TABLE llx_user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_user_rights DROP FOREIGN KEY fk_user_rights_fk_user_user;
ALTER TABLE llx_user_rights DROP INDEX uk_user_rights;
ALTER TABLE llx_user_rights DROP INDEX fk_user;
ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (entity, fk_user, fk_id);
ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
ALTER TABLE llx_usergroup_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_usergroup_rights DROP FOREIGN KEY fk_usergroup_rights_fk_usergroup;
ALTER TABLE llx_usergroup_rights DROP INDEX fk_usergroup;
ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id);
ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);

View File

@ -1,6 +1,7 @@
-- ============================================================================ -- ============================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
-- --
-- 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,7 +22,6 @@
-- Delete orphans -- Delete orphans
-- V4 DELETE llx_user_rights FROM llx_user_rights LEFT JOIN llx_user ON llx_user_rights.fk_user = llx_user.rowid WHERE llx_user.rowid IS NULL; -- V4 DELETE llx_user_rights FROM llx_user_rights LEFT JOIN llx_user ON llx_user_rights.fk_user = llx_user.rowid WHERE llx_user.rowid IS NULL;
ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (entity, fk_user, fk_id);
ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (fk_user, fk_id);

View File

@ -1,5 +1,6 @@
-- ============================================================================ -- ============================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
-- --
-- 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
@ -19,6 +20,7 @@
create table llx_user_rights create table llx_user_rights
( (
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_id integer NOT NULL fk_id integer NOT NULL
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -1,5 +1,6 @@
-- ============================================================================ -- ============================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
-- --
-- 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
@ -20,5 +21,6 @@
-- Supprime orhpelins pour permettre montee de la cle -- Supprime orhpelins pour permettre montee de la cle
-- V4 DELETE llx_usergroup_rights FROM llx_usergroup_rights LEFT JOIN llx_usergroup ON llx_usergroup_rights.fk_usergroup = llx_usergroup.rowid WHERE llx_usergroup.rowid IS NULL; -- V4 DELETE llx_usergroup_rights FROM llx_usergroup_rights LEFT JOIN llx_usergroup ON llx_usergroup_rights.fk_usergroup = llx_usergroup.rowid WHERE llx_usergroup.rowid IS NULL;
ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id);
ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid); ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);

View File

@ -1,5 +1,6 @@
-- ============================================================================ -- ============================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
-- --
-- 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
@ -19,9 +20,9 @@
create table llx_usergroup_rights create table llx_usergroup_rights
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
entity integer DEFAULT 1 NOT NULL, -- multi company id
fk_usergroup integer NOT NULL, fk_usergroup integer NOT NULL,
fk_id integer NOT NULL, fk_id integer NOT NULL
UNIQUE(fk_usergroup,fk_id)
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 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-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com> * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
* Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net> * Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
@ -98,11 +98,6 @@ if (! empty($dolibarr_main_document_root_alt))
} }
} }
// Set properties specific to multicompany
// TODO Multicompany Remove this. Useless. Var should be read when required.
$conf->multicompany->transverse_mode = empty($multicompany_transverse_mode)?'':$multicompany_transverse_mode; // Force Multi-Company transverse mode
$conf->multicompany->force_entity = empty($multicompany_force_entity)?'':(int) $multicompany_force_entity; // Force entity in login page
// Chargement des includes principaux de librairies communes // Chargement des includes principaux de librairies communes
if (! defined('NOREQUIREUSER')) require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; // Need 500ko memory if (! defined('NOREQUIREUSER')) require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; // Need 500ko memory
if (! defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php'; if (! defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php';
@ -170,10 +165,6 @@ if (! defined('NOREQUIREDB'))
{ {
$conf->entity = $_COOKIE['DOLENTITY']; $conf->entity = $_COOKIE['DOLENTITY'];
} }
else if (! empty($conf->multicompany->force_entity) && is_numeric($conf->multicompany->force_entity)) // To force entity in login page
{
$conf->entity = $conf->multicompany->force_entity;
}
// Sanitize entity // Sanitize entity
if (! is_numeric($conf->entity)) $conf->entity=1; if (! is_numeric($conf->entity)) $conf->entity=1;

View File

@ -110,7 +110,7 @@ if (empty($user->socid)) $fieldstosearchall["t.note_private"]="NotePrivate";
$arrayfields=array( $arrayfields=array(
't.field1'=>array('label'=>"Field1", 'checked'=>1), 't.field1'=>array('label'=>"Field1", 'checked'=>1),
't.field2'=>array('label'=>"Field2", 'checked'=>1), 't.field2'=>array('label'=>"Field2", 'checked'=>1),
//'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), //'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))),
't.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), 't.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500),
't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
//'t.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), //'t.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),

View File

@ -102,7 +102,7 @@ $arrayfields=array(
't.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>1), 't.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>1),
't.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>1), 't.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>1),
//'t.import_key'=>array('label'=>$langs->trans("ImportKey"), 'checked'=>1), //'t.import_key'=>array('label'=>$langs->trans("ImportKey"), 'checked'=>1),
//'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))),
//'t.fk_user_creat'=>array('label'=>$langs->trans("UserCreationShort"), 'checked'=>0, 'position'=>500), //'t.fk_user_creat'=>array('label'=>$langs->trans("UserCreationShort"), 'checked'=>0, 'position'=>500),
//'t.fk_user_modif'=>array('label'=>$langs->trans("UserModificationShort"), 'checked'=>0, 'position'=>500), //'t.fk_user_modif'=>array('label'=>$langs->trans("UserModificationShort"), 'checked'=>0, 'position'=>500),
't.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), 't.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500),

View File

@ -1695,7 +1695,7 @@ class Societe extends CommonObject
$sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo"; $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u";
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ((ug.fk_user = sc.fk_user"; $sql.= " WHERE ((ug.fk_user = sc.fk_user";

View File

@ -142,13 +142,13 @@ if (! empty($socid))
$sql = "SELECT DISTINCT u.rowid, u.login, u.fk_soc, u.lastname, u.firstname, u.statut, u.entity, u.photo"; $sql = "SELECT DISTINCT u.rowid, u.login, u.fk_soc, u.lastname, u.firstname, u.statut, u.entity, u.photo";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
} }
$sql .= " WHERE sc.fk_soc =".$object->id; $sql .= " WHERE sc.fk_soc =".$object->id;
$sql .= " AND sc.fk_user = u.rowid"; $sql .= " AND sc.fk_user = u.rowid";
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
$sql.= " AND ((ug.fk_user = sc.fk_user"; $sql.= " AND ((ug.fk_user = sc.fk_user";
$sql.= " AND ug.entity = ".$conf->entity.")"; $sql.= " AND ug.entity = ".$conf->entity.")";
@ -232,7 +232,7 @@ if (! empty($socid))
$sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.login, u.email, u.statut, u.fk_soc, u.photo"; $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.login, u.email, u.statut, u.fk_soc, u.photo";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ((ug.fk_user = u.rowid"; $sql.= " WHERE ((ug.fk_user = u.rowid";

View File

@ -3,7 +3,7 @@
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk> * Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com> * Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
@ -57,6 +57,12 @@ $subaction = GETPOST('subaction','alpha');
$group = GETPOST("group","int",3); $group = GETPOST("group","int",3);
$cancel = GETPOST('cancel'); $cancel = GETPOST('cancel');
// Users/Groups management only in master entity if transverse mode
if (($action == 'create' || $action == 'adduserldap') && ! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{
accessforbidden();
}
// Define value to know what current user can do on users // Define value to know what current user can do on users
$canadduser=(! empty($user->admin) || $user->rights->user->user->creer); $canadduser=(! empty($user->admin) || $user->rights->user->user->creer);
$canreaduser=(! empty($user->admin) || $user->rights->user->user->lire); $canreaduser=(! empty($user->admin) || $user->rights->user->user->lire);
@ -228,11 +234,11 @@ if (empty($reshook)) {
// Set entity property // Set entity property
$entity = GETPOST('entity', 'int'); $entity = GETPOST('entity', 'int');
if (!empty($conf->multicompany->enabled)) { if (! empty($conf->multicompany->enabled)) {
if (!empty($_POST["superadmin"])) { if (GETPOST('superadmin', 'int')) {
$object->entity = 0; $object->entity = 0;
} else { } else {
if ($conf->multicompany->transverse_mode) { if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$object->entity = 1; // all users are forced into master entity $object->entity = 1; // all users are forced into master entity
} else { } else {
$object->entity = ($entity == '' ? 1 : $entity); $object->entity = ($entity == '' ? 1 : $entity);
@ -249,8 +255,8 @@ if (empty($reshook)) {
$id = $object->create($user); $id = $object->create($user);
if ($id > 0) { if ($id > 0) {
if (isset($_POST['password']) && trim($_POST['password'])) { if (GETPOST('password')) {
$object->setPassword($user, trim($_POST['password'])); $object->setPassword($user, GETPOST('password'));
} }
if (! empty($conf->categorie->enabled)) { if (! empty($conf->categorie->enabled)) {
// Categories association // Categories association
@ -283,10 +289,10 @@ if (empty($reshook)) {
$object->fetch($id); $object->fetch($id);
if ($action == 'addgroup') { if ($action == 'addgroup') {
$object->SetInGroup($group, ($conf->multicompany->transverse_mode ? GETPOST("entity") : $editgroup->entity)); $object->SetInGroup($group, (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? GETPOST('entity', 'int') : $editgroup->entity));
} }
if ($action == 'removegroup') { if ($action == 'removegroup') {
$object->RemoveFromGroup($group, ($conf->multicompany->transverse_mode ? GETPOST("entity") : $editgroup->entity)); $object->RemoveFromGroup($group, (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? GETPOST('entity', 'int') : $editgroup->entity));
} }
if ($result > 0) { if ($result > 0) {
@ -367,7 +373,7 @@ if (empty($reshook)) {
{ {
$object->entity = 0; $object->entity = 0;
} }
else if ($conf->multicompany->transverse_mode) else if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
$object->entity = 1; // all users in master entity $object->entity = 1; // all users in master entity
} }
@ -409,7 +415,7 @@ if (empty($reshook)) {
} }
} }
if (!$error && isset($_POST['contactid'])) { if (!$error && GETPOST('contactid', 'int')) {
$contactid = GETPOST('contactid', 'int'); $contactid = GETPOST('contactid', 'int');
if ($contactid > 0) { if ($contactid > 0) {
@ -617,7 +623,7 @@ $formfile = new FormFile($db);
llxHeader('',$langs->trans("UserCard")); llxHeader('',$langs->trans("UserCard"));
if (($action == 'create') || ($action == 'adduserldap')) if ($action == 'create' || $action == 'adduserldap')
{ {
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
@ -858,7 +864,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
print '<td>'; print '<td>';
print $form->selectyesno('admin',GETPOST('admin'),1); print $form->selectyesno('admin',GETPOST('admin'),1);
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
@ -888,8 +894,8 @@ if (($action == 'create') || ($action == 'adduserldap'))
}); });
</script>'; </script>';
} }
$checked=($_POST["superadmin"]?' checked':''); $checked=(GETPOST('superadmin', 'int')?' checked':'');
$disabled=($_POST["superadmin"]?'':' disabled'); $disabled=(GETPOST('superadmin', 'int')?'':' disabled');
print '<input type="checkbox" name="superadmin" value="1"'.$checked.$disabled.' /> '.$langs->trans("SuperAdministrator"); print '<input type="checkbox" name="superadmin" value="1"'.$checked.$disabled.' /> '.$langs->trans("SuperAdministrator");
} }
print "</td></tr>\n"; print "</td></tr>\n";
@ -1005,9 +1011,9 @@ if (($action == 'create') || ($action == 'adduserldap'))
print '</td></tr>'; print '</td></tr>';
// Multicompany // Multicompany
if (! empty($conf->multicompany->enabled)) if (! empty($conf->multicompany->enabled) && is_object($mc))
{ {
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity && is_object($mc)) if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{ {
print "<tr>".'<td>'.$langs->trans("Entity").'</td>'; print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($conf->entity); print "<td>".$mc->select_entities($conf->entity);
@ -1226,7 +1232,7 @@ else
*/ */
if ($action == 'password') if ($action == 'password')
{ {
print $form->formconfirm("card.php?id=$object->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$object->login),"confirm_password", '', 0, 1); print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$object->login),"confirm_password", '', 0, 1);
} }
/* /*
@ -1234,7 +1240,7 @@ else
*/ */
if ($action == 'passwordsend') if ($action == 'passwordsend')
{ {
print $form->formconfirm("card.php?id=$object->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$object->login),"confirm_passwordsend", '', 0, 1); print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$object->login),"confirm_passwordsend", '', 0, 1);
} }
/* /*
@ -1242,7 +1248,7 @@ else
*/ */
if ($action == 'disable') if ($action == 'disable')
{ {
print $form->formconfirm("card.php?id=$object->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$object->login),"confirm_disable", '', 0, 1); print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$object->login),"confirm_disable", '', 0, 1);
} }
/* /*
@ -1250,7 +1256,7 @@ else
*/ */
if ($action == 'enable') if ($action == 'enable')
{ {
print $form->formconfirm("card.php?id=$object->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$object->login),"confirm_enable", '', 0, 1); print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$object->login),"confirm_enable", '', 0, 1);
} }
/* /*
@ -1258,7 +1264,7 @@ else
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
print $form->formconfirm("card.php?id=$object->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$object->login),"confirm_delete", '', 0, 1); print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$object->login),"confirm_delete", '', 0, 1);
} }
/* /*
@ -1476,26 +1482,6 @@ else
print '</td></tr>'; print '</td></tr>';
} }
// Multicompany
// TODO This should be done with hook formObjectOption
if (is_object($mc))
{
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
print '<tr><td>'.$langs->trans("Entity").'</td><td>';
if (empty($object->entity))
{
print $langs->trans("AllEntities");
}
else
{
$mc->getInfo($object->entity);
print $mc->label;
}
print "</td></tr>\n";
}
}
if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER))
{ {
print '<tr><td>'.$langs->trans("OpenIDURL").'</td>'; print '<tr><td>'.$langs->trans("OpenIDURL").'</td>';
@ -1514,6 +1500,7 @@ else
// Other attributes // Other attributes
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook) && ! empty($extrafields->attribute_label))
{ {
print $object->showOptionals($extrafields); print $object->showOptionals($extrafields);
@ -1524,23 +1511,23 @@ else
{ {
print '<tr><td>'.$langs->trans("LinkToCompanyContact").'</td>'; print '<tr><td>'.$langs->trans("LinkToCompanyContact").'</td>';
print '<td>'; print '<td>';
if (isset($object->societe_id) && $object->societe_id > 0) if (isset($object->socid) && $object->socid > 0)
{ {
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($object->societe_id); $societe->fetch($object->socid);
print $societe->getNomUrl(1,''); print $societe->getNomUrl(1,'');
} }
else else
{ {
print $langs->trans("ThisUserIsNot"); print $langs->trans("ThisUserIsNot");
} }
if (! empty($object->contact_id)) if (! empty($object->contactid))
{ {
$contact = new Contact($db); $contact = new Contact($db);
$contact->fetch($object->contact_id); $contact->fetch($object->contactid);
if ($object->societe_id > 0) print ' / '; if ($object->socid > 0) print ' / ';
else print '<br>'; else print '<br>';
print '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contact_id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>'; print '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contactid.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>';
} }
print '</td>'; print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
@ -1599,7 +1586,7 @@ else
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans('SendMail').'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans('SendMail').'</a></div>';
} }
if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
{ {
if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED))
{ {
@ -1611,7 +1598,7 @@ else
} }
} }
elseif ($caneditpassword && ! $object->ldap_sid && elseif ($caneditpassword && ! $object->ldap_sid &&
(empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("EditPassword").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("EditPassword").'</a></div>';
} }
@ -1624,7 +1611,7 @@ else
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("ReinitPassword").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("ReinitPassword").'</a></div>';
} }
elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=password">'.$langs->trans("ReinitPassword").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=password">'.$langs->trans("ReinitPassword").'</a></div>';
} }
@ -1634,7 +1621,7 @@ else
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("SendNewPassword").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("SendNewPassword").'</a></div>';
} }
else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
{ {
if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=passwordsend">'.$langs->trans("SendNewPassword").'</a></div>'; if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=passwordsend">'.$langs->trans("SendNewPassword").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendNewPassword").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendNewPassword").'</a></div>';
@ -1643,19 +1630,19 @@ else
// Activer // Activer
if ($user->id <> $id && $candisableuser && $object->statut == 0 && if ($user->id <> $id && $candisableuser && $object->statut == 0 &&
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=enable">'.$langs->trans("Reactivate").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=enable">'.$langs->trans("Reactivate").'</a></div>';
} }
// Desactiver // Desactiver
if ($user->id <> $id && $candisableuser && $object->statut == 1 && if ($user->id <> $id && $candisableuser && $object->statut == 1 &&
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=disable&amp;id='.$object->id.'">'.$langs->trans("DisableUser").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=disable&amp;id='.$object->id.'">'.$langs->trans("DisableUser").'</a></div>';
} }
// Delete // Delete
if ($user->id <> $id && $candisableuser && if ($user->id <> $id && $candisableuser &&
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
{ {
if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin
{ {
@ -1796,7 +1783,7 @@ else
if (! empty($groupslist)) if (! empty($groupslist))
{ {
if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))) if (! (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)))
{ {
foreach($groupslist as $groupforuser) foreach($groupslist as $groupforuser)
{ {
@ -1814,19 +1801,26 @@ else
print '<table class="noborder" width="100%">'."\n"; print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><th class="liste_titre" width="25%">'.$langs->trans("Groups").'</th>'."\n"; print '<tr class="liste_titre"><th class="liste_titre" width="25%">'.$langs->trans("Groups").'</th>'."\n";
if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{ {
print '<td class="liste_titre" width="25%">'.$langs->trans("Entity").'</td>'; print '<td class="liste_titre" width="25%">'.$langs->trans("Entity").'</td>';
} }
print '<th align="right">'; print '<th align="right">';
if ($caneditgroup) if ($caneditgroup)
{
// Users/Groups management only in master entity if transverse mode
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{
// nothing
}
else
{ {
print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity);
print ' &nbsp; '; print ' &nbsp; ';
// Multicompany // Multicompany
if (! empty($conf->multicompany->enabled)) if (! empty($conf->multicompany->enabled))
{ {
if ($conf->entity == 1 && $conf->multicompany->transverse_mode) if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{ {
print '</td><td>'.$langs->trans("Entity").'</td>'; print '</td><td>'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($conf->entity); print "<td>".$mc->select_entities($conf->entity);
@ -1842,6 +1836,7 @@ else
} }
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />';
} }
}
print '</th></tr>'."\n"; print '</th></tr>'."\n";
/* /*
@ -1864,7 +1859,7 @@ else
print img_object($langs->trans("ShowGroup"),"group").' '.$group->name; print img_object($langs->trans("ShowGroup"),"group").' '.$group->name;
} }
print '</td>'; print '</td>';
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{ {
print '<td class="valeur">'; print '<td class="valeur">';
if (! empty($group->usergroup_entity)) if (! empty($group->usergroup_entity))
@ -1882,7 +1877,7 @@ else
} }
} }
print '<td align="right">'; print '<td align="right">';
if ($caneditgroup && empty($conf->multicompany->transverse_mode)) if ($caneditgroup && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=removegroup&amp;group='.$group->id.'">'; print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=removegroup&amp;group='.$group->id.'">';
print img_delete($langs->trans("RemoveFromGroup")); print img_delete($langs->trans("RemoveFromGroup"));
@ -2042,7 +2037,7 @@ else
// Administrator // Administrator
print '<tr><td>'.$langs->trans("Administrator").'</td>'; print '<tr><td>'.$langs->trans("Administrator").'</td>';
if ($object->societe_id > 0) if ($object->socid > 0)
{ {
$langs->load("admin"); $langs->load("admin");
print '<td>'; print '<td>';
@ -2067,7 +2062,7 @@ else
{ {
print $form->selectyesno('admin',$object->admin,1); print $form->selectyesno('admin',$object->admin,1);
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
@ -2129,7 +2124,7 @@ else
if ($user->id == $object->id || ! $user->admin) if ($user->id == $object->id || ! $user->admin)
{ {
$type=$langs->trans("Internal"); $type=$langs->trans("Internal");
if ($object->societe_id) $type=$langs->trans("External"); if ($object->socid) $type=$langs->trans("External");
print $form->textwithpicto($type,$langs->trans("InternalExternalDesc")); print $form->textwithpicto($type,$langs->trans("InternalExternalDesc"));
if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')';
} }
@ -2390,16 +2385,16 @@ else
{ {
print '<tr><td width="25%">'.$langs->trans("LinkToCompanyContact").'</td>'; print '<tr><td width="25%">'.$langs->trans("LinkToCompanyContact").'</td>';
print '<td>'; print '<td>';
if ($object->societe_id > 0) if ($object->socid > 0)
{ {
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($object->societe_id); $societe->fetch($object->socid);
print $societe->getNomUrl(1,''); print $societe->getNomUrl(1,'');
if ($object->contact_id) if ($object->contactid)
{ {
$contact = new Contact($db); $contact = new Contact($db);
$contact->fetch($object->contact_id); $contact->fetch($object->contactid);
print ' / <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contact_id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>'; print ' / <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contactid.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>';
} }
} }
else else
@ -2432,25 +2427,10 @@ else
print "</tr>\n"; print "</tr>\n";
} }
// Multicompany
// TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !!
if (! empty($conf->multicompany->enabled) && is_object($mc))
{
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($object->entity, 'entity', '', 0, 1); // last parameter 1 means, show also a choice 0=>'all entities'
print "</td></tr>\n";
}
else
{
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
}
// Other attributes // Other attributes
$parameters=array('colspan' => ' colspan="2"'); $parameters=array('colspan' => ' colspan="2"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook) && ! empty($extrafields->attribute_label))
{ {
print $object->showOptionals($extrafields,'edit'); print $object->showOptionals($extrafields,'edit');
@ -2496,7 +2476,8 @@ else
$genallowed = $user->rights->user->user->creer; $genallowed = $user->rights->user->user->creer;
$delallowed = $user->rights->user->user->supprimer; $delallowed = $user->rights->user->user->supprimer;
$somethingshown = $formfile->show_documents('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); print $formfile->showdocuments('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
$somethingshown = $formfile->numoffiles;
// Show links to link elements // Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, null); $linktoelem = $form->showLinkToObjectBlock($object, null, null);

View File

@ -207,7 +207,7 @@ class User extends CommonObject
if ($entity < 0) if ($entity < 0)
{ {
if ((empty($conf->multicompany->enabled) || empty($conf->multicompany->transverse_mode)) && (! empty($user->entity))) if ((empty($conf->multicompany->enabled) || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) && (! empty($user->entity)))
{ {
$sql.= " WHERE u.entity IN (0,".$conf->entity.")"; $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
} }
@ -218,7 +218,7 @@ class User extends CommonObject
} }
else // The fetch was forced on an entity else // The fetch was forced on an entity
{ {
if (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode)) if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
else else
$sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; $sql.= " WHERE u.entity IN (0, ".$conf->entity.")";
@ -469,9 +469,9 @@ class User extends CommonObject
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$nid = $obj->id; $nid = $obj->id;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id." AND fk_id=".$nid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id." AND fk_id=".$nid." AND entity = ".$entity;
if (! $this->db->query($sql)) $error++; if (! $this->db->query($sql)) $error++;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (fk_user, fk_id) VALUES (".$this->id.", ".$nid.")"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (entity, fk_user, fk_id) VALUES (".$entity.", ".$this->id.", ".$nid.")";
if (! $this->db->query($sql)) $error++; if (! $this->db->query($sql)) $error++;
$i++; $i++;
@ -581,6 +581,7 @@ class User extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights";
$sql.= " WHERE fk_user = ".$this->id." AND fk_id=".$nid; $sql.= " WHERE fk_user = ".$this->id." AND fk_id=".$nid;
$sql.= " AND entity = ".$entity;
if (! $this->db->query($sql)) $error++; if (! $this->db->query($sql)) $error++;
$i++; $i++;
@ -660,7 +661,7 @@ class User extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur";
$sql.= ", ".MAIN_DB_PREFIX."rights_def as r"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.id = ur.fk_id"; $sql.= " WHERE r.id = ur.fk_id";
$sql.= " AND r.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND ur.entity = ".$conf->entity;
$sql.= " AND ur.fk_user= ".$this->id; $sql.= " AND ur.fk_user= ".$this->id;
$sql.= " AND r.perms IS NOT NULL"; $sql.= " AND r.perms IS NOT NULL";
if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'"; if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'";
@ -706,11 +707,8 @@ class User extends CommonObject
$sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,"; $sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,";
$sql.= " ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.id = gr.fk_id"; $sql.= " WHERE r.id = gr.fk_id";
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) { $sql.= " AND gr.entity = ".$conf->entity;
$sql.= " AND gu.entity IN (0,".$conf->entity.")";
} else {
$sql.= " AND r.entity = ".$conf->entity; $sql.= " AND r.entity = ".$conf->entity;
}
$sql.= " AND gr.fk_usergroup = gu.fk_usergroup"; $sql.= " AND gr.fk_usergroup = gu.fk_usergroup";
$sql.= " AND gu.fk_user = ".$this->id; $sql.= " AND gu.fk_user = ".$this->id;
$sql.= " AND r.perms IS NOT NULL"; $sql.= " AND r.perms IS NOT NULL";
@ -2573,7 +2571,7 @@ class User extends CommonObject
// Init $this->users array // Init $this->users array
$sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity"; // Distinct reduce pb with old tables with duplicates $sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity"; // Distinct reduce pb with old tables with duplicates
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->multicompany->transverse_mode) || (! empty($user->admin) && empty($user->entity)))) if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) || (! empty($user->admin) && empty($user->entity))))
{ {
$sql.= " WHERE u.entity IS NOT NULL"; $sql.= " WHERE u.entity IS NOT NULL";
} }

View File

@ -255,13 +255,16 @@ class UserGroup extends CommonObject
* @param int $rid id du droit a ajouter * @param int $rid id du droit a ajouter
* @param string $allmodule Ajouter tous les droits du module allmodule * @param string $allmodule Ajouter tous les droits du module allmodule
* @param string $allperms Ajouter tous les droits du module allmodule, perms allperms * @param string $allperms Ajouter tous les droits du module allmodule, perms allperms
* @param int $entity Entity to use
* @return int > 0 if OK, < 0 if KO * @return int > 0 if OK, < 0 if KO
*/ */
function addrights($rid,$allmodule='',$allperms='') function addrights($rid, $allmodule='', $allperms='', $entity=0)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms"); $entity = (! empty($entity)?$entity:$conf->entity);
dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms, $entity");
$error=0; $error=0;
$whereforadd=''; $whereforadd='';
@ -274,7 +277,7 @@ class UserGroup extends CommonObject
$sql = "SELECT module, perms, subperms"; $sql = "SELECT module, perms, subperms";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE id = '".$this->db->escape($rid)."'"; $sql.= " WHERE id = '".$this->db->escape($rid)."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$entity;
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) { if ($result) {
@ -311,7 +314,7 @@ class UserGroup extends CommonObject
$sql = "SELECT id"; $sql = "SELECT id";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE $whereforadd"; $sql.= " WHERE $whereforadd";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$entity;
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
@ -323,9 +326,9 @@ class UserGroup extends CommonObject
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$nid = $obj->id; $nid = $obj->id;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = $this->id AND fk_id=".$nid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = $this->id AND fk_id=".$nid." AND entity = ".$entity;
if (! $this->db->query($sql)) $error++; if (! $this->db->query($sql)) $error++;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (fk_usergroup, fk_id) VALUES ($this->id, $nid)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (entity, fk_usergroup, fk_id) VALUES (".$entity.", ".$this->id.", ".$nid.")";
if (! $this->db->query($sql)) $error++; if (! $this->db->query($sql)) $error++;
$i++; $i++;
@ -366,15 +369,18 @@ class UserGroup extends CommonObject
* @param int $rid id du droit a retirer * @param int $rid id du droit a retirer
* @param string $allmodule Retirer tous les droits du module allmodule * @param string $allmodule Retirer tous les droits du module allmodule
* @param string $allperms Retirer tous les droits du module allmodule, perms allperms * @param string $allperms Retirer tous les droits du module allmodule, perms allperms
* @param int $entity Entity to use
* @return int > 0 if OK, < 0 if OK * @return int > 0 if OK, < 0 if OK
*/ */
function delrights($rid,$allmodule='',$allperms='') function delrights($rid, $allmodule='', $allperms='', $entity=0)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$error=0; $error=0;
$wherefordel=''; $wherefordel='';
$entity = (! empty($entity)?$entity:$conf->entity);
$this->db->begin(); $this->db->begin();
if (! empty($rid)) if (! empty($rid))
@ -384,7 +390,7 @@ class UserGroup extends CommonObject
$sql = "SELECT module, perms, subperms"; $sql = "SELECT module, perms, subperms";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE id = '".$this->db->escape($rid)."'"; $sql.= " WHERE id = '".$this->db->escape($rid)."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$entity;
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) { if ($result) {
@ -421,7 +427,7 @@ class UserGroup extends CommonObject
$sql = "SELECT id"; $sql = "SELECT id";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE $wherefordel"; $sql.= " WHERE $wherefordel";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$entity;
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
@ -435,6 +441,7 @@ class UserGroup extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights";
$sql.= " WHERE fk_usergroup = $this->id AND fk_id=".$nid; $sql.= " WHERE fk_usergroup = $this->id AND fk_id=".$nid;
$sql.= " AND entity = ".$entity;
if (! $this->db->query($sql)) $error++; if (! $this->db->query($sql)) $error++;
$i++; $i++;
@ -498,6 +505,7 @@ class UserGroup extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup_rights as u, ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_rights as u, ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.id = u.fk_id"; $sql.= " WHERE r.id = u.fk_id";
$sql.= " AND r.entity = ".$conf->entity; $sql.= " AND r.entity = ".$conf->entity;
$sql.= " AND u.entity = ".$conf->entity;
$sql.= " AND u.fk_usergroup = ".$this->id; $sql.= " AND u.fk_usergroup = ".$this->id;
$sql.= " AND r.perms IS NOT NULL"; $sql.= " AND r.perms IS NOT NULL";
if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'"; if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'";

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com> * Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* *
@ -54,7 +54,8 @@ $userid=GETPOST('user', 'int');
// Security check // Security check
$result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user'); $result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user');
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode) // Users/Groups management only in master entity if transverse mode
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{ {
accessforbidden(); accessforbidden();
} }
@ -105,7 +106,7 @@ if ($action == 'add')
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;
else $object->entity = $_POST["entity"]; else $object->entity = $_POST["entity"];
$db->begin(); $db->begin();
@ -148,8 +149,8 @@ if ($action == 'adduser' || $action =='removeuser')
$edituser = new User($db); $edituser = new User($db);
$edituser->fetch($userid); $edituser->fetch($userid);
if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,(! empty($conf->multicompany->transverse_mode)?GETPOST('entity','int'):$object->entity)); if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,(! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?GETPOST('entity','int'):$object->entity));
if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,(! empty($conf->multicompany->transverse_mode)?GETPOST('entity','int'):$object->entity)); if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,(! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?GETPOST('entity','int'):$object->entity));
if ($result > 0) if ($result > 0)
{ {
@ -188,7 +189,7 @@ if ($action == 'update')
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;
else $object->entity = $_POST["entity"]; else $object->entity = $_POST["entity"];
$ret=$object->update(); $ret=$object->update();
@ -250,7 +251,7 @@ if ($action == 'create')
// Multicompany // Multicompany
if (! empty($conf->multicompany->enabled) && is_object($mc)) if (! empty($conf->multicompany->enabled) && is_object($mc))
{ {
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{ {
print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>'; print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($conf->entity); print "<td>".$mc->select_entities($conf->entity);
@ -333,7 +334,7 @@ else
print "</td></tr>\n"; print "</td></tr>\n";
// Multicompany // Multicompany
if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{ {
$mc->getInfo($object->entity); $mc->getInfo($object->entity);
print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>'; print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>';
@ -386,7 +387,7 @@ else
if (! empty($object->members)) if (! empty($object->members))
{ {
if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))) if (! (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)))
{ {
foreach($object->members as $useringroup) foreach($object->members as $useringroup)
{ {
@ -408,7 +409,7 @@ else
// Multicompany // Multicompany
if (! empty($conf->multicompany->enabled) && is_object($mc)) if (! empty($conf->multicompany->enabled) && is_object($mc))
{ {
if ($conf->entity == 1 && $conf->multicompany->transverse_mode) if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{ {
print '</td><td class="tdtop">'.$langs->trans("Entity").'</td>'; print '</td><td class="tdtop">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($conf->entity); print "<td>".$mc->select_entities($conf->entity);
@ -458,7 +459,7 @@ else
print '</td>'; print '</td>';
print '<td>'.$useringroup->lastname.'</td>'; print '<td>'.$useringroup->lastname.'</td>';
print '<td>'.$useringroup->firstname.'</td>'; print '<td>'.$useringroup->firstname.'</td>';
if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{ {
print '<td class="valeur">'; print '<td class="valeur">';
if (! empty($useringroup->usergroup_entity)) if (! empty($useringroup->usergroup_entity))
@ -543,7 +544,7 @@ else
// Multicompany // Multicompany
if (! empty($conf->multicompany->enabled) && is_object($mc)) if (! empty($conf->multicompany->enabled) && is_object($mc))
{ {
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{ {
print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>'; print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($object->entity); print "<td>".$mc->select_entities($object->entity);

View File

@ -32,6 +32,12 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
accessforbidden(); accessforbidden();
} }
// Users/Groups management only in master entity if transverse mode
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{
accessforbidden();
}
$langs->load("users"); $langs->load("users");
$sall=GETPOST('sall', 'alphanohtml'); $sall=GETPOST('sall', 'alphanohtml');
@ -95,7 +101,7 @@ llxHeader();
$sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb"; $sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
{ {
$sql.= " WHERE g.entity IS NOT NULL"; $sql.= " WHERE g.entity IS NOT NULL";
} }
@ -160,7 +166,7 @@ if ($resql)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder);
//multicompany //multicompany
if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) if(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)
{ {
print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],"g.entity",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],"g.entity",$param,"",'align="center"',$sortfield,$sortorder);
} }
@ -182,7 +188,7 @@ if ($resql)
} }
print "</td>"; print "</td>";
//multicompany //multicompany
if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)
{ {
$mc->getInfo($obj->entity); $mc->getInfo($obj->entity);
print '<td align="center">'.$mc->label.'</td>'; print '<td align="center">'.$mc->label.'</td>';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2006-2017 Regis Houssin <regis.houssin@capnetworks.com>
* *
* 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
@ -33,6 +33,12 @@ $langs->load("companies");
$langs->load("ldap"); $langs->load("ldap");
$langs->load("users"); $langs->load("users");
// Users/Groups management only in master entity if transverse mode
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{
accessforbidden();
}
$canreadperms=true; $canreadperms=true;
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
{ {

View File

@ -3,7 +3,7 @@
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* *
* 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
@ -38,6 +38,12 @@ $confirm=GETPOST('confirm', 'alpha');
$module=GETPOST('module', 'alpha'); $module=GETPOST('module', 'alpha');
$rights=GETPOST('rights', 'int'); $rights=GETPOST('rights', 'int');
// Users/Groups management only in master entity if transverse mode
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{
accessforbidden();
}
// Defini si peux lire les permissions // Defini si peux lire les permissions
$canreadperms=($user->admin || $user->rights->user->user->lire); $canreadperms=($user->admin || $user->rights->user->user->lire);
// Defini si peux modifier les permissions // Defini si peux modifier les permissions
@ -53,22 +59,44 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
if (! $canreadperms) accessforbidden(); if (! $canreadperms) accessforbidden();
$object = new Usergroup($db);
$object->fetch($id);
$object->getrights();
$entity=$conf->entity;
if (! empty($conf->multicompany->enabled))
{
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
$entity=(GETPOST('entity','int') ? GETPOST('entity','int') : $conf->entity);
else
$entity=(! empty($object->entity) ? $object->entity : $conf->entity);
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('groupcard','globalcard'));
/** /**
* Actions * Actions
*/ */
if ($action == 'addrights' && $caneditperms) $parameters=array();
{ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
$editgroup = new Usergroup($db); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$result=$editgroup->fetch($id);
if ($result > 0) $editgroup->addrights($rights, $module);
}
if ($action == 'delrights' && $caneditperms) if (empty($reshook)) {
{ if ($action == 'addrights' && $caneditperms)
{
$editgroup = new Usergroup($db); $editgroup = new Usergroup($db);
$result=$editgroup->fetch($id); $result=$editgroup->fetch($id);
if ($result > 0) $editgroup->delrights($rights, $module); if ($result > 0) $editgroup->addrights($rights, $module, '', $entity);
}
if ($action == 'delrights' && $caneditperms)
{
$editgroup = new Usergroup($db);
$result=$editgroup->fetch($id);
if ($result > 0) $editgroup->delrights($rights, $module, '', $entity);
}
} }
@ -80,12 +108,8 @@ $form = new Form($db);
llxHeader('',$langs->trans("Permissions")); llxHeader('',$langs->trans("Permissions"));
if ($id) if ($object->id)
{ {
$object = new Usergroup($db);
$object->fetch($id);
$object->getrights();
/* /*
* Affichage onglets * Affichage onglets
*/ */
@ -127,7 +151,6 @@ if ($id)
// Load all permissions // Load all permissions
if ($objMod->rights_class) if ($objMod->rights_class)
{ {
$entity=((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : null);
$ret=$objMod->insert_permissions(0, $entity); $ret=$objMod->insert_permissions(0, $entity);
$modules[$objMod->rights_class]=$objMod; $modules[$objMod->rights_class]=$objMod;
} }
@ -140,32 +163,17 @@ if ($id)
$db->commit(); $db->commit();
// Lecture des droits groupes // Lecture des droits groupes
$permsgroup = array(); $permsgroupbyentity = array();
$sql = "SELECT r.id, r.libelle, r.module "; $sql = "SELECT DISTINCT r.id, r.libelle, r.module, gr.entity";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,";
$sql.= ", ".MAIN_DB_PREFIX."usergroup_rights as ugr"; $sql.= " ".MAIN_DB_PREFIX."usergroup_rights as gr";
$sql.= " WHERE ugr.fk_id = r.id"; $sql.= " WHERE gr.fk_id = r.id";
if(! empty($conf->multicompany->enabled)) $sql.= " AND gr.entity = ".$entity;
{ $sql.= " AND gr.fk_usergroup = ".$object->id;
if (empty($conf->multicompany->transverse_mode))
{
$sql.= " AND r.entity = ".$object->entity;
}
else
{
$sql.= " AND r.entity IN (0,1)";
}
}
else
{
$sql.= " AND r.entity IN (0,".$conf->entity.")";
}
$sql.= " AND ugr.fk_usergroup = ".$object->id;
dol_syslog("get user perms", LOG_DEBUG);
$result=$db->query($sql); $result=$db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
@ -173,7 +181,9 @@ if ($id)
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
array_push($permsgroup,$obj->id); if (! isset($permsgroupbyentity[$obj->entity]))
$permsgroupbyentity[$obj->entity] = array();
array_push($permsgroupbyentity[$obj->entity], $obj->id);
$i++; $i++;
} }
$db->free($result); $db->free($result);
@ -184,7 +194,6 @@ if ($id)
} }
dol_banner_tab($object,'id','',$user->rights->user->user->lire || $user->admin); dol_banner_tab($object,'id','',$user->rights->user->user->lire || $user->admin);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
@ -214,6 +223,10 @@ if ($id)
if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")); if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules"));
$parameters=array();
$reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>'; print '<td>'.$langs->trans("Module").'</td>';
@ -225,22 +238,7 @@ if ($id)
$sql = "SELECT r.id, r.libelle, r.module"; $sql = "SELECT r.id, r.libelle, r.module";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
if(! empty($conf->multicompany->enabled)) $sql.= " AND r.entity = " . $entity;
{
if (empty($conf->multicompany->transverse_mode))
{
$sql.= " AND r.entity = ".$object->entity;
}
else
{
$sql.= " AND r.entity IN (0,1)";
}
}
else
{
$sql.= " AND r.entity = ".$conf->entity;
}
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable
$sql.= " ORDER BY r.module, r.id"; $sql.= " ORDER BY r.module, r.id";
@ -279,9 +277,9 @@ if ($id)
print '<td class="nowrap">'.img_object('',$picto).' '.$objMod->getName(); print '<td class="nowrap">'.img_object('',$picto).' '.$objMod->getName();
print '<a name="'.$objMod->getName().'">&nbsp;</a></td>'; print '<a name="'.$objMod->getName().'">&nbsp;</a></td>';
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
print '<a title='.$langs->trans("All").' alt='.$langs->trans("All").' href="perms.php?id='.$object->id.'&amp;action=addrights&amp;module='.$obj->module.'#'.$objMod->getName().'">'.$langs->trans("All")."</a>"; print '<a title='.$langs->trans("All").' alt='.$langs->trans("All").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'#'.$objMod->getName().'">'.$langs->trans("All")."</a>";
print '/'; print '/';
print '<a title='.$langs->trans("None").' alt='.$langs->trans("None").' href="perms.php?id='.$object->id.'&amp;action=delrights&amp;module='.$obj->module.'#'.$objMod->getName().'">'.$langs->trans("None")."</a>"; print '<a title='.$langs->trans("None").' alt='.$langs->trans("None").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module='.$obj->module.'#'.$objMod->getName().'">'.$langs->trans("None")."</a>";
print '</td>'; print '</td>';
print '<td colspan="2">&nbsp;</td>'; print '<td colspan="2">&nbsp;</td>';
print '</tr>'; print '</tr>';
@ -293,12 +291,14 @@ if ($id)
// Module // Module
print '<td class="nowrap">'.img_object('',$picto).' '.$objMod->getName().'</td>'; print '<td class="nowrap">'.img_object('',$picto).' '.$objMod->getName().'</td>';
if (in_array($obj->id, $permsgroup)) if (is_array($permsgroupbyentity[$entity]))
{
if (in_array($obj->id, $permsgroupbyentity[$entity]))
{ {
// Own permission by group // Own permission by group
if ($caneditperms) if ($caneditperms)
{ {
print '<td align="center"><a class="reposition" href="perms.php?id='.$object->id.'&amp;action=delrights&amp;rights='.$obj->id.'">'.img_edit_remove($langs->trans("Remove")).'</a></td>'; print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_remove($langs->trans("Remove")).'</a></td>';
} }
print '<td align="center">'; print '<td align="center">';
print img_picto($langs->trans("Active"),'tick'); print img_picto($langs->trans("Active"),'tick');
@ -309,7 +309,17 @@ if ($id)
// Do not own permission // Do not own permission
if ($caneditperms) if ($caneditperms)
{ {
print '<td align="center"><a class="reposition" href="perms.php?id='.$object->id.'&amp;action=addrights&amp;rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>'; print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
}
print '<td>&nbsp</td>';
}
}
else
{
// Do not own permission
if ($caneditperms)
{
print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
} }
print '<td>&nbsp</td>'; print '<td>&nbsp</td>';
} }
@ -326,6 +336,10 @@ if ($id)
print '</div>'; print '</div>';
$parameters=array();
$reshook=$hookmanager->executeHooks('insertExtraFooter',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
dol_fiche_end(); dol_fiche_end();
} }

View File

@ -102,9 +102,7 @@ foreach($fulltree as $key => $val)
$entitystring=''; $entitystring='';
// TODO Set of entitystring should be done with a hook // TODO Set of entitystring should be done with a hook
if (is_object($mc)) if (! empty($conf->multicompany->enabled) && is_object($mc))
{
if (! empty($conf->multicompany->enabled))
{ {
if (empty($entity)) if (empty($entity))
{ {
@ -116,7 +114,6 @@ foreach($fulltree as $key => $val)
$entitystring=$mc->label; $entitystring=$mc->label;
} }
} }
}
$li=$userstatic->getNomUrl(-1,'',0,1); $li=$userstatic->getNomUrl(-1,'',0,1);
if (! empty($conf->multicompany->enabled) && $userstatic->admin && ! $userstatic->entity) if (! empty($conf->multicompany->enabled) && $userstatic->admin && ! $userstatic->entity)

View File

@ -100,7 +100,7 @@ $sql.= ", s.code_client";
$sql.= ", s.canvas"; $sql.= ", s.canvas";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
{ {
$sql.= " WHERE u.entity IS NOT NULL"; $sql.= " WHERE u.entity IS NOT NULL";
} }
@ -212,7 +212,7 @@ if ($canreadperms)
$sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec"; $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec";
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
{ {
$sql.= " WHERE g.entity IS NOT NULL"; $sql.= " WHERE g.entity IS NOT NULL";
} }

View File

@ -92,7 +92,7 @@ $arrayfields=array(
'u.accountancy_code'=>array('label'=>$langs->trans("AccountancyCode"), 'checked'=>0), 'u.accountancy_code'=>array('label'=>$langs->trans("AccountancyCode"), 'checked'=>0),
'u.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1), 'u.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1),
'u.fk_soc'=>array('label'=>$langs->trans("Company"), 'checked'=>1), 'u.fk_soc'=>array('label'=>$langs->trans("Company"), 'checked'=>1),
'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), 'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))),
'u.fk_user'=>array('label'=>$langs->trans("HierarchicalResponsible"), 'checked'=>1), 'u.fk_user'=>array('label'=>$langs->trans("HierarchicalResponsible"), 'checked'=>1),
'u.datelastlogin'=>array('label'=>$langs->trans("LastConnexion"), 'checked'=>1, 'position'=>100), 'u.datelastlogin'=>array('label'=>$langs->trans("LastConnexion"), 'checked'=>1, 'position'=>100),
'u.datepreviouslogin'=>array('label'=>$langs->trans("PreviousConnexion"), 'checked'=>0, 'position'=>110), 'u.datepreviouslogin'=>array('label'=>$langs->trans("PreviousConnexion"), 'checked'=>0, 'position'=>110),
@ -194,7 +194,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields as ef on (u.rowid = ef.fk_object)"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields as ef on (u.rowid = ef.fk_object)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid";
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->multicompany->transverse_mode) || (! empty($user->admin) && empty($user->entity)))) if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) || (! empty($user->admin) && empty($user->entity))))
{ {
$sql.= " WHERE u.entity IS NOT NULL"; $sql.= " WHERE u.entity IS NOT NULL";
} }
@ -545,7 +545,7 @@ while ($i < min($num,$limit))
print '</td>'; print '</td>';
} }
// Multicompany enabled // Multicompany enabled
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode)) if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
if (! empty($arrayfields['u.entity']['checked'])) if (! empty($arrayfields['u.entity']['checked']))
{ {
@ -555,14 +555,10 @@ while ($i < min($num,$limit))
print $langs->trans("AllEntities"); print $langs->trans("AllEntities");
} }
else else
{
// $mc is defined in conf.class.php if multicompany enabled.
if (is_object($mc))
{ {
$mc->getInfo($obj->entity); $mc->getInfo($obj->entity);
print $mc->label; print $mc->label;
} }
}
print '</td>'; print '</td>';
} }
} }
@ -581,7 +577,7 @@ while ($i < min($num,$limit))
$user2->photo=$obj->photo2; $user2->photo=$obj->photo2;
$user2->admin=$obj->admin2; $user2->admin=$obj->admin2;
$user2->email=$obj->email2; $user2->email=$obj->email2;
$user2->societe_id=$obj->fk_soc2; $user2->socid=$obj->fk_soc2;
print $user2->getNomUrl(-1,'',0,0,24,0,''); print $user2->getNomUrl(-1,'',0,0,24,0,'');
if (! empty($conf->multicompany->enabled) && $obj->admin2 && ! $obj->entity2) if (! empty($conf->multicompany->enabled) && $obj->admin2 && ! $obj->entity2)
{ {

View File

@ -3,7 +3,7 @@
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -38,7 +38,6 @@ $action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha'); $confirm=GETPOST('confirm', 'alpha');
$module=GETPOST('module', 'alpha'); $module=GETPOST('module', 'alpha');
$rights=GETPOST('rights', 'int'); $rights=GETPOST('rights', 'int');
$entity=(GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity);
if (! isset($id) || empty($id)) accessforbidden(); if (! isset($id) || empty($id)) accessforbidden();
@ -71,6 +70,15 @@ $object = new User($db);
$object->fetch($id, '', '', 1); $object->fetch($id, '', '', 1);
$object->getrights(); $object->getrights();
$entity=$conf->entity;
if (! empty($conf->multicompany->enabled))
{
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
$entity=(GETPOST('entity','int') ? GETPOST('entity','int') : $conf->entity);
else
$entity=(! empty($object->entity) ? $object->entity : $conf->entity);
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('usercard','globalcard')); $hookmanager->initHooks(array('usercard','globalcard'));
@ -86,12 +94,11 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) { if (empty($reshook)) {
if ($action == 'addrights' && $caneditperms) { if ($action == 'addrights' && $caneditperms) {
$edituser = new User($db); $edituser = new User($db);
$edituser->fetch($id); $edituser->fetch($object->id);
//$edituser->addrights($rights, $module, '', $entity); // TODO unused for the moment $edituser->addrights($rights, $module, '', $entity);
$edituser->addrights($rights, $module);
// Si on a touche a ses propres droits, on recharge // Si on a touche a ses propres droits, on recharge
if ($id == $user->id) { if ($object->id == $user->id) {
$user->clearrights(); $user->clearrights();
$user->getrights(); $user->getrights();
$menumanager->loadMenu(); $menumanager->loadMenu();
@ -100,12 +107,11 @@ if (empty($reshook)) {
if ($action == 'delrights' && $caneditperms) { if ($action == 'delrights' && $caneditperms) {
$edituser = new User($db); $edituser = new User($db);
$edituser->fetch($id); $edituser->fetch($object->id);
//$edituser->delrights($rights, $module, '', $entity); // TODO unused for the moment $edituser->delrights($rights, $module, '', $entity);
$edituser->delrights($rights, $module);
// Si on a touche a ses propres droits, on recharge // Si on a touche a ses propres droits, on recharge
if ($id == $user->id) { if ($object->id == $user->id) {
$user->clearrights(); $user->clearrights();
$user->getrights(); $user->getrights();
$menumanager->loadMenu(); $menumanager->loadMenu();
@ -161,8 +167,7 @@ foreach($modulesdir as $dir)
// Load all permissions // Load all permissions
if ($objMod->rights_class) if ($objMod->rights_class)
{ {
$forceEntity=((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : null); $ret=$objMod->insert_permissions(0, $entity);
$ret=$objMod->insert_permissions(0, $forceEntity);
$modules[$objMod->rights_class]=$objMod; $modules[$objMod->rights_class]=$objMod;
//print "modules[".$objMod->rights_class."]=$objMod;"; //print "modules[".$objMod->rights_class."]=$objMod;";
} }
@ -177,22 +182,11 @@ $db->commit();
// Lecture des droits utilisateurs // Lecture des droits utilisateurs
$permsuser = array(); $permsuser = array();
$sql = "SELECT r.id, r.libelle, r.module"; $sql = "SELECT DISTINCT r.id, r.libelle, r.module";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,";
$sql.= " ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= " ".MAIN_DB_PREFIX."user_rights as ur";
$sql.= " WHERE ur.fk_id = r.id"; $sql.= " WHERE ur.fk_id = r.id";
if (! empty($conf->multicompany->enabled)) $sql.= " AND ur.entity = ".$entity;
{
if (1==2 && ! empty($conf->multicompany->transverse_mode)) {
$sql.= " AND r.entity = ".(GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity); // TODO unused for the moment
} else {
$sql.= " AND r.entity = ".(! empty($object->entity) ? $object->entity : $conf->entity);
}
}
else
{
$sql.= " AND r.entity = ".$conf->entity;
}
$sql.= " AND ur.fk_user = ".$object->id; $sql.= " AND ur.fk_user = ".$object->id;
dol_syslog("get user perms", LOG_DEBUG); dol_syslog("get user perms", LOG_DEBUG);
@ -216,18 +210,13 @@ else
// Lecture des droits groupes // Lecture des droits groupes
$permsgroupbyentity = array(); $permsgroupbyentity = array();
$aEntities = array();
$sql = "SELECT r.id, r.libelle, r.module, gu.entity"; $sql = "SELECT DISTINCT r.id, r.libelle, r.module, gu.entity";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,";
$sql.= " ".MAIN_DB_PREFIX."usergroup_rights as gr,"; $sql.= " ".MAIN_DB_PREFIX."usergroup_rights as gr,";
$sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu"; $sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu";
$sql.= " WHERE gr.fk_id = r.id"; $sql.= " WHERE gr.fk_id = r.id";
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) { $sql.= " AND gr.entity = ".$entity;
$sql.= " AND gu.entity IS NOT NULL";
} else {
$sql.= " AND r.entity = ".((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : $conf->entity);
}
$sql.= " AND gr.fk_usergroup = gu.fk_usergroup"; $sql.= " AND gr.fk_usergroup = gu.fk_usergroup";
$sql.= " AND gu.fk_user = ".$object->id; $sql.= " AND gu.fk_user = ".$object->id;
@ -272,17 +261,10 @@ if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivat
// Show warning about external users // Show warning about external users
if (empty($user->societe_id)) print info_admin(showModulesExludedForExternal($modules))."\n"; if (empty($user->societe_id)) print info_admin(showModulesExludedForExternal($modules))."\n";
// For multicompany transversal mode $parameters=array('permsgroupbyentity'=>$permsgroupbyentity);
// TODO Place a hook here $reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
{
$aEntities=array_keys($permsgroupbyentity);
sort($aEntities);
$entity = (GETPOST('entity', 'int')?GETPOST('entity', 'int'):$aEntities[0]);
$head = entity_prepare_head($object, $aEntities);
$title = $langs->trans("Entities");
dol_fiche_head($head, $entity, $title, 1, 'multicompany@multicompany');
}
print "\n"; print "\n";
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
@ -297,7 +279,7 @@ print '</tr>'."\n";
$sql = "SELECT r.id, r.libelle, r.module"; $sql = "SELECT r.id, r.libelle, r.module";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
$sql.= " AND r.entity = ".((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : $conf->entity); $sql.= " AND r.entity = " . $entity;
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable
$sql.= " ORDER BY r.module, r.id"; $sql.= " ORDER BY r.module, r.id";
@ -336,9 +318,9 @@ if ($result)
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'.img_object('',$picto).' '.$objMod->getName(); print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'.img_object('',$picto).' '.$objMod->getName();
print '<a name="'.$objMod->getName().'"></a></td>'; print '<a name="'.$objMod->getName().'"></a></td>';
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="perms.php?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("All")."</a>"; print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("All")."</a>";
print '/'; print '/';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="perms.php?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("None")."</a>"; print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("None")."</a>";
print '</td>'; print '</td>';
print '<td colspan="2">&nbsp;</td>'; print '<td colspan="2">&nbsp;</td>';
print '</tr>'."\n"; print '</tr>'."\n";
@ -365,7 +347,7 @@ if ($result)
{ {
if ($caneditperms) if ($caneditperms)
{ {
print '<td align="center"><a class="reposition" href="perms.php?id='.$object->id.'&amp;action=delrights&amp;rights='.$obj->id.'">'.img_edit_remove($langs->trans("Remove")).'</a></td>'; print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_remove($langs->trans("Remove")).'</a></td>';
} }
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
print img_picto($langs->trans("Active"),'tick'); print img_picto($langs->trans("Active"),'tick');
@ -391,7 +373,7 @@ if ($result)
// Do not own permission // Do not own permission
if ($caneditperms) if ($caneditperms)
{ {
print '<td align="center"><a class="reposition" href="perms.php?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>'; print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
} }
print '<td>&nbsp</td>'; print '<td>&nbsp</td>';
} }
@ -401,7 +383,7 @@ if ($result)
// Do not own permission // Do not own permission
if ($caneditperms) if ($caneditperms)
{ {
print '<td align="center"><a class="reposition" href="perms.php?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>'; print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
} }
print '<td>&nbsp</td>'; print '<td>&nbsp</td>';
} }
@ -417,13 +399,10 @@ if ($result)
else dol_print_error($db); else dol_print_error($db);
print '</table>'; print '</table>';
$parameters=array();
$reshook=$hookmanager->executeHooks('insertExtraFooter',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// For multicompany transversal mode
// TODO Place a hook here
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
{
dol_fiche_end();
}
dol_fiche_end(); dol_fiche_end();

View File

@ -416,7 +416,7 @@ function getListOfGroups($authentication)
$sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb"; $sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
{ {
$sql.= " WHERE g.entity IS NOT NULL"; $sql.= " WHERE g.entity IS NOT NULL";
} }