Fix: more bugs with multicompany

This commit is contained in:
Regis Houssin 2012-07-07 10:57:54 +02:00
parent 8ee06f02b1
commit 250e3555c3
6 changed files with 30 additions and 24 deletions

View File

@ -199,7 +199,7 @@ class Conf
{
$modulename=strtolower($reg[1]);
if ($modulename == 'propale') $modulename='propal';
$this->$modulename=(object) array();
if (! is_object($this->$modulename)) $this->$modulename=(object) array();
$this->$modulename->enabled=true;
$this->modules[]=$modulename; // Add this module in list of enabled modules
}

View File

@ -929,7 +929,7 @@ class Form
* @param int $force_entity Possibility to force entity
* @return void
*/
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=false)
{
print $this->select_dolusers($selected,$htmlname,$show_empty,$exclude,$disabled,$include,$enableonly,$force_entity);
}
@ -947,7 +947,7 @@ class Form
* @param int $force_entity Possibility to force entity
* @return string HTML select string
*/
function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=false)
{
global $conf,$user,$langs;

View File

@ -358,7 +358,7 @@ if (! defined('NOLOGIN'))
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf,GETPOST('entity'));
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf,GETPOST('entity','int',2));
if ($result < 0) {
$error++;
}
@ -742,7 +742,7 @@ $heightforframes=48;
// Switch to another entity
if (! empty($conf->multicompany->enabled) && GETPOST('action') == 'switchentity')
{
if ($mc->switchEntity(GETPOST('entity','int')) > 0)
if ($mc->switchEntity(GETPOST('entity','int',2)) > 0)
{
Header("Location: ".DOL_URL_ROOT.'/');
exit;

View File

@ -1999,7 +1999,7 @@ class User extends CommonObject
}
else
{
if ($all) $sql.= " WHERE entity = is not null";
if ($all) $sql.= " WHERE entity IS NOT NULL"; // all users except superadmin
else $sql.= " WHERE entity = ".$conf->entity;
if ($limitTo == 'active') $sql.= " AND statut = 1";
}

View File

@ -203,18 +203,22 @@ if ($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.
if($conf->multicompany->enabled)
if ($conf->multicompany->enabled)
{
if($conf->multicompany->transverse_mode || ! empty($_POST["superadmin"]))
if (! empty($_POST["superadmin"]))
{
$edituser->entity=0;
$edituser->entity = 0;
}
else if ($conf->multicompany->transverse_mode)
{
$edituser->entity = 1; // all users in master entity
}
else
{
$edituser->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]);
}
}
else if(! empty($_POST["admin"]))
else if (! empty($_POST["admin"]))
{
$edituser->entity=0;
}
@ -317,11 +321,15 @@ if ($action == 'update' && ! $_POST["cancel"])
$edituser->webcal_login = $_POST["webcal_login"];
$edituser->phenix_login = $_POST["phenix_login"];
$edituser->phenix_pass = $_POST["phenix_pass"];
if($conf->multicompany->enabled)
if ($conf->multicompany->enabled)
{
if($conf->multicompany->transverse_mode || ! empty($_POST["superadmin"]))
if (! empty($_POST["superadmin"]))
{
$edituser->entity=0;
$edituser->entity = 0;
}
else if ($conf->multicompany->transverse_mode)
{
$edituser->entity = 1; // all users in master entity
}
else
{

View File

@ -51,7 +51,7 @@ $userid=GETPOST('user', 'int');
// Security check
$result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user');
if(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode)
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode)
{
accessforbidden();
}
@ -83,7 +83,7 @@ if ($action == 'confirm_delete' && $confirm == "yes")
*/
if ($action == 'add')
{
if($caneditperms)
if ($caneditperms)
{
$message="";
if (! $_POST["nom"])
@ -96,8 +96,8 @@ if ($action == 'add')
{
$object->nom = trim($_POST["nom"]);
$object->note = trim($_POST["note"]);
if($conf->multicompany->enabled && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0;
if ($conf->multicompany->enabled && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0;
else $object->entity = $_POST["entity"];
$db->begin();
@ -108,7 +108,7 @@ if ($action == 'add')
{
$db->commit();
Header("Location: fiche.php?id=".$object->id);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
@ -145,7 +145,7 @@ if ($action == 'adduser' || $action =='removeuser')
if ($result > 0)
{
header("Location: fiche.php?id=".$object->id);
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
@ -164,7 +164,7 @@ if ($action == 'adduser' || $action =='removeuser')
if ($action == 'update')
{
if($caneditperms)
if ($caneditperms)
{
$message="";
@ -176,8 +176,8 @@ if ($action == 'update')
$object->nom = trim($_POST["group"]);
$object->note = dol_htmlcleanlastbr($_POST["note"]);
if($conf->multicompany->enabled && !empty($conf->multicompany->transverse_mode)) $object->entity = 0;
if ($conf->multicompany->enabled && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0;
else $object->entity = $_POST["entity"];
$ret=$object->update();
@ -504,7 +504,5 @@ else
}
llxFooter();
$db->close();
?>