multicompany enhancement (in progress)

This commit is contained in:
Regis Houssin
2011-08-19 22:15:22 +00:00
parent 318c9da5b8
commit a49bea1b03
9 changed files with 280 additions and 155 deletions

View File

@@ -31,7 +31,7 @@
* \file htdocs/core/class/html.form.class.php * \file htdocs/core/class/html.form.class.php
* \ingroup core * \ingroup core
* \brief File of class with all html predefined components * \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=''; $out='';
// On recherche les utilisateurs // On recherche les utilisateurs
$sql = "SELECT u.rowid, u.name, u.firstname, u.login, u.admin"; $sql = "SELECT u.rowid, u.name, u.firstname, u.login, u.admin, u.entity";
if($conf->entity==0) if($conf->multicompany->enabled && $conf->entity == 1 && $user->admin && ! $user->entity)
$sql.=" ,e.label";
$sql.= " FROM ".MAIN_DB_PREFIX ."user as u";
if($conf->entity==0)
{ {
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX ."entity as e on e.rowid=u.entity"; $sql.= ", e.label";
$sql.=" WHERE u.entity IS NOT NULL"; }
$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 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($exclude) && $excludeUsers) $sql.= " AND u.rowid NOT IN ('".$excludeUsers."')";
if (is_array($include) && $includeUsers) $sql.= " AND u.rowid IN ('".$includeUsers."')"; if (is_array($include) && $includeUsers) $sql.= " AND u.rowid IN ('".$includeUsers."')";
$sql.= " ORDER BY u.name ASC"; $sql.= " ORDER BY u.name ASC";
@@ -845,8 +849,12 @@ class Form
$out.= '>'; $out.= '>';
} }
$out.= $userstatic->getFullName($langs); $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 ($obj->admin) $out.= ' *';
if ($conf->global->MAIN_SHOW_LOGIN) $out.= ' ('.$obj->login.')'; if ($conf->global->MAIN_SHOW_LOGIN) $out.= ' ('.$obj->login.')';
@@ -3515,16 +3523,20 @@ class Form
// On recherche les groupes // On recherche les groupes
$sql = "SELECT ug.rowid, ug.nom "; $sql = "SELECT ug.rowid, ug.nom ";
if($conf->entity==0) if($conf->multicompany->enabled && $conf->entity == 1)
{
$sql.= ", e.label"; $sql.= ", e.label";
}
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as ug "; $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.= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e on e.rowid=ug.entity";
$sql.= " WHERE ug.entity IS NOT NULL"; $sql.= " WHERE ug.entity IS NOT NULL";
} }
else else
{
$sql.= " WHERE ug.entity IN (0,".$conf->entity.")"; $sql.= " WHERE ug.entity IN (0,".$conf->entity.")";
}
if (is_array($exclude) && $excludeGroups) $sql.= " AND ug.rowid NOT IN ('".$excludeGroups."')"; if (is_array($exclude) && $excludeGroups) $sql.= " AND ug.rowid NOT IN ('".$excludeGroups."')";
if (is_array($include) && $includeGroups) $sql.= " AND ug.rowid IN ('".$includeGroups."')"; if (is_array($include) && $includeGroups) $sql.= " AND ug.rowid IN ('".$includeGroups."')";
$sql.= " ORDER BY ug.nom ASC"; $sql.= " ORDER BY ug.nom ASC";
@@ -3554,8 +3566,10 @@ class Form
$out.= '>'; $out.= '>';
$out.= $obj->nom; $out.= $obj->nom;
if($conf->entity==0 && !$conf->global->MULTICOMPANY_TRANSVERSE_MODE) if($conf->multicompany->enabled && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)
{
$out.= " (".$obj->label.")"; $out.= " (".$obj->label.")";
}
$out.= '</option>'; $out.= '</option>';
$i++; $i++;

View File

