forked from Wavyzz/dolibarr
Qual: add $mc global object (multicompany)
This commit is contained in:
@@ -193,9 +193,11 @@ class Conf
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Load multicompany configuration
|
||||
if (! empty($this->multicompany->enabled))
|
||||
// Object $mc
|
||||
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
|
||||
{
|
||||
global $mc;
|
||||
|
||||
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
|
||||
if ($ret)
|
||||
{
|
||||
|
||||
@@ -266,17 +266,10 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
||||
|
||||
// Entity field
|
||||
$select_entity='';
|
||||
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY) && empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX))
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX))
|
||||
{
|
||||
$rowspan++;
|
||||
|
||||
$res=dol_include_once('/multicompany/class/actions_multicompany.class.php');
|
||||
if ($res)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
|
||||
$select_entity=$mc->select_entities($lastentity, 'tabindex="3"', 1);
|
||||
}
|
||||
$select_entity = $mc->select_entities($lastentity, 'tabindex="3"', 1);
|
||||
}
|
||||
|
||||
// Security graphical code
|
||||
|
||||
@@ -734,23 +734,13 @@ else
|
||||
$heightforframes=48;
|
||||
|
||||
// Switch to another entity
|
||||
if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY))
|
||||
if (! empty($conf->multicompany->enabled) && GETPOST('action') == 'switchentity')
|
||||
{
|
||||
if (GETPOST('action') == 'switchentity')
|
||||
{
|
||||
$res = @dol_include_once("/multicompany/class/actions_multicompany.class.php");
|
||||
|
||||
if ($res)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
|
||||
if($mc->switchEntity(GETPOST('entity')) >= 0)
|
||||
if ($mc->switchEntity(GETPOST('entity')) >= 0)
|
||||
{
|
||||
Header("Location: ".DOL_URL_ROOT.'/');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1032,7 +1022,9 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
|
||||
*/
|
||||
function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='')
|
||||
{
|
||||
global $user, $conf, $langs, $db, $dolibarr_main_authentication;
|
||||
global $user, $conf, $langs, $db;
|
||||
global $dolibarr_main_authentication;
|
||||
global $mc;
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
@@ -1217,17 +1209,11 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
||||
|
||||
print $form->textwithtooltip('',$loginhtmltext,2,1,$logintext,'',1);
|
||||
|
||||
// Select entity
|
||||
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY))
|
||||
// Show entity info
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
$res=@dol_include_once('/multicompany/class/actions_multicompany.class.php');
|
||||
|
||||
if ($res)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
$mc->showInfo($conf->entity);
|
||||
}
|
||||
}
|
||||
|
||||
print $form->textwithtooltip('',$logouthtmltext,2,1,$logouttext,'',1);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ if (! defined('NOREQUIRETRAN'))
|
||||
}
|
||||
|
||||
/*
|
||||
* Creation objet $db
|
||||
* Object $db
|
||||
*/
|
||||
if (! defined('NOREQUIREDB'))
|
||||
{
|
||||
@@ -111,7 +111,7 @@ if (! defined('NOREQUIREDB'))
|
||||
unset($conf->db->pass); // This is to avoid password to be shown in memory/swap dump
|
||||
|
||||
/*
|
||||
* Creation objet $user
|
||||
* Object $user
|
||||
*/
|
||||
if (! defined('NOREQUIREUSER'))
|
||||
{
|
||||
@@ -129,23 +129,22 @@ if (! defined('NOREQUIREDB'))
|
||||
{
|
||||
$conf->entity = $_SESSION["dol_entity"];
|
||||
}
|
||||
elseif (! empty($_ENV["dol_entity"])) // Entity inside a CLI script
|
||||
else if (! empty($_ENV["dol_entity"])) // Entity inside a CLI script
|
||||
{
|
||||
$conf->entity = $_ENV["dol_entity"];
|
||||
}
|
||||
elseif (isset($_POST["loginfunction"]) && GETPOST("entity")) // Just after a login page
|
||||
else if (isset($_POST["loginfunction"]) && GETPOST("entity")) // Just after a login page
|
||||
{
|
||||
$conf->entity = GETPOST("entity",'int');
|
||||
}
|
||||
else
|
||||
else if (! empty($conf->file->cookie_cryptkey))
|
||||
{
|
||||
$prefix=dol_getprefix();
|
||||
$entityCookieName = 'DOLENTITYID_'.$prefix;
|
||||
if (! empty($_COOKIE[$entityCookieName]) && ! empty($conf->file->cookie_cryptkey)) // Just for view specific login page
|
||||
if (! empty($_COOKIE[$entityCookieName])) // Just for view specific login page
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT."/core/class/cookie.class.php");
|
||||
$lastuser = '';
|
||||
$lastentity = '';
|
||||
$lastuser = ''; $lastentity = '';
|
||||
$entityCookie = new DolCookie($conf->file->cookie_cryptkey);
|
||||
$cookieValue = $entityCookie->_getCookie($entityCookieName);
|
||||
list($lastuser, $lastentity) = explode('|', $cookieValue);
|
||||
|
||||
@@ -746,7 +746,6 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
||||
{
|
||||
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
print "</td></tr>\n";
|
||||
@@ -1076,7 +1075,6 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
$mc->getInfo($fuser->entity);
|
||||
print $mc->label;
|
||||
}
|
||||
@@ -1327,7 +1325,6 @@ else
|
||||
{
|
||||
if ($conf->entity == 1 && $conf->multicompany->transverse_mode)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
print '</td><td valign="top">'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
}
|
||||
@@ -1378,9 +1375,8 @@ else
|
||||
print img_object($langs->trans("ShowGroup"),"group").' '.$group->nom;
|
||||
}
|
||||
print '</td>';
|
||||
if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
$mc->getInfo($group->usergroup_entity);
|
||||
print '<td class="valeur">'.$mc->label."</td>";
|
||||
}
|
||||
@@ -1594,9 +1590,8 @@ else
|
||||
//Multicompany
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if(empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
print "</td></tr>\n";
|
||||
|
||||
@@ -233,7 +233,6 @@ if ($action == 'create')
|
||||
{
|
||||
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
print "</td></tr>\n";
|
||||
@@ -311,7 +310,6 @@ else
|
||||
// Multicompany
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
$mc->getInfo($object->entity);
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
|
||||
print '<td width="75%" class="valeur">'.$mc->label;
|
||||
@@ -382,7 +380,6 @@ else
|
||||
{
|
||||
if ($conf->entity == 1 && $conf->multicompany->transverse_mode)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
print '</td><td valign="top">'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
}
|
||||
@@ -435,7 +432,6 @@ else
|
||||
print '<td>'.$useringroup->firstname.'</td>';
|
||||
if(! empty($conf->multicompany->enabled) && $conf->entity == 1)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
$mc->getInfo($useringroup->usergroup_entity);
|
||||
print '<td class="valeur">'.$mc->label."</td>";
|
||||
}
|
||||
@@ -480,7 +476,6 @@ else
|
||||
{
|
||||
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($object->entity);
|
||||
print "</td></tr>\n";
|
||||
|
||||
@@ -108,8 +108,6 @@ if ($resql)
|
||||
//multicompany
|
||||
if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1)
|
||||
{
|
||||
dol_include_once("/multicompany/class/actions_multicompany.class.php");
|
||||
$mc = new ActionsMulticompany($db);
|
||||
$mc->getInfo($obj->entity);
|
||||
print '<td align="center">'.$mc->label.'</td>';
|
||||
}
|
||||
|
||||
@@ -153,7 +153,6 @@ if ($resql)
|
||||
}
|
||||
else
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
$mc->getInfo($obj->entity);
|
||||
print $mc->label;
|
||||
}
|
||||
@@ -232,7 +231,6 @@ if ($canreadperms)
|
||||
print "</td>";
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
$mc->getInfo($obj->entity);
|
||||
print '<td>';
|
||||
print $mc->label;
|
||||
|
||||
@@ -137,7 +137,6 @@ if ($result)
|
||||
}
|
||||
else
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
$mc->getInfo($obj->entity);
|
||||
print $mc->label;
|
||||
}
|
||||
|
||||
@@ -208,34 +208,27 @@ elseif (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.
|
||||
|
||||
// Entity combobox
|
||||
$select_entity='';
|
||||
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY) && empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX) && ! $disabled)
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX) && ! $disabled)
|
||||
{
|
||||
$rowspan++;
|
||||
$lastuser='';
|
||||
$lastentity = GETPOST('entity');
|
||||
|
||||
if (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE))
|
||||
if (! empty($conf->global->MULTICOMPANY_COOKIE_ENABLED))
|
||||
{
|
||||
$prefix=dol_getprefix();
|
||||
$entityCookieName = 'DOLENTITYID_'.$prefix;
|
||||
if (isset($_COOKIE[$entityCookieName]))
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/cookie.class.php");
|
||||
|
||||
$cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' );
|
||||
|
||||
$entityCookie = new DolCookie($cryptkey);
|
||||
$lastuser = ''; $lastentity = '';
|
||||
$entityCookie = new DolCookie($conf->file->cookie_cryptkey);
|
||||
$cookieValue = $entityCookie->_getCookie($entityCookieName);
|
||||
list($lastuser, $lastentity) = explode('|', $cookieValue);
|
||||
}
|
||||
}
|
||||
|
||||
$res=dol_include_once('/multicompany/class/actions_multicompany.class.php');
|
||||
if ($res)
|
||||
{
|
||||
$mc = new ActionsMulticompany($db);
|
||||
$select_entity = $mc->select_entities($lastentity,'tabindex="2"');
|
||||
}
|
||||
}
|
||||
|
||||
// Security graphical code
|
||||
|
||||
Reference in New Issue
Block a user