| '.$langs->trans("Type").' | ';
@@ -1146,8 +1185,7 @@ else
print '';
- if ($caneditfield &&
- (empty($conf->multicompany->enabled) || (($fuser->entity == $conf->entity) || $fuser->entity == $user->entity)) )
+ if ($caneditfield && (empty($conf->multicompany->enabled) || (($fuser->entity == $conf->entity) || $fuser->entity == $user->entity) || $conf->entity==0) )
{
if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED))
{
@@ -1159,7 +1197,7 @@ else
}
}
elseif ($caneditpassword && ! $fuser->ldap_sid &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) )
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0) )
{
print ' '.$langs->trans("EditPassword").'';
}
@@ -1168,13 +1206,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)))
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0))
{
print ' '.$langs->trans("ReinitPassword").'';
}
if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) )
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0) )
{
if ($fuser->email) print ' '.$langs->trans("SendNewPassword").'';
else print ' '.$langs->trans("SendNewPassword").'';
@@ -1183,19 +1221,19 @@ else
// Activer
if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 0 &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) )
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0) )
{
print ' '.$langs->trans("Reactivate").'';
}
// Desactiver
if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 1 &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) )
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0) )
{
print ' '.$langs->trans("DisableUser").'';
}
// Delete
if ($user->id <> $_GET["id"] && $candisableuser &&
- (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) )
+ (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || $conf->entity==0) )
{
print ' '.$langs->trans("DeleteUser").'';
}
@@ -1221,9 +1259,12 @@ else
if (! empty($groupslist))
{
- foreach($groupslist as $groupforuser)
+ if( !($conf->multicompany->enabled && $conf->global->MULTICOMPANY_MODE_TRANVERSAL))
{
- $exclude[]=$groupforuser->id;
+ foreach($groupslist as $groupforuser)
+ {
+ $exclude[]=$groupforuser->id;
+ }
}
}
@@ -1233,12 +1274,27 @@ else
print ' '."\n";
@@ -1252,6 +1308,8 @@ else
print ' ';
print '';
print '| '.$langs->trans("Groups").' | ';
+ if($conf->multicompany->enabled && $conf->entity==0)
+ print ''.$langs->trans("Entity").' | ';
print " | \n";
if (! empty($groupslist))
@@ -1273,6 +1331,12 @@ else
print img_object($langs->trans("ShowGroup"),"group").' '.$group->nom;
}
print '';
+ if($conf->multicompany->enabled && $conf->entity==0)
+ {
+ $mc = new ActionsMulticompany($db);
+ $mc->getInfo($group->usergroup_entity);
+ print ''.$mc->label." | ";
+ }
print '';
if ($caneditgroup)
@@ -1312,6 +1376,7 @@ else
print '';
$rowspan=12;
+
if ($conf->societe->enabled) $rowspan++;
if ($conf->adherent->enabled) $rowspan++;
if ($conf->webcalendar->enabled) $rowspan++;
@@ -1350,6 +1415,7 @@ else
print ' ';
}
print ' | ';
+
print '';
// Firstname
@@ -1423,7 +1489,7 @@ else
{
print $form->selectyesno('admin',$fuser->admin,1);
- if (! empty($conf->multicompany->enabled) && ! $user->entity)
+ /*if (! empty($conf->multicompany->enabled) && ! $user->entity)
{
if ($conf->use_javascript_ajax)
{
@@ -1451,18 +1517,35 @@ else
$checked=(($fuser->admin && ! $fuser->entity) ? ' checked' : '');
print ' '.$langs->trans("SuperAdministrator");
- }
+ }*/
}
else
{
$yn = yn($fuser->admin);
print '';
- if (! empty($conf->multicompany->enabled) && ! $fuser->entity) print $html->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning');
- else print $yn;
+ //if (! empty($conf->multicompany->enabled) && ! $fuser->entity) print $html->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning');
+ //else print $yn;
}
print '';
}
+ //Multicompany
+ if ($conf->multicompany->enabled)
+ {
+ if ($conf->entity == 0 && !$conf->global->MULTICOMPANY_MODE_TRANVERSAL)
+ {
+ $mc = new ActionsMulticompany($db);
+ print "".'| '.$langs->trans("Entity").' | ';
+ print "".$mc->select_entities($fuser->entity);
+ print " | \n";
+ }
+ else
+ {
+ print '';
+ }
+ }
+ else
+ {
// Type
print '| '.$langs->trans("Type").' | ';
print '';
@@ -1479,7 +1562,7 @@ else
print $langs->trans("Internal");
}
print ' | ';
-
+ }
// Tel pro
print "".'| '.$langs->trans("PhonePro").' | ';
print '';
@@ -1659,7 +1742,7 @@ else
$db->close();
-llxFooter('$Date: 2011/07/31 23:19:43 $ - $Revision: 1.275 $');
+llxFooter('$Date: 2011/08/19 07:22:17 $ - $Revision: 1.276 $');
diff --git a/htdocs/user/group/fiche.php b/htdocs/user/group/fiche.php
index 60cec3b409d..ec628b0fe4a 100644
--- a/htdocs/user/group/fiche.php
+++ b/htdocs/user/group/fiche.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2005 Rodolphe Quiedeville
* Copyright (C) 2005-2010 Laurent Destailleur
* Copyright (C) 2005-2011 Regis Houssin
+ * Copyright (C) 2011 Herve Prot
*
* 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
@@ -20,12 +21,13 @@
/**
* \file htdocs/user/group/fiche.php
* \brief Onglet groupes utilisateurs
- * \version $Id: fiche.php,v 1.70 2011/08/17 15:56:24 eldy Exp $
+ * \version $Id: fiche.php,v 1.71 2011/08/19 07:22:18 hregis Exp $
*/
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
+if($conf->multicompany->enabled) require_once(DOL_DOCUMENT_ROOT."/multicompany/class/actions_multicompany.class.php");
// Defini si peux lire/modifier utilisateurs et permisssions
$canreadperms=($user->admin || $user->rights->user->user->lire);
@@ -45,6 +47,11 @@ $langs->load("other");
// Security check
$result = restrictedArea($user, 'user', $_GET["id"], 'usergroup', 'user');
+if($conf->multicompany->enabled && $conf->entity > 0 && $conf->global->MULTICOMPANY_MODE_TRANVERSAL)
+{
+ accessforbidden();
+}
+
$action=GETPOST("action");
$confirm=GETPOST("confirm");
$userid=GETPOST("user","int");
@@ -84,11 +91,11 @@ if ($_POST["action"] == 'add')
$action="create"; // Go back to create page
}
- if (! $message)
- {
- $object->nom = trim($_POST["nom"]);
- $object->globalgroup = $_POST["globalgroup"];
- $object->note = trim($_POST["note"]);
+ if (! $message)
+ {
+ $object->nom = trim($_POST["nom"]);
+ $object->entity = $_POST["entity"];
+ $object->note = trim($_POST["note"]);
$db->begin();
@@ -127,10 +134,10 @@ if ($action == 'adduser' || $action =='removeuser')
$object->fetch($_GET["id"]);
$object->oldcopy=dol_clone($object);
- $edituser = new User($db);
- $edituser->fetch($userid);
- if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,GETPOST('entity'));
- if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,GETPOST('entity'));
+ $edituser = new User($db);
+ $edituser->fetch($userid);
+ if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,($conf->global->MULTICOMPANY_MODE_TRANVERSAL?$_POST["entity"]:$object->entity));
+ if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,($conf->global->MULTICOMPANY_MODE_TRANVERSAL?$_GET["entity"]:$object->entity));
if ($result > 0)
{
@@ -162,9 +169,9 @@ if ($_POST["action"] == 'update')
$object->oldcopy=dol_clone($object);
- $object->nom = trim($_POST["group"]);
- $object->globalgroup = $_POST["globalgroup"];
- $object->note = dol_htmlcleanlastbr($_POST["note"]);
+ $object->nom = trim($_POST["group"]);
+ $object->entity = $_POST["entity"];
+ $object->note = dol_htmlcleanlastbr($_POST["note"]);
$ret=$object->update();
@@ -208,23 +215,24 @@ if ($action == 'create')
print '';
- print "".'| '.$langs->trans("Name").' | ';
- print ' | ';
-
- // Global group
- if ($conf->multicompany->enabled)
- {
- if ($conf->entity == 1)
- {
- print "".'| '.$langs->trans("GlobalGroup").' | ';
- $checked=(empty($_POST['globalgroup']) ? '' : ' checked');
- print ' | ';
- }
- else
- {
- print '';
- }
- }
+ print " ".'| '.$langs->trans("Name").' | ';
+ print ' | ';
+
+ // Multicompany
+ if ($conf->multicompany->enabled)
+ {
+ if ($conf->entity == 0 && !$conf->global->MULTICOMPANY_MODE_TRANVERSAL)
+ {
+ $mc = new ActionsMulticompany($db);
+ print "".'| '.$langs->trans("Entity").' | ';
+ print "".$mc->select_entities($conf->entity);
+ print " | \n";
+ }
+ else
+ {
+ print '';
+ }
+ }
print "".'| '.$langs->trans("Note").' | ';
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_USER)
@@ -264,64 +272,77 @@ else
$title = $langs->trans("Group");
dol_fiche_head($head, 'group', $title, 0, 'group');
- /*
- * Confirmation suppression
- */
- if ($action == 'delete')
- {
- $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("DeleteAGroup"),$langs->trans("ConfirmDeleteGroup",$object->name),"confirm_delete", '',0,1);
- if ($ret == 'html') print ' ';
- }
+ /*
+ * Confirmation suppression
+ */
+ if ($action == 'delete')
+ {
+ $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("DeleteAGroup"),$langs->trans("ConfirmDeleteGroup",$object->name),"confirm_delete", '',0,1);
+ if ($ret == 'html') print ' ';
+ }
- /*
- * Fiche en mode visu
- */
+ /*
+ * Fiche en mode visu
+ */
- if ($action != 'edit')
- {
- print '';
+ if ($action != 'edit')
+ {
+ print '';
- // Ref
- print '| '.$langs->trans("Ref").' | ';
- print '';
- print $form->showrefnav($object,'id','',$user->rights->user->user->lire || $user->admin);
- print ' | ';
- print ' ';
+ // Ref
+ print '| '.$langs->trans("Ref").' | ';
+ print '';
+ print $form->showrefnav($object,'id','',$user->rights->user->user->lire || $user->admin);
+ print ' | ';
+ print ' ';
- // Name
- print '| '.$langs->trans("Name").' | ';
- print ''.$object->nom;
- if (empty($object->entity))
- {
- print img_picto($langs->trans("GlobalGroup"),'redstar');
- }
- print " | \n";
+ // Name
+ print '| '.$langs->trans("Name").' | ';
+ print ''.$object->nom;
+ if (empty($object->entity))
+ {
+ 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";
+ }
+ }
- // Note
- print '| '.$langs->trans("Note").' | ';
- print ''.dol_htmlentitiesbr($object->note).' | ';
- print " \n";
- print " \n";
+ // Note
+ print '| '.$langs->trans("Note").' | ';
+ print ''.dol_htmlentitiesbr($object->note).' | ';
+ print " \n";
+ print " \n";
- print '';
+ print '';
- /*
- * Barre d'actions
- */
- print '';
+ /*
+ * Barre d'actions
+ */
+ print ' \n";
- print " \n";
+ print " \n";
+ print " \n";
dol_htmloutput_errors($message);
@@ -336,12 +357,15 @@ else
$exclude = array();
$userslist = $object->listUsersForGroup();
-
+
if (! empty($userslist))
{
- foreach($userslist as $useringroup)
+ if( !($conf->multicompany->enabled && $conf->global->MULTICOMPANY_MODE_TRANVERSAL))
{
- $exclude[]=$useringroup->id;
+ foreach($userslist as $useringroup)
+ {
+ $exclude[]=$useringroup->id;
+ }
}
}
@@ -350,12 +374,27 @@ else
print ''."\n";
@@ -368,6 +407,8 @@ else
print '';
print '';
print '| '.$langs->trans("Login").' | ';
+ if($conf->multicompany->enabled && $conf->entity==0)
+ print ''.$langs->trans("Entity").' | ';
print ''.$langs->trans("Lastname").' | ';
print ''.$langs->trans("Firstname").' | ';
print ''.$langs->trans("Status").' | ';
@@ -377,34 +418,40 @@ else
if (! empty($userslist))
{
- $var=True;
-
- foreach($userslist as $useringroup)
- {
- $var=!$var;
-
- print " ";
- print '| ';
- print ''.img_object($langs->trans("ShowUser"),"user").' '.$useringroup->login.'';
- if ($useringroup->admin && ! $useringroup->entity) print img_picto($langs->trans("SuperAdministrator"),'redstar');
- else if ($useringroup->admin) print img_picto($langs->trans("Administrator"),'star');
- print ' | ';
- print ''.ucfirst(stripslashes($useringroup->lastname)).' | ';
- print ''.ucfirst(stripslashes($useringroup->firstname)).' | ';
- print ''.$useringroup->getLibStatut(5).' | ';
- print ' | ';
- print '';
- if ($user->admin)
- {
- print '';
- print img_delete($langs->trans("RemoveFromGroup"));
- }
- else
- {
- print "-";
- }
- print " | \n";
- }
+ $var=True;
+
+ foreach($userslist as $useringroup)
+ {
+ $var=!$var;
+
+ print "";
+ print '| ';
+ print ''.img_object($langs->trans("ShowUser"),"user").' '.$useringroup->login.'';
+ if ($useringroup->admin && ! $useringroup->entity) print img_redstar($langs->trans("SuperAdministrator"));
+ 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." | ";
+ }
+ print ''.ucfirst(stripslashes($useringroup->lastname)).' | ';
+ print ''.ucfirst(stripslashes($useringroup->firstname)).' | ';
+ print ''.$useringroup->getLibStatut(5).' | ';
+ print ' | ';
+ print '';
+ if ($user->admin)
+ {
+ print '';
+ print img_delete($langs->trans("RemoveFromGroup"));
+ }
+ else
+ {
+ print "-";
+ }
+ print " | \n";
+ }
}
else
{
@@ -427,21 +474,21 @@ else
print '| '.$langs->trans("Name").' | ';
print '';
print " | \n";
-
- // Global group
+
+ // Multicompany
if ($conf->multicompany->enabled)
{
- if ($conf->entity == 1)
+ if ($conf->entity == 0 && !$conf->global->MULTICOMPANY_MODE_TRANVERSAL)
{
- print "".'| '.$langs->trans("GlobalGroup").' | ';
- $checked=(empty($object->entity) ? ' checked' : '');
- print ' | ';
- }
- else
- {
- $value=(empty($object->entity) ? 1 : 0);
- print '';
+ $mc = new ActionsMulticompany($db);
+ print " ".'| '.$langs->trans("Entity").' | ';
+ print "".$mc->select_entities($object->entity);
+ print " | \n";
}
+ else
+ {
+ print '';
+ }
}
print '| '.$langs->trans("Note").' | ';
@@ -473,5 +520,5 @@ else
$db->close();
-llxFooter('$Date: 2011/08/17 15:56:24 $ - $Revision: 1.70 $');
+llxFooter('$Date: 2011/08/19 07:22:18 $ - $Revision: 1.71 $');
?>
diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php
index 2c6ccbd1606..55e4a9bbea7 100644
--- a/htdocs/user/group/index.php
+++ b/htdocs/user/group/index.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2002-2003 Rodolphe Quiedeville
* Copyright (C) 2004-2011 Laurent Destailleur
* Copyright (C) 2005-2010 Regis Houssin
+ * Copyright (C) 2011 Herve Prot
*
* 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 +22,7 @@
* \file htdocs/user/group/index.php
* \ingroup core
* \brief Page of user groups
- * \version $Id: index.php,v 1.25 2011/08/17 15:56:24 eldy Exp $
+ * \version $Id: index.php,v 1.26 2011/08/19 07:22:18 hregis Exp $
*/
require("../../main.inc.php");
@@ -58,7 +59,10 @@ 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";
-$sql.= " WHERE g.entity IN (0,".$conf->entity.")";
+if($conf->entity==0)
+ $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"]."%')";
@@ -77,6 +81,9 @@ if ($resql)
print "";
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);
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";
@@ -93,6 +100,14 @@ if ($resql)
print img_picto($langs->trans("GlobalGroup"),'redstar');
}
print "";
+ //multicompany
+ if($conf->multicompany->enabled && $conf->entity==0)
+ {
+ require_once(DOL_DOCUMENT_ROOT."/multicompany/class/actions_multicompany.class.php");
+ $mc = new ActionsMulticompany($db);
+ $mc->getInfo($obj->entity);
+ print ''.$mc->label.' | ';
+ }
print ''.$obj->nb.' | ';
print ''.dol_print_date($db->jdate($obj->datec),"dayhour").' | ';
print "\n";
@@ -108,6 +123,6 @@ else
$db->close();
-llxFooter('$Date: 2011/08/17 15:56:24 $ - $Revision: 1.25 $');
+llxFooter('$Date: 2011/08/19 07:22:18 $ - $Revision: 1.26 $');
?>
diff --git a/htdocs/user/index.php b/htdocs/user/index.php
index f13127df380..e9e315b4540 100644
--- a/htdocs/user/index.php
+++ b/htdocs/user/index.php
@@ -21,10 +21,12 @@
* \file htdocs/user/index.php
* \ingroup core
* \brief Page of users
- * \version $Id: index.php,v 1.52 2011/08/17 15:56:25 eldy Exp $
+ * \version $Id: index.php,v 1.53 2011/08/19 07:22:17 hregis Exp $
*/
require("../main.inc.php");
+if($conf->multicompany->enabled) dol_include_once("/multicompany/class/actions_multicompany.class.php");
+
if (! $user->rights->user->user->lire && ! $user->admin) accessforbidden();
@@ -67,7 +69,10 @@ $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";
-$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
+if($conf->entity==0)
+ $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 ($_POST["search_user"])
{
@@ -120,11 +125,18 @@ if ($result)
$companystatic->canvas=$obj->canvas;
print $companystatic->getNomUrl(1);
}
+ else if ($conf->multicompany->enabled)
+ {
+ $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
@@ -149,5 +161,5 @@ else
$db->close();
-llxFooter('$Date: 2011/08/17 15:56:25 $ - $Revision: 1.52 $');
+llxFooter('$Date: 2011/08/19 07:22:17 $ - $Revision: 1.53 $');
?>
| | |