@@ -28,7 +28,7 @@
* \file htdocs/lib/functions.lib.php * \file htdocs/lib/functions.lib.php
* \brief A set of functions for Dolibarr * \brief A set of functions for Dolibarr
* This file contains all frequently used functions. * 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 // For compatibility during upgrade
@@ -2224,8 +2224,15 @@ function restrictedArea($user, $features='societe', $objectid=0, $dbtablename=''
$sql = "SELECT dbt.".$dbt_select; $sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid; $sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
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).")"; $sql.= " AND dbt.entity IN (0,".(! empty($conf->entities[$dbtablename]) ? $conf->entities[$dbtablename] : $conf->entity).")";
} }
}
else if (in_array($feature,$checksoc)) else if (in_array($feature,$checksoc))
{ {
// If external user: Check permission for external users // If external user: Check permission for external users
@@ -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).")"; $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 // 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 = "SELECT s.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $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).")"; $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 // 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 = "SELECT dbt.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $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; $sql.= " AND sc.fk_user = ".$user->id;
} }
// If multicompany and internal users with all permissions, check user is in correct 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.".$dbt_select; $sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";

View File

@@ -25,7 +25,7 @@
/** /**
* \file htdocs/user/class/user.class.php * \file htdocs/user/class/user.class.php
* \brief Fichier de la classe utilisateur * \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"); 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) function fetch($id='', $login='',$sid='',$loadpersonalconf=1)
{ {
global $conf; global $conf, $user;
// Clean parameters // Clean parameters
$login=trim($login); $login=trim($login);
@@ -144,10 +144,15 @@ class User extends CommonObject
$sql.= " u.photo as photo,"; $sql.= " u.photo as photo,";
$sql.= " u.openid as openid"; $sql.= " u.openid as openid";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if($conf->entity==0)
if($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";
}
else else
{
$sql.= " WHERE u.entity IN (0,".$conf->entity.")"; $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
}
if ($sid) if ($sid)
{ {

View File

@@ -21,7 +21,7 @@
* \file htdocs/user/class/usergroup.class.php * \file htdocs/user/class/usergroup.class.php
* \brief Fichier de la classe des groupes d'utilisateur * \brief Fichier de la classe des groupes d'utilisateur
* \author Rodolphe Qiedeville * \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"); 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.= " ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ug.fk_usergroup = g.rowid"; $sql.= " WHERE ug.fk_usergroup = g.rowid";
$sql.= " AND ug.fk_user = ".$userid; $sql.= " AND ug.fk_user = ".$userid;
if($conf->entity==0)
$sql.= " AND ug.entity IS NOT NULL"; if($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)
{
$sql.= " AND g.entity IS NOT NULL";
}
else else
$sql.= " AND ug.entity IN (0,".$conf->entity.")"; {
$sql.= " AND g.entity IN (0,".$conf->entity.")";
}
$sql.= " ORDER BY g.nom"; $sql.= " ORDER BY g.nom";
dol_syslog("UserGroup::listGroupsForUser sql=".$sql,LOG_DEBUG); 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.= " ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ug.fk_user = u.rowid"; $sql.= " WHERE ug.fk_user = u.rowid";
$sql.= " AND ug.fk_usergroup = ".$this->id; $sql.= " AND ug.fk_usergroup = ".$this->id;
if($conf->entity==0)
if($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)
{
$sql.= " AND u.entity IS NOT NULL"; $sql.= " AND u.entity IS NOT NULL";
}
else else
{
$sql.= " AND u.entity IN (0,".$conf->entity.")"; $sql.= " AND u.entity IN (0,".$conf->entity.")";
}
dol_syslog("UserGroup::listUsersForGroup sql=".$sql,LOG_DEBUG); dol_syslog("UserGroup::listUsersForGroup sql=".$sql,LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@@ -511,6 +522,12 @@ class UserGroup extends CommonObject
$now=dol_now(); $now=dol_now();
$entity=$conf->entity;
if($conf->multicompany->enabled && $conf->entity == 1)
{
$entity=$this->entity;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup (";
$sql.= "datec"; $sql.= "datec";
$sql.= ", nom"; $sql.= ", nom";
@@ -518,7 +535,7 @@ class UserGroup extends CommonObject
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= "'".$this->db->idate($now)."'"; $sql.= "'".$this->db->idate($now)."'";
$sql.= ",'".$this->db->escape($this->nom)."'"; $sql.= ",'".$this->db->escape($this->nom)."'";
$sql.= ",".($conf->entity==0 ? $this->entity : $conf->entity); $sql.= ",".$entity;
$sql.= ")"; $sql.= ")";
dol_syslog("UserGroup::Create sql=".$sql, LOG_DEBUG); dol_syslog("UserGroup::Create sql=".$sql, LOG_DEBUG);
@@ -560,11 +577,17 @@ class UserGroup extends CommonObject
$error=0; $error=0;
$entity=$conf->entity;
if($conf->multicompany->enabled && $conf->entity == 1)
{
$entity=$this->entity;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."usergroup SET "; $sql = "UPDATE ".MAIN_DB_PREFIX."usergroup SET ";
$sql.= " nom = '".$this->db->escape($this->nom)."'"; $sql.= " nom = '" . $this->db->escape($this->nom) . "'";
$sql.= ", entity = ".($conf->entity==0 ? $this->entity : $conf->entity); $sql.= ", entity = " . $entity;
$sql.= ", note = '".$this->db->escape($this->note)."'"; $sql.= ", note = '" . $this->db->escape($this->note) . "'";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = " . $this->id;
dol_syslog("Usergroup::update sql=".$sql); dol_syslog("Usergroup::update sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@@ -24,7 +24,7 @@
/** /**
* \file htdocs/user/fiche.php * \file htdocs/user/fiche.php
* \brief Tab of user card * \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"); require("../main.inc.php");
@@ -51,7 +51,7 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
} }
//Multicompany in mode transversal //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(); accessforbidden();
} }
@@ -666,7 +666,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
print '<td>'; print '<td>';
print $form->selectyesno('admin',$_POST["admin"],1); 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) if ($conf->use_javascript_ajax)
{ {
@@ -677,11 +677,22 @@ if (($action == 'create') || ($action == 'adduserldap'))
$("input[name=superadmin]") $("input[name=superadmin]")
.attr("disabled", true) .attr("disabled", true)
.attr("checked", false); .attr("checked", false);
$("select[name=entity]")
.attr("disabled", false);
} else { } else {
$("input[name=superadmin]") $("input[name=superadmin]")
.attr("disabled", false); .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);
}
});
}); });
</script>'; </script>';
} }
@@ -695,7 +706,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
//Multicompany //Multicompany
if ($conf->multicompany->enabled) 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); $mc = new ActionsMulticompany($db);
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>'; print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
@@ -1028,16 +1039,20 @@ else
print '</td></tr>'."\n"; print '</td></tr>'."\n";
// Multicompany // 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) print '<tr><td valign="top">'.$langs->trans("Entity").'</td><td width="75%" class="valeur">';
if ($fuser->admin && ! $fuser->entity)
{
print $langs->trans("AllEntities");
}
else
{ {
$mc = new ActionsMulticompany($db); $mc = new ActionsMulticompany($db);
$mc->getInfo($fuser->entity); $mc->getInfo($fuser->entity);
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>'; print $mc->label;
print '<td width="75%" class="valeur">'.$mc->label;
print "</td></tr>\n";
} }
print "</td></tr>\n";
} }
// Type // Type
@@ -1185,7 +1200,7 @@ else
print '<div class="tabsAction">'; print '<div class="tabsAction">';
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)) if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED))
{ {
@@ -1197,7 +1212,7 @@ else
} }
} }
elseif ($caneditpassword && ! $fuser->ldap_sid && 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 '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=edit">'.$langs->trans("EditPassword").'</a>'; print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=edit">'.$langs->trans("EditPassword").'</a>';
} }
@@ -1206,13 +1221,13 @@ else
if ($conf->global->USER_PASSWORD_GENERATED != 'none') if ($conf->global->USER_PASSWORD_GENERATED != 'none')
{ {
if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && 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 '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=password">'.$langs->trans("ReinitPassword").'</a>'; print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=password">'.$langs->trans("ReinitPassword").'</a>';
} }
if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && 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 '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=passwordsend">'.$langs->trans("SendNewPassword").'</a>'; if ($fuser->email) print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=passwordsend">'.$langs->trans("SendNewPassword").'</a>';
else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendNewPassword").'</a>'; else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendNewPassword").'</a>';
@@ -1221,19 +1236,19 @@ else
// Activer // Activer
if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 0 && 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 '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=enable">'.$langs->trans("Reactivate").'</a>'; print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=enable">'.$langs->trans("Reactivate").'</a>';
} }
// Desactiver // Desactiver
if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 1 && 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 '<a class="butActionDelete" href="fiche.php?action=disable&amp;id='.$fuser->id.'">'.$langs->trans("DisableUser").'</a>'; print '<a class="butActionDelete" href="fiche.php?action=disable&amp;id='.$fuser->id.'">'.$langs->trans("DisableUser").'</a>';
} }
// Delete // Delete
if ($user->id <> $_GET["id"] && $candisableuser && 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 '<a class="butActionDelete" href="fiche.php?action=delete&amp;id='.$fuser->id.'">'.$langs->trans("DeleteUser").'</a>'; print '<a class="butActionDelete" href="fiche.php?action=delete&amp;id='.$fuser->id.'">'.$langs->trans("DeleteUser").'</a>';
} }
@@ -1259,7 +1274,7 @@ else
if (! empty($groupslist)) 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) foreach($groupslist as $groupforuser)
{ {
@@ -1272,8 +1287,8 @@ else
{ {
$form = new Form($db); $form = new Form($db);
print '<form action="fiche.php?id='.$_GET["id"].'" method="post">'."\n"; print '<form action="fiche.php?id='.$_GET["id"].'" method="post">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="addgroup">'; print '<input type="hidden" name="action" value="addgroup" />';
print '<table class="noborder" width="100%">'."\n"; print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td class="liste_titre" width="25%">'.$langs->trans("GroupsToAdd").'</td>'."\n"; print '<tr class="liste_titre"><td class="liste_titre" width="25%">'.$langs->trans("GroupsToAdd").'</td>'."\n";
print '<td>'; print '<td>';
@@ -1282,7 +1297,7 @@ else
// Multicompany // Multicompany
if ($conf->multicompany->enabled) 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); $mc = new ActionsMulticompany($db);
print '</td><td valign="top">'.$langs->trans("Entity").'</td>'; print '</td><td valign="top">'.$langs->trans("Entity").'</td>';
@@ -1294,8 +1309,10 @@ else
} }
} }
else else
print '<input type="hidden" name="entity" value="'.$conf->entity.'">'; {
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
print '</table></form>'."\n"; print '</table></form>'."\n";
@@ -1308,8 +1325,10 @@ else
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre" width="25%">'.$langs->trans("Groups").'</td>'; print '<td class="liste_titre" width="25%">'.$langs->trans("Groups").'</td>';
if($conf->multicompany->enabled && $conf->entity==0) if($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 "<td>&nbsp;</td></tr>\n"; print "<td>&nbsp;</td></tr>\n";
if (! empty($groupslist)) if (! empty($groupslist))
@@ -1331,14 +1350,13 @@ else
print img_object($langs->trans("ShowGroup"),"group").' '.$group->nom; print img_object($langs->trans("ShowGroup"),"group").' '.$group->nom;
} }
print '</td>'; print '</td>';
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 = new ActionsMulticompany($db);
$mc->getInfo($group->usergroup_entity); $mc->getInfo($group->usergroup_entity);
print '<td class="valeur">'.$mc->label."</td>"; print '<td class="valeur">'.$mc->label."</td>";
} }
print '<td align="right">'; print '<td align="right">';
if ($caneditgroup) if ($caneditgroup)
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$fuser->id.'&amp;action=removegroup&amp;group='.$group->id.'&amp;entity='.$group->usergroup_entity.'">'; print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$fuser->id.'&amp;action=removegroup&amp;group='.$group->id.'&amp;entity='.$group->usergroup_entity.'">';
@@ -1353,7 +1371,7 @@ else
} }
else else
{ {
print '<tr '.$bc[false].'><td colspan=2>'.$langs->trans("None").'</td></tr>'; print '<tr '.$bc[false].'><td colspan="3">'.$langs->trans("None").'</td></tr>';
} }
print "</table>"; print "</table>";
@@ -1489,28 +1507,43 @@ else
{ {
print $form->selectyesno('admin',$fuser->admin,1); 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) if ($conf->use_javascript_ajax)
{ {
print '<script type="text/javascript"> print '<script type="text/javascript">
$(function() { $(function() {
var admin = $("select[name=admin]"); var admin = $("select[name=admin]").val();
if (admin.val() == 0) { if (admin == 0) {
$("input[name=superadmin]") $("input[name=superadmin]")
.attr("disabled", true) .attr("disabled", true)
.attr("checked", false); .attr("checked", false);
} }
if ($("input[name=superadmin]").attr("checked") == "checked") {
$("select[name=entity]")
.attr("disabled", true);
}
$("select[name=admin]").change(function() { $("select[name=admin]").change(function() {
if ( $(this).val() == 0 ) { if ( $(this).val() == 0 ) {
$("input[name=superadmin]") $("input[name=superadmin]")
.attr("disabled", true) .attr("disabled", true)
.attr("checked", false); .attr("checked", false);
$("select[name=entity]")
.attr("disabled", false);
} else { } else {
$("input[name=superadmin]") $("input[name=superadmin]")
.attr("disabled", false); .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);
}
});
}); });
</script>'; </script>';
} }
@@ -1532,11 +1565,11 @@ else
//Multicompany //Multicompany
if ($conf->multicompany->enabled) 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); $mc = new ActionsMulticompany($db);
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>'; print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($fuser->entity); print "<td>".$mc->select_entities($conf->entity);
print "</td></tr>\n"; print "</td></tr>\n";
} }
else else
@@ -1743,7 +1776,7 @@ else
$db->close(); $db->close();
llxFooter('$Date: 2011/08/19 09:26:41 $ - $Revision: 1.278 $'); llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.279 $');

View File

@@ -21,7 +21,7 @@
/** /**
* \file htdocs/user/group/fiche.php * \file htdocs/user/group/fiche.php
* \brief Onglet groupes utilisateurs * \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"); require("../../main.inc.php");
@@ -47,7 +47,7 @@ $langs->load("other");
// Security check // Security check
$result = restrictedArea($user, 'user', $_GET["id"], 'usergroup', 'user'); $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(); accessforbidden();
} }
@@ -136,8 +136,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,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?$_POST["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?$_GET["entity"]:$object->entity)); if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?GETPOST("entity"):$object->entity));
if ($result > 0) if ($result > 0)
{ {
@@ -221,7 +221,7 @@ if ($action == 'create')
// Multicompany // Multicompany
if ($conf->multicompany->enabled) 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); $mc = new ActionsMulticompany($db);
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>'; print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
@@ -306,9 +306,7 @@ else
print "</td></tr>\n"; print "</td></tr>\n";
// Multicompany // 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 = new ActionsMulticompany($db);
$mc->getInfo($object->entity); $mc->getInfo($object->entity);
@@ -316,7 +314,6 @@ else
print '<td width="75%" class="valeur">'.$mc->label; print '<td width="75%" class="valeur">'.$mc->label;
print "</td></tr>\n"; print "</td></tr>\n";
} }
}
// Note // Note
print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>'; print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
@@ -382,7 +379,7 @@ else
// Multicompany // Multicompany
if ($conf->multicompany->enabled) 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); $mc = new ActionsMulticompany($db);
print '</td><td valign="top">'.$langs->trans("Entity").'</td>'; print '</td><td valign="top">'.$langs->trans("Entity").'</td>';
@@ -394,7 +391,9 @@ else
} }
} }
else else
{
print '<input type="hidden" name="entity" value="'.$conf->entity.'">'; print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
}
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
print '</table></form>'."\n"; print '</table></form>'."\n";
@@ -407,8 +406,10 @@ else
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre" width="25%">'.$langs->trans("Login").'</td>'; print '<td class="liste_titre" width="25%">'.$langs->trans("Login").'</td>';
if($conf->multicompany->enabled && $conf->entity==0) if($conf->multicompany->enabled && $conf->entity == 1)
{
print '<td class="liste_titre" width="25%">'.$langs->trans("Entity").'</td>'; print '<td class="liste_titre" width="25%">'.$langs->trans("Entity").'</td>';
}
print '<td class="liste_titre" width="25%">'.$langs->trans("Lastname").'</td>'; print '<td class="liste_titre" width="25%">'.$langs->trans("Lastname").'</td>';
print '<td class="liste_titre" width="25%">'.$langs->trans("Firstname").'</td>'; print '<td class="liste_titre" width="25%">'.$langs->trans("Firstname").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("Status").'</td>'; print '<td class="liste_titre" align="right">'.$langs->trans("Status").'</td>';
@@ -427,10 +428,10 @@ else
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'; print '<td>';
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$useringroup->id.'">'.img_object($langs->trans("ShowUser"),"user").' '.$useringroup->login.'</a>'; print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$useringroup->id.'">'.img_object($langs->trans("ShowUser"),"user").' '.$useringroup->login.'</a>';
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'); else if ($useringroup->admin) print img_picto($langs->trans("Administrator"),'star');
print '</td>'; print '</td>';
if($conf->multicompany->enabled && $conf->entity==0) if($conf->multicompany->enabled && $conf->entity == 1)
{ {
$mc = new ActionsMulticompany($db); $mc = new ActionsMulticompany($db);
$mc->getInfo($useringroup->usergroup_entity); $mc->getInfo($useringroup->usergroup_entity);
@@ -478,7 +479,7 @@ else
// Multicompany // Multicompany
if ($conf->multicompany->enabled) 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); $mc = new ActionsMulticompany($db);
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>'; print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
@@ -520,5 +521,5 @@ else
$db->close(); $db->close();
llxFooter('$Date: 2011/08/19 09:26:42 $ - $Revision: 1.73 $'); llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.74 $');
?> ?>

View File

@@ -22,7 +22,7 @@
* \file htdocs/user/group/index.php * \file htdocs/user/group/index.php
* \ingroup core * \ingroup core
* \brief Page of user groups * \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"); 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 = "SELECT g.rowid, g.nom, g.entity, g.datec, COUNT(ugu.rowid) 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($conf->entity==0) if($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)
{
$sql.= " WHERE g.entity IS NOT NULL"; $sql.= " WHERE g.entity IS NOT NULL";
}
else else
{
$sql.= " WHERE g.entity IN (0,".$conf->entity.")"; $sql.= " WHERE g.entity IN (0,".$conf->entity.")";
}
if ($_POST["search_group"]) 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.= " GROUP BY g.rowid, g.nom, g.entity, g.datec";
$sql.= $db->order($sortfield,$sortorder); $sql.= $db->order($sortfield,$sortorder);
@@ -82,8 +86,10 @@ 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($conf->multicompany->enabled && $conf->entity==0) 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("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("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_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"g.datec",$param,"",'align="right"',$sortfield,$sortorder);
print "</tr>\n"; print "</tr>\n";
@@ -101,7 +107,7 @@ if ($resql)
} }
print "</td>"; print "</td>";
//multicompany //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"); dol_include_once("/multicompany/class/actions_multicompany.class.php");
$mc = new ActionsMulticompany($db); $mc = new ActionsMulticompany($db);
@@ -123,6 +129,6 @@ else
$db->close(); $db->close();
llxFooter('$Date: 2011/08/19 09:26:10 $ - $Revision: 1.27 $'); llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.28 $');
?> ?>

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
/** /**
* \file htdocs/user/home.php * \file htdocs/user/home.php
* \brief Home page of users and groups management * \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"); 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.= " s.nom, 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_societe = s.rowid"; $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; if (!empty($socid)) $sql.= " AND u.fk_societe = ".$socid;
$sql.= $db->order("u.datec","DESC"); $sql.= $db->order("u.datec","DESC");
$sql.= $db->plimit($max); $sql.= $db->plimit($max);
@@ -138,12 +145,28 @@ if ($resql)
$companystatic->nom=$obj->nom; $companystatic->nom=$obj->nom;
$companystatic->canvas=$obj->canvas; $companystatic->canvas=$obj->canvas;
print $companystatic->getNomUrl(1); 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) else if ($obj->ldap_sid)
{ {
print $langs->trans("DomainUser"); print $langs->trans("DomainUser");
} }
else print $langs->trans("InternalUser"); else
{
print $langs->trans("InternalUser");
}
print '</td>'; print '</td>';
print '<td align="right">'.dol_print_date($db->jdate($obj->datec),'dayhour').'</td>'; print '<td align="right">'.dol_print_date($db->jdate($obj->datec),'dayhour').'</td>';
print '<td align="right">'; print '<td align="right">';
@@ -219,5 +242,5 @@ print '</table>';
$db->close(); $db->close();
llxFooter('$Date: 2011/08/17 15:56:25 $ - $Revision: 1.49 $'); llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.50 $');
?> ?>

View File

@@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
* \file htdocs/user/index.php * \file htdocs/user/index.php
* \ingroup core * \ingroup core
* \brief Page of users * \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"); require("../main.inc.php");
@@ -69,10 +69,14 @@ $sql.= " u.ldap_sid, u.statut, u.entity,";
$sql.= " s.nom, s.canvas"; $sql.= " s.nom, 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_societe = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_societe = s.rowid";
if($conf->entity==0) if($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";
}
else 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 (!empty($socid)) $sql.= " AND u.fk_societe = ".$socid;
if ($_POST["search_user"]) if ($_POST["search_user"])
{ {
@@ -88,7 +92,7 @@ if ($result)
$i = 0; $i = 0;
$param="search_user=$search_user&amp;sall=$sall"; $param="search_user=$search_user&amp;sall=$sall";
print "<table class=\"noborder\" width=\"100%\">"; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Login"),"index.php","u.login",$param,"","",$sortfield,$sortorder); 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); print_liste_field_titre($langs->trans("LastName"),"index.php","u.name",$param,"","",$sortfield,$sortorder);
@@ -106,7 +110,7 @@ if ($result)
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td><a href="fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'</a>'; print '<td><a href="fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'</a>';
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'); print img_picto($langs->trans("SuperAdministrator"),'redstar');
} }
@@ -126,17 +130,26 @@ if ($result)
print $companystatic->getNomUrl(1); print $companystatic->getNomUrl(1);
} }
else if ($conf->multicompany->enabled) else if ($conf->multicompany->enabled)
{
if ($obj->admin && ! $obj->entity)
{
print $langs->trans("AllEntities");
}
else
{ {
$mc = new ActionsMulticompany($db); $mc = new ActionsMulticompany($db);
$mc->getInfo($obj->entity); $mc->getInfo($obj->entity);
print $mc->label; print $mc->label;
} }
}
else if ($obj->ldap_sid) else if ($obj->ldap_sid)
{ {
print $langs->trans("DomainUser"); print $langs->trans("DomainUser");
} }
else else
{
print $langs->trans("InternalUser"); print $langs->trans("InternalUser");
}
print '</td>'; print '</td>';
// Date creation // Date creation
@@ -161,5 +174,5 @@ else
$db->close(); $db->close();
llxFooter('$Date: 2011/08/19 07:22:17 $ - $Revision: 1.53 $'); llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.54 $');
?> ?>