diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index db8ceff7e61..e758e8fbc7d 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -31,7 +31,7 @@
* \file htdocs/core/class/html.form.class.php
* \ingroup core
* \brief File of class with all html predefined components
- * \version $Id: html.form.class.php,v 1.198 2011/08/19 09:26:41 hregis Exp $
+ * \version $Id: html.form.class.php,v 1.199 2011/08/19 22:15:22 hregis Exp $
*/
@@ -794,17 +794,21 @@ class Form
$out='';
// On recherche les utilisateurs
- $sql = "SELECT u.rowid, u.name, u.firstname, u.login, u.admin";
- if($conf->entity==0)
- $sql.=" ,e.label";
- $sql.= " FROM ".MAIN_DB_PREFIX ."user as u";
- if($conf->entity==0)
+ $sql = "SELECT u.rowid, u.name, u.firstname, u.login, u.admin, u.entity";
+ if($conf->multicompany->enabled && $conf->entity == 1 && $user->admin && ! $user->entity)
{
- $sql.=" LEFT JOIN ".MAIN_DB_PREFIX ."entity as e on e.rowid=u.entity";
- $sql.=" WHERE u.entity IS NOT NULL";
+ $sql.= ", e.label";
+ }
+ $sql.= " FROM ".MAIN_DB_PREFIX ."user as u";
+ if($conf->multicompany->enabled && $conf->entity == 1 && $user->admin && ! $user->entity)
+ {
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."entity as e on e.rowid=u.entity";
+ $sql.= " WHERE u.entity IS NOT NULL";
}
else
- $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
+ {
+ $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
+ }
if (is_array($exclude) && $excludeUsers) $sql.= " AND u.rowid NOT IN ('".$excludeUsers."')";
if (is_array($include) && $includeUsers) $sql.= " AND u.rowid IN ('".$includeUsers."')";
$sql.= " ORDER BY u.name ASC";
@@ -845,8 +849,12 @@ class Form
$out.= '>';
}
$out.= $userstatic->getFullName($langs);
- if($conf->entity==0 && !$conf->global->MULTICOMPANY_TRANSVERSE_MODE)
- $out.=" (".$obj->label.")";
+
+ if($conf->multicompany->enabled && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
+ {
+ if ($obj->admin && ! $obj->entity) $out.=" (".$langs->trans("AllEntities").")";
+ else $out.=" (".$obj->label.")";
+ }
//if ($obj->admin) $out.= ' *';
if ($conf->global->MAIN_SHOW_LOGIN) $out.= ' ('.$obj->login.')';
@@ -3515,17 +3523,21 @@ class Form
// On recherche les groupes
$sql = "SELECT ug.rowid, ug.nom ";
- if($conf->entity==0)
- $sql.= ", e.label";
+ if($conf->multicompany->enabled && $conf->entity == 1)
+ {
+ $sql.= ", e.label";
+ }
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as ug ";
- if($conf->entity==0)
+ if($conf->multicompany->enabled && $conf->entity == 1)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e on e.rowid=ug.entity";
$sql.= " WHERE ug.entity IS NOT NULL";
}
else
- $sql.= " WHERE ug.entity IN (0,".$conf->entity.")";
- if (is_array($exclude) && $excludeGroups) $sql.= " AND ug.rowid NOT IN ('".$excludeGroups."')";
+ {
+ $sql.= " WHERE ug.entity IN (0,".$conf->entity.")";
+ }
+ if (is_array($exclude) && $excludeGroups) $sql.= " AND ug.rowid NOT IN ('".$excludeGroups."')";
if (is_array($include) && $includeGroups) $sql.= " AND ug.rowid IN ('".$includeGroups."')";
$sql.= " ORDER BY ug.nom ASC";
@@ -3554,8 +3566,10 @@ class Form
$out.= '>';
$out.= $obj->nom;
- if($conf->entity==0 && !$conf->global->MULTICOMPANY_TRANSVERSE_MODE)
- $out.= " (".$obj->label.")";
+ if($conf->multicompany->enabled && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)
+ {
+ $out.= " (".$obj->label.")";
+ }
$out.= '';
$i++;
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index 764fa4bf276..426d8d3d41c 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -28,7 +28,7 @@
* \file htdocs/lib/functions.lib.php
* \brief A set of functions for Dolibarr
* This file contains all frequently used functions.
- * \version $Id: functions.lib.php,v 1.558 2011/08/17 16:33:53 eldy Exp $
+ * \version $Id: functions.lib.php,v 1.559 2011/08/19 22:15:22 hregis Exp $
*/
// For compatibility during upgrade
@@ -2224,7 +2224,14 @@ function restrictedArea($user, $features='societe', $objectid=0, $dbtablename=''
$sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
- $sql.= " AND dbt.entity IN (0,".(! empty($conf->entities[$dbtablename]) ? $conf->entities[$dbtablename] : $conf->entity).")";
+ if (($feature == 'user' || $feature == 'usergroup') && $conf->multicompany->enabled && $conf->entity == 1 && $user->admin && ! $user->entity)
+ {
+ $sql.= " AND dbt.entity IS NOT NULL";
+ }
+ else
+ {
+ $sql.= " AND dbt.entity IN (0,".(! empty($conf->entities[$dbtablename]) ? $conf->entities[$dbtablename] : $conf->entity).")";
+ }
}
else if (in_array($feature,$checksoc))
{
@@ -2245,7 +2252,7 @@ function restrictedArea($user, $features='societe', $objectid=0, $dbtablename=''
$sql.= " AND s.entity IN (0,".(! empty($conf->entities[$dbtablename]) ? $conf->entities[$dbtablename] : $conf->entity).")";
}
// If multicompany and internal users with all permissions, check user is in correct entity
- else if ($conf->global->MAIN_MODULE_MULTICOMPANY)
+ else if ($conf->multicompany->enabled)
{
$sql = "SELECT s.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
@@ -2274,7 +2281,7 @@ function restrictedArea($user, $features='societe', $objectid=0, $dbtablename=''
$sql.= " AND dbt.entity IN (0,".(! empty($conf->entities[$dbtablename]) ? $conf->entities[$dbtablename] : $conf->entity).")";
}
// If multicompany and internal users with all permissions, check user is in correct entity
- else if ($conf->global->MAIN_MODULE_MULTICOMPANY)
+ else if ($conf->multicompany->enabled)
{
$sql = "SELECT dbt.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
@@ -2317,7 +2324,7 @@ function restrictedArea($user, $features='societe', $objectid=0, $dbtablename=''
$sql.= " AND sc.fk_user = ".$user->id;
}
// If multicompany and internal users with all permissions, check user is in correct entity
- else if ($conf->global->MAIN_MODULE_MULTICOMPANY)
+ else if ($conf->multicompany->enabled)
{
$sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index e0d030da0a2..6b538389678 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -25,7 +25,7 @@
/**
* \file htdocs/user/class/user.class.php
* \brief Fichier de la classe utilisateur
- * \version $Id: user.class.php,v 1.48 2011/08/19 07:22:17 hregis Exp $
+ * \version $Id: user.class.php,v 1.49 2011/08/19 22:15:22 hregis Exp $
*/
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
@@ -126,7 +126,7 @@ class User extends CommonObject
*/
function fetch($id='', $login='',$sid='',$loadpersonalconf=1)
{
- global $conf;
+ global $conf, $user;
// Clean parameters
$login=trim($login);
@@ -144,10 +144,15 @@ class User extends CommonObject
$sql.= " u.photo as photo,";
$sql.= " u.openid as openid";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
- if($conf->entity==0)
- $sql.= " WHERE u.entity IS NOT NULL";
- else
- $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
+
+ if($conf->multicompany->enabled && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
+ {
+ $sql.= " WHERE u.entity IS NOT NULL";
+ }
+ else
+ {
+ $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
+ }
if ($sid)
{
diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php
index 8823ac96979..63f31977b0e 100644
--- a/htdocs/user/class/usergroup.class.php
+++ b/htdocs/user/class/usergroup.class.php
@@ -21,7 +21,7 @@
* \file htdocs/user/class/usergroup.class.php
* \brief Fichier de la classe des groupes d'utilisateur
* \author Rodolphe Qiedeville
- * \version $Id: usergroup.class.php,v 1.13 2011/08/19 07:22:17 hregis Exp $
+ * \version $Id: usergroup.class.php,v 1.14 2011/08/19 22:15:22 hregis Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
@@ -129,10 +129,16 @@ class UserGroup extends CommonObject
$sql.= " ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ug.fk_usergroup = g.rowid";
$sql.= " AND ug.fk_user = ".$userid;
- if($conf->entity==0)
- $sql.= " AND ug.entity IS NOT NULL";
- else
- $sql.= " AND ug.entity IN (0,".$conf->entity.")";
+
+ if($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)
+ {
+ $sql.= " AND g.entity IS NOT NULL";
+ }
+ else
+ {
+ $sql.= " AND g.entity IN (0,".$conf->entity.")";
+ }
+
$sql.= " ORDER BY g.nom";
dol_syslog("UserGroup::listGroupsForUser sql=".$sql,LOG_DEBUG);
@@ -175,10 +181,15 @@ class UserGroup extends CommonObject
$sql.= " ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ug.fk_user = u.rowid";
$sql.= " AND ug.fk_usergroup = ".$this->id;
- if($conf->entity==0)
- $sql.= " AND u.entity IS NOT NULL";
- else
- $sql.= " AND u.entity IN (0,".$conf->entity.")";
+
+ if($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)
+ {
+ $sql.= " AND u.entity IS NOT NULL";
+ }
+ else
+ {
+ $sql.= " AND u.entity IN (0,".$conf->entity.")";
+ }
dol_syslog("UserGroup::listUsersForGroup sql=".$sql,LOG_DEBUG);
$result = $this->db->query($sql);
@@ -510,6 +521,12 @@ class UserGroup extends CommonObject
global $user, $conf, $langs;
$now=dol_now();
+
+ $entity=$conf->entity;
+ if($conf->multicompany->enabled && $conf->entity == 1)
+ {
+ $entity=$this->entity;
+ }
$sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup (";
$sql.= "datec";
@@ -518,7 +535,7 @@ class UserGroup extends CommonObject
$sql.= ") VALUES (";
$sql.= "'".$this->db->idate($now)."'";
$sql.= ",'".$this->db->escape($this->nom)."'";
- $sql.= ",".($conf->entity==0 ? $this->entity : $conf->entity);
+ $sql.= ",".$entity;
$sql.= ")";
dol_syslog("UserGroup::Create sql=".$sql, LOG_DEBUG);
@@ -559,12 +576,18 @@ class UserGroup extends CommonObject
global $user, $conf, $langs;
$error=0;
+
+ $entity=$conf->entity;
+ if($conf->multicompany->enabled && $conf->entity == 1)
+ {
+ $entity=$this->entity;
+ }
$sql = "UPDATE ".MAIN_DB_PREFIX."usergroup SET ";
- $sql.= " nom = '".$this->db->escape($this->nom)."'";
- $sql.= ", entity = ".($conf->entity==0 ? $this->entity : $conf->entity);
- $sql.= ", note = '".$this->db->escape($this->note)."'";
- $sql.= " WHERE rowid = ".$this->id;
+ $sql.= " nom = '" . $this->db->escape($this->nom) . "'";
+ $sql.= ", entity = " . $entity;
+ $sql.= ", note = '" . $this->db->escape($this->note) . "'";
+ $sql.= " WHERE rowid = " . $this->id;
dol_syslog("Usergroup::update sql=".$sql);
$resql = $this->db->query($sql);
diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php
index c2cb538a04f..10e69ca92f5 100644
--- a/htdocs/user/fiche.php
+++ b/htdocs/user/fiche.php
@@ -24,7 +24,7 @@
/**
* \file htdocs/user/fiche.php
* \brief Tab of user card
- * \version $Id: fiche.php,v 1.278 2011/08/19 09:26:41 hregis Exp $
+ * \version $Id: fiche.php,v 1.279 2011/08/19 22:15:23 hregis Exp $
*/
require("../main.inc.php");
@@ -51,7 +51,7 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
}
//Multicompany in mode transversal
-if($conf->multicompany->enabled && $conf->entity > 0 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
+if($conf->multicompany->enabled && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{
accessforbidden();
}
@@ -666,7 +666,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
print '
';
print $form->selectyesno('admin',$_POST["admin"],1);
- if (! empty($conf->multicompany->enabled) && ! $user->entity && ! $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
+ if ($conf->multicompany->enabled && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{
if ($conf->use_javascript_ajax)
{
@@ -677,11 +677,22 @@ if (($action == 'create') || ($action == 'adduserldap'))
$("input[name=superadmin]")
.attr("disabled", true)
.attr("checked", false);
+ $("select[name=entity]")
+ .attr("disabled", false);
} else {
$("input[name=superadmin]")
.attr("disabled", false);
}
});
+ $("input[name=superadmin]").change(function() {
+ if ( $(this).attr("checked") == "checked" ) {
+ $("select[name=entity]")
+ .attr("disabled", true);
+ } else {
+ $("select[name=entity]")
+ .attr("disabled", false);
+ }
+ });
});
';
}
@@ -695,7 +706,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
//Multicompany
if ($conf->multicompany->enabled)
{
- if ($conf->entity == 0 && ! $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
+ if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
$mc = new ActionsMulticompany($db);
print " | ".'| '.$langs->trans("Entity").' | ';
@@ -1028,16 +1039,20 @@ else
print '
'."\n";
// Multicompany
- if ($conf->multicompany->enabled)
+ if ($conf->multicompany->enabled && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
- if ($conf->entity == 0)
- {
- $mc = new ActionsMulticompany($db);
- $mc->getInfo($fuser->entity);
- print "".'| '.$langs->trans("Entity").' | ';
- print ''.$mc->label;
- print " |
\n";
- }
+ print '| '.$langs->trans("Entity").' | ';
+ if ($fuser->admin && ! $fuser->entity)
+ {
+ print $langs->trans("AllEntities");
+ }
+ else
+ {
+ $mc = new ActionsMulticompany($db);
+ $mc->getInfo($fuser->entity);
+ print $mc->label;
+ }
+ print " |
\n";
}
// Type
@@ -1185,7 +1200,7 @@ else
print '';
- if ($caneditfield && (empty($conf->multicompany->enabled) || (($fuser->entity == $conf->entity) || $fuser->entity == $user->entity) || $conf->entity==0) )
+ if ($caneditfield && (empty($conf->multicompany->enabled) || (($fuser->entity == $conf->entity) || $fuser->entity == $user->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) )
{
if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED))
{
@@ -1197,7 +1212,7 @@ else
}
}
elseif ($caneditpassword && ! $fuser->ldap_sid &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0) )
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) )
{
print '
'.$langs->trans("EditPassword").'';
}
@@ -1206,13 +1221,13 @@ else
if ($conf->global->USER_PASSWORD_GENERATED != 'none')
{
if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0))
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
{
print '
'.$langs->trans("ReinitPassword").'';
}
if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0) )
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) )
{
if ($fuser->email) print '
'.$langs->trans("SendNewPassword").'';
else print '
'.$langs->trans("SendNewPassword").'';
@@ -1221,19 +1236,19 @@ else
// Activer
if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 0 &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0) )
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) )
{
print '
'.$langs->trans("Reactivate").'';
}
// Desactiver
if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 1 &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0) )
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) )
{
print '
'.$langs->trans("DisableUser").'';
}
// Delete
if ($user->id <> $_GET["id"] && $candisableuser &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0) )
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) )
{
print '
'.$langs->trans("DeleteUser").'';
}
@@ -1259,7 +1274,7 @@ else
if (! empty($groupslist))
{
- if( !($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE))
+ if( ! ($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{
foreach($groupslist as $groupforuser)
{
@@ -1272,8 +1287,8 @@ else
{
$form = new Form($db);
print '
'."\n";
@@ -1308,8 +1325,10 @@ else
print '
';
print '';
print '| '.$langs->trans("Groups").' | ';
- if($conf->multicompany->enabled && $conf->entity==0)
- print ''.$langs->trans("Entity").' | ';
+ if($conf->multicompany->enabled && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
+ {
+ print ''.$langs->trans("Entity").' | ';
+ }
print " |
\n";
if (! empty($groupslist))
@@ -1331,14 +1350,13 @@ else
print img_object($langs->trans("ShowGroup"),"group").' '.$group->nom;
}
print '';
- if($conf->multicompany->enabled && $conf->entity==0)
+ if($conf->multicompany->enabled && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
$mc = new ActionsMulticompany($db);
$mc->getInfo($group->usergroup_entity);
print ''.$mc->label." | ";
}
print '';
-
if ($caneditgroup)
{
print '';
@@ -1353,7 +1371,7 @@ else
}
else
{
- print '| '.$langs->trans("None").' | ';
+ print '| '.$langs->trans("None").' | ';
}
print " |
";
@@ -1489,28 +1507,43 @@ else
{
print $form->selectyesno('admin',$fuser->admin,1);
- if (! empty($conf->multicompany->enabled) && ! $user->entity && ! $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
+ if ($conf->multicompany->enabled && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{
if ($conf->use_javascript_ajax)
{
print '';
}
@@ -1532,11 +1565,11 @@ else
//Multicompany
if ($conf->multicompany->enabled)
{
- if ($conf->entity == 0 && ! $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
+ if(empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
$mc = new ActionsMulticompany($db);
print "
".'| '.$langs->trans("Entity").' | ';
- print "".$mc->select_entities($fuser->entity);
+ print " | ".$mc->select_entities($conf->entity);
print " |
\n";
}
else
@@ -1743,7 +1776,7 @@ else
$db->close();
-llxFooter('$Date: 2011/08/19 09:26:41 $ - $Revision: 1.278 $');
+llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.279 $');
diff --git a/htdocs/user/group/fiche.php b/htdocs/user/group/fiche.php
index d71c11072d1..cff3f0b5bc9 100644
--- a/htdocs/user/group/fiche.php
+++ b/htdocs/user/group/fiche.php
@@ -21,7 +21,7 @@
/**
* \file htdocs/user/group/fiche.php
* \brief Onglet groupes utilisateurs
- * \version $Id: fiche.php,v 1.73 2011/08/19 09:26:42 hregis Exp $
+ * \version $Id: fiche.php,v 1.74 2011/08/19 22:15:23 hregis Exp $
*/
require("../../main.inc.php");
@@ -47,7 +47,7 @@ $langs->load("other");
// Security check
$result = restrictedArea($user, 'user', $_GET["id"], 'usergroup', 'user');
-if($conf->multicompany->enabled && $conf->entity > 0 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
+if($conf->multicompany->enabled && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{
accessforbidden();
}
@@ -93,9 +93,9 @@ if ($_POST["action"] == 'add')
if (! $message)
{
- $object->nom = trim($_POST["nom"]);
+ $object->nom = trim($_POST["nom"]);
$object->entity = $_POST["entity"];
- $object->note = trim($_POST["note"]);
+ $object->note = trim($_POST["note"]);
$db->begin();
@@ -136,8 +136,8 @@ if ($action == 'adduser' || $action =='removeuser')
$edituser = new User($db);
$edituser->fetch($userid);
- if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?$_POST["entity"]:$object->entity));
- if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?$_GET["entity"]:$object->entity));
+ if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?GETPOST("entity"):$object->entity));
+ if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?GETPOST("entity"):$object->entity));
if ($result > 0)
{
@@ -169,9 +169,9 @@ if ($_POST["action"] == 'update')
$object->oldcopy=dol_clone($object);
- $object->nom = trim($_POST["group"]);
+ $object->nom = trim($_POST["group"]);
$object->entity = $_POST["entity"];
- $object->note = dol_htmlcleanlastbr($_POST["note"]);
+ $object->note = dol_htmlcleanlastbr($_POST["note"]);
$ret=$object->update();
@@ -221,17 +221,17 @@ if ($action == 'create')
// Multicompany
if ($conf->multicompany->enabled)
{
- if ($conf->entity == 0 && !$conf->global->MULTICOMPANY_TRANSVERSE_MODE)
- {
- $mc = new ActionsMulticompany($db);
- print "
".'| '.$langs->trans("Entity").' | ';
- print "".$mc->select_entities($conf->entity);
- print " |
\n";
- }
- else
- {
- print '
';
- }
+ if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
+ {
+ $mc = new ActionsMulticompany($db);
+ print "
".'| '.$langs->trans("Entity").' | ';
+ print "".$mc->select_entities($conf->entity);
+ print " |
\n";
+ }
+ else
+ {
+ print '
';
+ }
}
print "
".'| '.$langs->trans("Note").' | ';
@@ -304,19 +304,16 @@ else
print img_redstar($langs->trans("GlobalGroup"));
}
print " |
\n";
-
- // Multicompany
- if ($conf->multicompany->enabled)
- {
- if ($conf->entity == 0)
- {
- $mc = new ActionsMulticompany($db);
- $mc->getInfo($object->entity);
- print "
".'| '.$langs->trans("Entity").' | ';
- print ''.$mc->label;
- print " |
\n";
- }
- }
+
+ // Multicompany
+ if ($conf->multicompany->enabled && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
+ {
+ $mc = new ActionsMulticompany($db);
+ $mc->getInfo($object->entity);
+ print "
".'| '.$langs->trans("Entity").' | ';
+ print ''.$mc->label;
+ print " |
\n";
+ }
// Note
print '
| '.$langs->trans("Note").' | ';
@@ -382,7 +379,7 @@ else
// Multicompany
if ($conf->multicompany->enabled)
{
- if ($conf->entity == 0 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
+ if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
{
$mc = new ActionsMulticompany($db);
print ''.$langs->trans("Entity").' | ';
@@ -390,11 +387,13 @@ else
}
else
{
- print '';
+ print '';
}
}
else
- print '';
+ {
+ print '';
+ }
print '';
print '
'."\n";
print ''."\n";
@@ -407,8 +406,10 @@ else
print '
';
print '';
print '| '.$langs->trans("Login").' | ';
- if($conf->multicompany->enabled && $conf->entity==0)
- print ''.$langs->trans("Entity").' | ';
+ if($conf->multicompany->enabled && $conf->entity == 1)
+ {
+ print ''.$langs->trans("Entity").' | ';
+ }
print ''.$langs->trans("Lastname").' | ';
print ''.$langs->trans("Firstname").' | ';
print ''.$langs->trans("Status").' | ';
@@ -427,15 +428,15 @@ else
print "
";
print '| ';
print ''.img_object($langs->trans("ShowUser"),"user").' '.$useringroup->login.'';
- if ($useringroup->admin && ! $useringroup->entity) print img_redstar($langs->trans("SuperAdministrator"));
+ if ($useringroup->admin && ! $useringroup->entity) print img_picto($langs->trans("SuperAdministrator"),'redstar');
else if ($useringroup->admin) print img_picto($langs->trans("Administrator"),'star');
print ' | ';
- if($conf->multicompany->enabled && $conf->entity==0)
- {
- $mc = new ActionsMulticompany($db);
- $mc->getInfo($useringroup->usergroup_entity);
- print ''.$mc->label." | ";
- }
+ if($conf->multicompany->enabled && $conf->entity == 1)
+ {
+ $mc = new ActionsMulticompany($db);
+ $mc->getInfo($useringroup->usergroup_entity);
+ print ''.$mc->label." | ";
+ }
print ''.ucfirst(stripslashes($useringroup->lastname)).' | ';
print ''.ucfirst(stripslashes($useringroup->firstname)).' | ';
print ''.$useringroup->getLibStatut(5).' | ';
@@ -478,7 +479,7 @@ else
// Multicompany
if ($conf->multicompany->enabled)
{
- if ($conf->entity == 0 && !$conf->global->MULTICOMPANY_TRANSVERSE_MODE)
+ if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
$mc = new ActionsMulticompany($db);
print "
".'| '.$langs->trans("Entity").' | ';
@@ -520,5 +521,5 @@ else
$db->close();
-llxFooter('$Date: 2011/08/19 09:26:42 $ - $Revision: 1.73 $');
+llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.74 $');
?>
diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php
index 25eba21861c..5cab12b2aab 100644
--- a/htdocs/user/group/index.php
+++ b/htdocs/user/group/index.php
@@ -22,7 +22,7 @@
* \file htdocs/user/group/index.php
* \ingroup core
* \brief Page of user groups
- * \version $Id: index.php,v 1.27 2011/08/19 09:26:10 hregis Exp $
+ * \version $Id: index.php,v 1.28 2011/08/19 22:15:23 hregis Exp $
*/
require("../../main.inc.php");
@@ -59,15 +59,19 @@ print_fiche_titre($langs->trans("ListOfGroups"));
$sql = "SELECT g.rowid, g.nom, g.entity, g.datec, COUNT(ugu.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
-if($conf->entity==0)
- $sql.= " WHERE g.entity IS NOT NULL";
-else
- $sql.= " WHERE g.entity IN (0,".$conf->entity.")";
+if($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)
+{
+ $sql.= " WHERE g.entity IS NOT NULL";
+}
+else
+{
+ $sql.= " WHERE g.entity IN (0,".$conf->entity.")";
+}
if ($_POST["search_group"])
{
- $sql .= " AND (g.nom like '%".$_POST["search_group"]."%' OR g.note like '%".$_POST["search_group"]."%')";
+ $sql .= " AND (g.nom LIKE '%".$_POST["search_group"]."%' OR g.note LIKE '%".$_POST["search_group"]."%')";
}
-if ($sall) $sql.= " AND (g.nom like '%".$sall."%' OR g.note like '%".$sall."%')";
+if ($sall) $sql.= " AND (g.nom LIKE '%".$sall."%' OR g.note LIKE '%".$sall."%')";
$sql.= " GROUP BY g.rowid, g.nom, g.entity, g.datec";
$sql.= $db->order($sortfield,$sortorder);
@@ -82,8 +86,10 @@ if ($resql)
print '
';
print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder);
//multicompany
- if($conf->multicompany->enabled && $conf->entity==0)
- print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],"g.entity",$param,"",'align="center"',$sortfield,$sortorder);
+ if($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("NbOfUsers"),$_SERVER["PHP_SELF"],"g.nb",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"g.datec",$param,"",'align="right"',$sortfield,$sortorder);
print "
\n";
@@ -101,7 +107,7 @@ if ($resql)
}
print "";
//multicompany
- if($conf->multicompany->enabled && $conf->entity==0)
+ if($conf->multicompany->enabled && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)
{
dol_include_once("/multicompany/class/actions_multicompany.class.php");
$mc = new ActionsMulticompany($db);
@@ -123,6 +129,6 @@ else
$db->close();
-llxFooter('$Date: 2011/08/19 09:26:10 $ - $Revision: 1.27 $');
+llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.28 $');
?>
diff --git a/htdocs/user/home.php b/htdocs/user/home.php
index 5a3c1a1bea5..ff508457bcc 100644
--- a/htdocs/user/home.php
+++ b/htdocs/user/home.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2005-2010 Regis Houssin
+ * Copyright (C) 2005-2011 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
/**
* \file htdocs/user/home.php
* \brief Home page of users and groups management
- * \version $Id: home.php,v 1.49 2011/08/17 15:56:25 eldy Exp $
+ * \version $Id: home.php,v 1.50 2011/08/19 22:15:23 hregis Exp $
*/
require("../main.inc.php");
@@ -100,7 +100,14 @@ $sql = "SELECT u.rowid, u.name, u.firstname, u.admin, u.login, u.fk_societe, u.d
$sql.= " s.nom, s.canvas";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_societe = s.rowid";
-$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
+if($conf->multicompany->enabled && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
+{
+ $sql.= " WHERE u.entity IS NOT NULL";
+}
+else
+{
+ $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
+}
if (!empty($socid)) $sql.= " AND u.fk_societe = ".$socid;
$sql.= $db->order("u.datec","DESC");
$sql.= $db->plimit($max);
@@ -139,11 +146,27 @@ if ($resql)
$companystatic->canvas=$obj->canvas;
print $companystatic->getNomUrl(1);
}
+ else if ($conf->multicompany->enabled)
+ {
+ if ($obj->admin && ! $obj->entity)
+ {
+ print $langs->trans("AllEntities");
+ }
+ else
+ {
+ $mc = new ActionsMulticompany($db);
+ $mc->getInfo($obj->entity);
+ print $mc->label;
+ }
+ }
else if ($obj->ldap_sid)
{
print $langs->trans("DomainUser");
}
- else print $langs->trans("InternalUser");
+ else
+ {
+ print $langs->trans("InternalUser");
+ }
print '';
print ''.dol_print_date($db->jdate($obj->datec),'dayhour').' | ';
print '';
@@ -219,5 +242,5 @@ print ' |
';
$db->close();
-llxFooter('$Date: 2011/08/17 15:56:25 $ - $Revision: 1.49 $');
+llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.50 $');
?>
diff --git a/htdocs/user/index.php b/htdocs/user/index.php
index e9e315b4540..adc733a752f 100644
--- a/htdocs/user/index.php
+++ b/htdocs/user/index.php
@@ -1,7 +1,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur
- * Copyright (C) 2005-2010 Regis Houssin
+ * Copyright (C) 2005-2011 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
* \file htdocs/user/index.php
* \ingroup core
* \brief Page of users
- * \version $Id: index.php,v 1.53 2011/08/19 07:22:17 hregis Exp $
+ * \version $Id: index.php,v 1.54 2011/08/19 22:15:23 hregis Exp $
*/
require("../main.inc.php");
@@ -69,10 +69,14 @@ $sql.= " u.ldap_sid, u.statut, u.entity,";
$sql.= " s.nom, s.canvas";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_societe = s.rowid";
-if($conf->entity==0)
- $sql.= " WHERE u.entity IS NOT NULL";
+if($conf->multicompany->enabled && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
+{
+ $sql.= " WHERE u.entity IS NOT NULL";
+}
else
- $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
+{
+ $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
+}
if (!empty($socid)) $sql.= " AND u.fk_societe = ".$socid;
if ($_POST["search_user"])
{
@@ -88,7 +92,7 @@ if ($result)
$i = 0;
$param="search_user=$search_user&sall=$sall";
- print "";
+ print '';
print '';
print_liste_field_titre($langs->trans("Login"),"index.php","u.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("LastName"),"index.php","u.name",$param,"","",$sortfield,$sortorder);
@@ -106,7 +110,7 @@ if ($result)
print "
";
print '| '.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'';
- if ($conf->global->MAIN_MODULE_MULTICOMPANY && $obj->admin && ! $obj->entity)
+ if ($conf->multicompany->enabled && $obj->admin && ! $obj->entity)
{
print img_picto($langs->trans("SuperAdministrator"),'redstar');
}
@@ -127,16 +131,25 @@ if ($result)
}
else if ($conf->multicompany->enabled)
{
- $mc = new ActionsMulticompany($db);
- $mc->getInfo($obj->entity);
- print $mc->label;
+ if ($obj->admin && ! $obj->entity)
+ {
+ print $langs->trans("AllEntities");
+ }
+ else
+ {
+ $mc = new ActionsMulticompany($db);
+ $mc->getInfo($obj->entity);
+ print $mc->label;
+ }
}
else if ($obj->ldap_sid)
{
print $langs->trans("DomainUser");
}
- else
- print $langs->trans("InternalUser");
+ else
+ {
+ print $langs->trans("InternalUser");
+ }
print ' | ';
// Date creation
@@ -161,5 +174,5 @@ else
$db->close();
-llxFooter('$Date: 2011/08/19 07:22:17 $ - $Revision: 1.53 $');
+llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.54 $');
?>