From c5691093e4e9a4f4b074b31d7fbdc3e5581d46ba Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 19 Aug 2011 09:26:41 +0000 Subject: [PATCH] multi-company module enhancement --- htdocs/core/class/html.form.class.php | 6 +- htdocs/user/fiche.php | 89 ++++++++++++++------------- htdocs/user/group/fiche.php | 18 +++--- 3 files changed, 57 insertions(+), 56 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fdcd213a5d0..db8ceff7e61 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.197 2011/08/19 07:22:17 hregis Exp $ + * \version $Id: html.form.class.php,v 1.198 2011/08/19 09:26:41 hregis Exp $ */ @@ -845,7 +845,7 @@ class Form $out.= '>'; } $out.= $userstatic->getFullName($langs); - if($conf->entity==0 && !$conf->global->MULTICOMPANY_MODE_TRANVERSAL) + if($conf->entity==0 && !$conf->global->MULTICOMPANY_TRANSVERSE_MODE) $out.=" (".$obj->label.")"; //if ($obj->admin) $out.= ' *'; @@ -3554,7 +3554,7 @@ class Form $out.= '>'; $out.= $obj->nom; - if($conf->entity==0 && !$conf->global->MULTICOMPANY_MODE_TRANVERSAL) + if($conf->entity==0 && !$conf->global->MULTICOMPANY_TRANSVERSE_MODE) $out.= " (".$obj->label.")"; $out.= ''; diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 36c61b46be7..c2cb538a04f 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.277 2011/08/19 09:26:10 hregis Exp $ + * \version $Id: fiche.php,v 1.278 2011/08/19 09:26:41 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_MODE_TRANVERSAL) +if($conf->multicompany->enabled && $conf->entity > 0 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { accessforbidden(); } @@ -203,7 +203,7 @@ if ($_POST["action"] == 'add' && $canadduser) $edituser->note = $_POST["note"]; $edituser->ldap_sid = $_POST["ldap_sid"]; // If multicompany is off, admin users must all be on entity 0. - $edituser->entity = (empty($_POST["entity"]) || empty($conf->multicompany->enabled) ? 0 : $_POST["entity"]); + $edituser->entity = ( ! empty($_POST["admin"]) && (! empty($_POST["superadmin"]) || empty($_POST["entity"]) || empty($conf->multicompany->enabled)) ? 0 : $_POST["entity"]); $db->begin(); @@ -243,8 +243,8 @@ if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield) $edituser = new User($db); $edituser->fetch($_GET["id"]); - if ($action == 'addgroup') $edituser->SetInGroup($group,($conf->global->MULTICOMPANY_MODE_TRANVERSAL?$_POST["entity"]:$editgroup->entity)); - if ($action == 'removegroup') $edituser->RemoveFromGroup($group,($conf->global->MULTICOMPANY_MODE_TRANVERSAL?$_GET["entity"]:$editgroup->entity)); + if ($action == 'addgroup') $edituser->SetInGroup($group,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?GETPOST("entity"):$editgroup->entity)); + if ($action == 'removegroup') $edituser->RemoveFromGroup($group,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?GETPOST("entity"):$editgroup->entity)); if ($result > 0) { @@ -299,7 +299,7 @@ if ($action == 'update' && ! $_POST["cancel"]) $edituser->webcal_login = $_POST["webcal_login"]; $edituser->phenix_login = $_POST["phenix_login"]; $edituser->phenix_pass = $_POST["phenix_pass"]; - $edituser->entity = ( empty($_POST["entity"]) ? 0 : $_POST["entity"]); + $edituser->entity = ( (! empty($_POST["superadmin"]) && ! empty($_POST["admin"]) || empty($_POST["entity"])) ? 0 : $_POST["entity"]); if (GETPOST('deletephoto')) $edituser->photo=''; if (! empty($_FILES['photo']['name'])) $edituser->photo = dol_sanitizeFileName($_FILES['photo']['name']); @@ -666,7 +666,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; print $form->selectyesno('admin',$_POST["admin"],1); - /*if (! empty($conf->multicompany->enabled) && ! $user->entity) + if (! empty($conf->multicompany->enabled) && ! $user->entity && ! $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { if ($conf->use_javascript_ajax) { @@ -688,14 +688,14 @@ if (($action == 'create') || ($action == 'adduserldap')) $checked=($_POST["superadmin"]?' checked':''); $disabled=($_POST["superadmin"]?'':' disabled'); print ' '.$langs->trans("SuperAdministrator"); - }*/ + } print "\n"; } //Multicompany if ($conf->multicompany->enabled) { - if ($conf->entity == 0 && !$conf->global->MULTICOMPANY_MODE_TRANVERSAL) + if ($conf->entity == 0 && ! $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { $mc = new ActionsMulticompany($db); print "".''.$langs->trans("Entity").''; @@ -1259,7 +1259,7 @@ else if (! empty($groupslist)) { - if( !($conf->multicompany->enabled && $conf->global->MULTICOMPANY_MODE_TRANVERSAL)) + if( !($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { foreach($groupslist as $groupforuser) { @@ -1282,7 +1282,7 @@ else // Multicompany if ($conf->multicompany->enabled) { - if ($conf->entity == 0 && $conf->global->MULTICOMPANY_MODE_TRANVERSAL) + if ($conf->entity == 0 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { $mc = new ActionsMulticompany($db); print ''.$langs->trans("Entity").''; @@ -1489,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 && ! $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { if ($conf->use_javascript_ajax) { @@ -1517,52 +1517,53 @@ 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 ''; - if ($fuser->societe_id) + if ($conf->multicompany->enabled) { - print $langs->trans("External"); - } - else if ($fuser->ldap_sid) - { - print $langs->trans("DomainUser"); + if ($conf->entity == 0 && ! $conf->global->MULTICOMPANY_TRANSVERSE_MODE) + { + $mc = new ActionsMulticompany($db); + print "".''.$langs->trans("Entity").''; + print "".$mc->select_entities($fuser->entity); + print "\n"; + } + else + { + print ''; + } } else { - print $langs->trans("Internal"); + // Type + print ''.$langs->trans("Type").''; + print ''; + if ($fuser->societe_id) + { + print $langs->trans("External"); + } + else if ($fuser->ldap_sid) + { + print $langs->trans("DomainUser"); + } + else + { + print $langs->trans("Internal"); + } + print ''; } - print ''; - } + // Tel pro print "".''.$langs->trans("PhonePro").''; print ''; @@ -1742,7 +1743,7 @@ else $db->close(); -llxFooter('$Date: 2011/08/19 09:26:10 $ - $Revision: 1.277 $'); +llxFooter('$Date: 2011/08/19 09:26:41 $ - $Revision: 1.278 $'); diff --git a/htdocs/user/group/fiche.php b/htdocs/user/group/fiche.php index 08989dede1c..d71c11072d1 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.72 2011/08/19 09:26:10 hregis Exp $ + * \version $Id: fiche.php,v 1.73 2011/08/19 09:26:42 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_MODE_TRANVERSAL) +if($conf->multicompany->enabled && $conf->entity > 0 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { accessforbidden(); } @@ -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_MODE_TRANVERSAL?$_POST["entity"]:$object->entity)); - if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,($conf->global->MULTICOMPANY_MODE_TRANVERSAL?$_GET["entity"]:$object->entity)); + 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 ($result > 0) { @@ -221,7 +221,7 @@ if ($action == 'create') // Multicompany if ($conf->multicompany->enabled) { - if ($conf->entity == 0 && !$conf->global->MULTICOMPANY_MODE_TRANVERSAL) + if ($conf->entity == 0 && !$conf->global->MULTICOMPANY_TRANSVERSE_MODE) { $mc = new ActionsMulticompany($db); print "".''.$langs->trans("Entity").''; @@ -360,7 +360,7 @@ else if (! empty($userslist)) { - if( !($conf->multicompany->enabled && $conf->global->MULTICOMPANY_MODE_TRANVERSAL)) + if( !($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { foreach($userslist as $useringroup) { @@ -382,7 +382,7 @@ else // Multicompany if ($conf->multicompany->enabled) { - if ($conf->entity == 0 && $conf->global->MULTICOMPANY_MODE_TRANVERSAL) + if ($conf->entity == 0 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { $mc = new ActionsMulticompany($db); print ''.$langs->trans("Entity").''; @@ -478,7 +478,7 @@ else // Multicompany if ($conf->multicompany->enabled) { - if ($conf->entity == 0 && !$conf->global->MULTICOMPANY_MODE_TRANVERSAL) + if ($conf->entity == 0 && !$conf->global->MULTICOMPANY_TRANSVERSE_MODE) { $mc = new ActionsMulticompany($db); print "".''.$langs->trans("Entity").''; @@ -520,5 +520,5 @@ else $db->close(); -llxFooter('$Date: 2011/08/19 09:26:10 $ - $Revision: 1.72 $'); +llxFooter('$Date: 2011/08/19 09:26:42 $ - $Revision: 1.73 $'); ?>