From ef6706a6b94802189236953f5d44cf5aadc352b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Feb 2012 12:02:12 +0100 Subject: [PATCH] New: Add hook toprightmenu --- htdocs/core/class/hookmanager.class.php | 2 +- htdocs/main.inc.php | 1971 ++++++++++++----------- 2 files changed, 1004 insertions(+), 969 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 9acad8b7466..2b7344eaf1c 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -125,7 +125,7 @@ class HookManager * @param Object &$object Object to use hooks on * @param string &$action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) * @return mixed For doActions,formObjectOptions: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO. - * For printSearchForm,printLeftBlock: Return HTML string. + * For printSearchForm,printLeftBlock,printTopRightMenu,...: Return HTML string. * $this->error or this->errors are also defined by class called by this function if error. */ function executeHooks($method, $parameters=false, &$object='', &$action='') diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 5a49f7442be..9f34333ac27 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1,33 +1,33 @@ * Copyright (C) 2003 Xavier Dutoit - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011 Philippe Grand - * Copyright (C) 2008 Matteli - * Copyright (C) 2011 Juanjo Menent - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +* Copyright (C) 2004-2011 Laurent Destailleur +* Copyright (C) 2004 Sebastien Di Cintio +* Copyright (C) 2004 Benoit Mortier +* Copyright (C) 2005-2012 Regis Houssin +* Copyright (C) 2011 Philippe Grand +* Copyright (C) 2008 Matteli +* Copyright (C) 2011 Juanjo Menent +* +* 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 +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ /** * \file htdocs/main.inc.php - * \ingroup core - * \brief File that defines environment for Dolibarr pages only (variables not required by scripts) - */ +* \ingroup core +* \brief File that defines environment for Dolibarr pages only (variables not required by scripts) +*/ //@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP @@ -36,31 +36,33 @@ $micro_start_time=0; if (! empty($_SERVER['DOL_TUNING'])) { - list($usec, $sec) = explode(" ", microtime()); - $micro_start_time=((float) $usec + (float) $sec); - // Add Xdebug code coverage - //define('XDEBUGCOVERAGE',1); - if (defined('XDEBUGCOVERAGE')) { xdebug_start_code_coverage(); } + list($usec, $sec) = explode(" ", microtime()); + $micro_start_time=((float) $usec + (float) $sec); + // Add Xdebug code coverage + //define('XDEBUGCOVERAGE',1); + if (defined('XDEBUGCOVERAGE')) { + xdebug_start_code_coverage(); + } } // Removed magic_quotes if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP6 { - if (get_magic_quotes_gpc()) - { - // Forcing parameter setting magic_quotes_gpc and cleaning parameters - // (Otherwise he would have for each position, condition - // Reading stripslashes variable according to state get_magic_quotes_gpc). - // Off mode (recommended, you just do $db->escape when an insert / update. - function stripslashes_deep($value) - { - return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value)); - } - $_GET = array_map('stripslashes_deep', $_GET); - $_POST = array_map('stripslashes_deep', $_POST); - //$_COOKIE = array_map('stripslashes_deep', $_COOKIE); // Useless because a cookie should never be outputed on screen nor used into sql - @set_magic_quotes_runtime(0); - } + if (get_magic_quotes_gpc()) + { + // Forcing parameter setting magic_quotes_gpc and cleaning parameters + // (Otherwise he would have for each position, condition + // Reading stripslashes variable according to state get_magic_quotes_gpc). + // Off mode (recommended, you just do $db->escape when an insert / update. + function stripslashes_deep($value) + { + return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value)); + } + $_GET = array_map('stripslashes_deep', $_GET); + $_POST = array_map('stripslashes_deep', $_POST); + //$_COOKIE = array_map('stripslashes_deep', $_COOKIE); // Useless because a cookie should never be outputed on screen nor used into sql + @set_magic_quotes_runtime(0); + } } /** @@ -72,34 +74,34 @@ if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP6 */ function test_sql_and_script_inject($val, $type) { - $sql_inj = 0; - // For SQL Injection (only GET and POST are used to be included into bad escaped SQL requests) - if ($type != 2) - { - $sql_inj += preg_match('/delete[\s]+from/i', $val); - $sql_inj += preg_match('/create[\s]+table/i', $val); - $sql_inj += preg_match('/update.+set.+=/i', $val); - $sql_inj += preg_match('/insert[\s]+into/i', $val); - $sql_inj += preg_match('/select.+from/i', $val); - $sql_inj += preg_match('/union.+select/i', $val); - $sql_inj += preg_match('/(\.\.%2f)+/i', $val); - } - // For XSS Injection done by adding javascript with script - // This is all cases a browser consider text is javascript: - // When it found ' $value) - { - if (analyse_sql_and_script($value,$type)) - { - $var[$key] = $value; - } - else - { - print 'Access refused by SQL/Script injection protection in main.inc.php'; - exit; - } - } - return true; - } - else - { - return (test_sql_and_script_inject($var,$type) <= 0); - } + if (is_array($var)) + { + foreach ($var as $key => $value) + { + if (analyse_sql_and_script($value,$type)) + { + $var[$key] = $value; + } + else + { + print 'Access refused by SQL/Script injection protection in main.inc.php'; + exit; + } + } + return true; + } + else + { + return (test_sql_and_script_inject($var,$type) <= 0); + } } // Sanity check on URL @@ -172,70 +174,70 @@ register_shutdown_function('dol_shutdown'); // Detection browser if (isset($_SERVER["HTTP_USER_AGENT"])) { - // If phone/smartphone, we set phone os name. - if (preg_match('/android/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='android'; - elseif (preg_match('/blackberry/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='blackberry'; - elseif (preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='iphone'; - elseif (preg_match('/ipod/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='iphone'; - elseif (preg_match('/palm/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='palm'; - elseif (preg_match('/symbian/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='symbian'; - elseif (preg_match('/webos/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='webos'; - elseif (preg_match('/maemo/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='maemo'; - // MS products at end - elseif (preg_match('/iemobile/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='windowsmobile'; - elseif (preg_match('/windows ce/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='windowsmobile'; - // Name - if (preg_match('/firefox/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='firefox'; - elseif (preg_match('/chrome/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='chrome'; - elseif (preg_match('/iceweasel/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='iceweasel'; - elseif ((empty($conf->browser->phone) || preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) && preg_match('/safari/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='safari'; // Safari is often present in string but its not. - elseif (preg_match('/opera/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='opera'; - // MS products at end - elseif (preg_match('/msie/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='ie'; - else $conf->browser->name='unknown'; - // Other - if (in_array($conf->browser->name,array('firefox','iceweasel'))) $conf->browser->firefox=1; - //$conf->browser->phone='android'; + // If phone/smartphone, we set phone os name. + if (preg_match('/android/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='android'; + elseif (preg_match('/blackberry/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='blackberry'; + elseif (preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='iphone'; + elseif (preg_match('/ipod/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='iphone'; + elseif (preg_match('/palm/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='palm'; + elseif (preg_match('/symbian/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='symbian'; + elseif (preg_match('/webos/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='webos'; + elseif (preg_match('/maemo/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='maemo'; + // MS products at end + elseif (preg_match('/iemobile/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='windowsmobile'; + elseif (preg_match('/windows ce/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='windowsmobile'; + // Name + if (preg_match('/firefox/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='firefox'; + elseif (preg_match('/chrome/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='chrome'; + elseif (preg_match('/iceweasel/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='iceweasel'; + elseif ((empty($conf->browser->phone) || preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) && preg_match('/safari/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='safari'; // Safari is often present in string but its not. + elseif (preg_match('/opera/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='opera'; + // MS products at end + elseif (preg_match('/msie/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='ie'; + else $conf->browser->name='unknown'; + // Other + if (in_array($conf->browser->name,array('firefox','iceweasel'))) $conf->browser->firefox=1; + //$conf->browser->phone='android'; } // Force HTTPS if required ($conf->file->main_force_https is 0/1 or https dolibarr root url) if (! empty($conf->file->main_force_https)) { - $newurl=''; - if ($conf->file->main_force_https == '1') - { - if (! empty($_SERVER["SCRIPT_URI"])) // If SCRIPT_URI supported by server - { - if (preg_match('/^http:/i',$_SERVER["SCRIPT_URI"]) && ! preg_match('/^https:/i',$_SERVER["SCRIPT_URI"])) // If link is http - { - $newurl=preg_replace('/^http:/i','https:',$_SERVER["SCRIPT_URI"]); - } - } - else // Check HTTPS environment variable (Apache/mod_ssl only) - { - // $_SERVER["HTTPS"] is 'on' when link is https, otherwise $_SERVER["HTTPS"] is empty or 'off' - if (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') // If link is http - { - $newurl=preg_replace('/^http:/i','https:',DOL_MAIN_URL_ROOT).$_SERVER["REQUEST_URI"]; - } - } - } - else - { - $newurl=$conf->file->main_force_https.$_SERVER["REQUEST_URI"]; - } - // Start redirect - if ($newurl) - { - dol_syslog("main.inc: dolibarr_main_force_https is on, we make a redirect to ".$newurl); - header("Location: ".$newurl); - exit; - } - else - { - dol_syslog("main.inc: dolibarr_main_force_https is on but we failed to forge new https url so no redirect is done", LOG_WARNING); - } + $newurl=''; + if ($conf->file->main_force_https == '1') + { + if (! empty($_SERVER["SCRIPT_URI"])) // If SCRIPT_URI supported by server + { + if (preg_match('/^http:/i',$_SERVER["SCRIPT_URI"]) && ! preg_match('/^https:/i',$_SERVER["SCRIPT_URI"])) // If link is http + { + $newurl=preg_replace('/^http:/i','https:',$_SERVER["SCRIPT_URI"]); + } + } + else // Check HTTPS environment variable (Apache/mod_ssl only) + { + // $_SERVER["HTTPS"] is 'on' when link is https, otherwise $_SERVER["HTTPS"] is empty or 'off' + if (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') // If link is http + { + $newurl=preg_replace('/^http:/i','https:',DOL_MAIN_URL_ROOT).$_SERVER["REQUEST_URI"]; + } + } + } + else + { + $newurl=$conf->file->main_force_https.$_SERVER["REQUEST_URI"]; + } + // Start redirect + if ($newurl) + { + dol_syslog("main.inc: dolibarr_main_force_https is on, we make a redirect to ".$newurl); + header("Location: ".$newurl); + exit; + } + else + { + dol_syslog("main.inc: dolibarr_main_force_https is on but we failed to forge new https url so no redirect is done", LOG_WARNING); + } } @@ -247,9 +249,9 @@ if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once(DOL_D // If install or upgrade process not done or not completely finished, we call the install page. if (! empty($conf->global->MAIN_NOT_INSTALLED) || ! empty($conf->global->MAIN_NOT_UPGRADED)) { - dol_syslog("main.inc: A previous install or upgrade was not complete. Redirect to install page.", LOG_WARNING); - Header("Location: ".DOL_URL_ROOT."/install/index.php"); - exit; + dol_syslog("main.inc: A previous install or upgrade was not complete. Redirect to install page.", LOG_WARNING); + Header("Location: ".DOL_URL_ROOT."/install/index.php"); + exit; } // If an upgrade process is required, we call the install page. if ((! empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && ($conf->global->MAIN_VERSION_LAST_UPGRADE != DOL_VERSION)) @@ -257,86 +259,86 @@ if ((! empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && ($conf->global->MAIN_V { $versiontocompare=empty($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_INSTALL:$conf->global->MAIN_VERSION_LAST_UPGRADE; require_once(DOL_DOCUMENT_ROOT ."/core/lib/admin.lib.php"); - $dolibarrversionlastupgrade=preg_split('/[.-]/',$versiontocompare); - $dolibarrversionprogram=preg_split('/[.-]/',DOL_VERSION); + $dolibarrversionlastupgrade=preg_split('/[.-]/',$versiontocompare); + $dolibarrversionprogram=preg_split('/[.-]/',DOL_VERSION); $rescomp=versioncompare($dolibarrversionprogram,$dolibarrversionlastupgrade); if ($rescomp > 0) // Programs have a version higher than database. We did not add "&& $rescomp < 3" because we want upgrade process for build upgrades - { - dol_syslog("main.inc: database version ".$versiontocompare." is lower than programs version ".DOL_VERSION.". Redirect to install page.", LOG_WARNING); - Header("Location: ".DOL_URL_ROOT."/install/index.php"); - exit; - } + { + dol_syslog("main.inc: database version ".$versiontocompare." is lower than programs version ".DOL_VERSION.". Redirect to install page.", LOG_WARNING); + Header("Location: ".DOL_URL_ROOT."/install/index.php"); + exit; + } } // Creation of a token against CSRF vulnerabilities if (! defined('NOTOKENRENEWAL')) { - $token = dol_hash(uniqid(mt_rand(),TRUE)); // Genere un hash d'un nombre aleatoire - // roulement des jetons car cree a chaque appel - if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken']; - $_SESSION['newtoken'] = $token; + $token = dol_hash(uniqid(mt_rand(),TRUE)); // Genere un hash d'un nombre aleatoire + // roulement des jetons car cree a chaque appel + if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken']; + $_SESSION['newtoken'] = $token; } if (! empty($conf->global->MAIN_SECURITY_CSRF)) // Check validity of token, only if option enabled (this option breaks some features sometimes) { - if (isset($_POST['token']) && isset($_SESSION['token'])) - { - if (($_POST['token'] != $_SESSION['token'])) - { - dol_syslog("Invalid token in ".$_SERVER['HTTP_REFERER'].", action=".$_POST['action'].", _POST['token']=".$_POST['token'].", _SESSION['token']=".$_SESSION['token'],LOG_WARNING); - //print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers. - unset($_POST); - } - } + if (isset($_POST['token']) && isset($_SESSION['token'])) + { + if (($_POST['token'] != $_SESSION['token'])) + { + dol_syslog("Invalid token in ".$_SERVER['HTTP_REFERER'].", action=".$_POST['action'].", _POST['token']=".$_POST['token'].", _SESSION['token']=".$_SESSION['token'],LOG_WARNING); + //print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers. + unset($_POST); + } + } } // Disable modules (this must be after session_start and after conf has been loaded) if (GETPOST('disablemodules')) $_SESSION["disablemodules"]=GETPOST('disablemodules'); if (! empty($_SESSION["disablemodules"])) { - $disabled_modules=explode(',',$_SESSION["disablemodules"]); - foreach($disabled_modules as $module) - { - if ($module) $conf->$module->enabled=false; - } + $disabled_modules=explode(',',$_SESSION["disablemodules"]); + foreach($disabled_modules as $module) + { + if ($module) $conf->$module->enabled=false; + } } /* * Phase authentication / login - */ +*/ $login=''; if (! defined('NOLOGIN')) { - // $authmode lists the different means of identification to be tested in order of preference. - // Example: 'http', 'dolibarr', 'ldap', 'http,forceuser' + // $authmode lists the different means of identification to be tested in order of preference. + // Example: 'http', 'dolibarr', 'ldap', 'http,forceuser' - // Authentication mode - if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr'; - // Authentication mode: forceuser - if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto'; - // Set authmode - $authmode=explode(',',$dolibarr_main_authentication); + // Authentication mode + if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr'; + // Authentication mode: forceuser + if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto'; + // Set authmode + $authmode=explode(',',$dolibarr_main_authentication); - // No authentication mode - if (! count($authmode) && empty($conf->login_method_modules)) - { - $langs->load('main'); - dol_print_error('',$langs->trans("ErrorConfigParameterNotDefined",'dolibarr_main_authentication')); - exit; - } + // No authentication mode + if (! count($authmode) && empty($conf->login_method_modules)) + { + $langs->load('main'); + dol_print_error('',$langs->trans("ErrorConfigParameterNotDefined",'dolibarr_main_authentication')); + exit; + } - // If requested by the login has already occurred, it is retrieved from the session - // Call module if not realized that his request. - // At the end of this phase, the variable $login is defined. - $resultFetchUser=''; - $test=true; - if (! isset($_SESSION["dol_login"])) - { - // It is not already authenticated and it requests the login / password - include_once(DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'); + // If requested by the login has already occurred, it is retrieved from the session + // Call module if not realized that his request. + // At the end of this phase, the variable $login is defined. + $resultFetchUser=''; + $test=true; + if (! isset($_SESSION["dol_login"])) + { + // It is not already authenticated and it requests the login / password + include_once(DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'); - // If in demo mode, we check we go to home page through the public/demo/index.php page - if ($dolibarr_main_demo && $_SERVER['PHP_SELF'] == DOL_URL_ROOT.'/index.php') // We ask index page + // If in demo mode, we check we go to home page through the public/demo/index.php page + if ($dolibarr_main_demo && $_SERVER['PHP_SELF'] == DOL_URL_ROOT.'/index.php') // We ask index page { if (! preg_match('/public/',$_SERVER['HTTP_REFERER'])) { @@ -346,245 +348,257 @@ if (! defined('NOLOGIN')) } } - // Verification security graphic code - if (GETPOST("username","alpha",2) && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) - { + // Verification security graphic code + if (GETPOST("username","alpha",2) && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) + { $sessionkey = 'dol_antispam_value'; $ok=(array_key_exists($sessionkey, $_SESSION) === TRUE && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code']))); - // Verifie code - if (! $ok) - { - dol_syslog('Bad value for code, connexion refused'); - $langs->load('main'); - $langs->load('errors'); + // Verifie code + if (! $ok) + { + dol_syslog('Bad value for code, connexion refused'); + $langs->load('main'); + $langs->load('errors'); - $user->trigger_mesg='ErrorBadValueForCode - login='.GETPOST("username","alpha",2); - $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadValueForCode"); - $test=false; + $user->trigger_mesg='ErrorBadValueForCode - login='.GETPOST("username","alpha",2); + $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadValueForCode"); + $test=false; - // 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')); - if ($result < 0) { $error++; } - // Fin appel triggers - } - } + // 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')); + if ($result < 0) { + $error++; + } + // Fin appel triggers + } + } - $usertotest = (! empty($_COOKIE['login_dolibarr']) ? $_COOKIE['login_dolibarr'] : GETPOST("username","alpha",2)); - $passwordtotest = (! empty($_COOKIE['password_dolibarr']) ? $_COOKIE['password_dolibarr'] : $_POST["password"]); - $entitytotest = (! empty($_POST["entity"]) ? $_POST["entity"] : 1); + $usertotest = (! empty($_COOKIE['login_dolibarr']) ? $_COOKIE['login_dolibarr'] : GETPOST("username","alpha",2)); + $passwordtotest = (! empty($_COOKIE['password_dolibarr']) ? $_COOKIE['password_dolibarr'] : $_POST["password"]); + $entitytotest = (! empty($_POST["entity"]) ? $_POST["entity"] : 1); - // Validation of login/pass/entity - // If ok, the variable login will be returned - // If error, we will put error message in session under the name dol_loginmesg - $goontestloop=false; - if (isset($_SERVER["REMOTE_USER"]) && in_array('http',$authmode)) $goontestloop=true; - if (GETPOST("username","alpha",2) || ! empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode','alpha',1)) $goontestloop=true; + // Validation of login/pass/entity + // If ok, the variable login will be returned + // If error, we will put error message in session under the name dol_loginmesg + $goontestloop=false; + if (isset($_SERVER["REMOTE_USER"]) && in_array('http',$authmode)) $goontestloop=true; + if (GETPOST("username","alpha",2) || ! empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode','alpha',1)) $goontestloop=true; - if ($test && $goontestloop) - { - $login = checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode); - if ($login) - { - $dol_authmode=$conf->authmode; // This properties is defined only when logged to say what mode was successfully used - $dol_tz=$_POST["tz"]; - $dol_dst=0; - if (isset($_POST["dst_first"]) && isset($_POST["dst_second"])) - { - include_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); + if ($test && $goontestloop) + { + $login = checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode); + if ($login) + { + $dol_authmode=$conf->authmode; // This properties is defined only when logged to say what mode was successfully used + $dol_tz=$_POST["tz"]; + $dol_dst=0; + if (isset($_POST["dst_first"]) && isset($_POST["dst_second"])) + { + include_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); $datenow=dol_now(); $datefirst=dol_stringtotime($_POST["dst_first"]); $datesecond=dol_stringtotime($_POST["dst_second"]); if ($datenow >= $datefirst && $datenow < $datesecond) $dol_dst=1; - } - //print $datefirst.'-'.$datesecond.'-'.$datenow; exit; - $dol_dst_observed=$_POST["dst_observed"]; - $dol_dst_first=$_POST["dst_first"]; - $dol_dst_second=$_POST["dst_second"]; - $dol_screenwidth=$_POST["screenwidth"]; - $dol_screenheight=$_POST["screenheight"]; - } + } + //print $datefirst.'-'.$datesecond.'-'.$datenow; exit; + $dol_dst_observed=$_POST["dst_observed"]; + $dol_dst_first=$_POST["dst_first"]; + $dol_dst_second=$_POST["dst_second"]; + $dol_screenwidth=$_POST["screenwidth"]; + $dol_screenheight=$_POST["screenheight"]; + } - if (! $login) - { - dol_syslog('Bad password, connexion refused',LOG_DEBUG); - $langs->load('main'); - $langs->load('errors'); + if (! $login) + { + dol_syslog('Bad password, connexion refused',LOG_DEBUG); + $langs->load('main'); + $langs->load('errors'); - // Bad password. No authmode has found a good password. - $user->trigger_mesg=$langs->trans("ErrorBadLoginPassword").' - login='.GETPOST("username","alpha",2); - $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); + // Bad password. No authmode has found a good password. + $user->trigger_mesg=$langs->trans("ErrorBadLoginPassword").' - login='.GETPOST("username","alpha",2); + $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); - // 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("username","alpha",2)); - if ($result < 0) { $error++; } - // Fin appel triggers - } - } + // 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("username","alpha",2)); + if ($result < 0) { + $error++; + } + // Fin appel triggers + } + } - // End test login / passwords - if (! $login) - { - // We show login page - if (! is_object($langs)) // This can occurs when calling page with NOREQUIRETRAN defined - { + // End test login / passwords + if (! $login) + { + // We show login page + if (! is_object($langs)) // This can occurs when calling page with NOREQUIRETRAN defined + { include_once(DOL_DOCUMENT_ROOT."/core/class/translate.class.php"); - $langs=new Translate("",$conf); - } - dol_loginfunction($langs,$conf,$mysoc); - exit; - } + $langs=new Translate("",$conf); + } + dol_loginfunction($langs,$conf,$mysoc); + exit; + } - $resultFetchUser=$user->fetch('',$login); - if ($resultFetchUser <= 0) - { - dol_syslog('User not found, connexion refused'); - session_destroy(); - session_name($sessionname); - session_start(); + $resultFetchUser=$user->fetch('',$login); + if ($resultFetchUser <= 0) + { + dol_syslog('User not found, connexion refused'); + session_destroy(); + session_name($sessionname); + session_start(); - if ($resultFetchUser == 0) - { - $langs->load('main'); - $langs->load('errors'); + if ($resultFetchUser == 0) + { + $langs->load('main'); + $langs->load('errors'); - $user->trigger_mesg='ErrorCantLoadUserFromDolibarrDatabase - login='.$login; - $_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login); - } - if ($resultFetchUser < 0) - { - $user->trigger_mesg=$user->error; - $_SESSION["dol_loginmesg"]=$user->error; - } + $user->trigger_mesg='ErrorCantLoadUserFromDolibarrDatabase - login='.$login; + $_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login); + } + if ($resultFetchUser < 0) + { + $user->trigger_mesg=$user->error; + $_SESSION["dol_loginmesg"]=$user->error; + } - // Call 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,$_POST["entity"]); - if ($result < 0) { $error++; } - // End call triggers + // Call 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,$_POST["entity"]); + if ($result < 0) { + $error++; + } + // End call triggers - header('Location: '.DOL_URL_ROOT.'/index.php'); - exit; - } - } - else - { - // We are already into an authenticated session - $login=$_SESSION["dol_login"]; - dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login); + header('Location: '.DOL_URL_ROOT.'/index.php'); + exit; + } + } + else + { + // We are already into an authenticated session + $login=$_SESSION["dol_login"]; + dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login); - $resultFetchUser=$user->fetch('',$login); - if ($resultFetchUser <= 0) - { - // Account has been removed after login - dol_syslog("Can't load user even if session logged. _SESSION['dol_login']=".$login, LOG_WARNING); - session_destroy(); - session_name($sessionname); - session_start(); + $resultFetchUser=$user->fetch('',$login); + if ($resultFetchUser <= 0) + { + // Account has been removed after login + dol_syslog("Can't load user even if session logged. _SESSION['dol_login']=".$login, LOG_WARNING); + session_destroy(); + session_name($sessionname); + session_start(); - if ($resultFetchUser == 0) - { - $langs->load('main'); - $langs->load('errors'); + if ($resultFetchUser == 0) + { + $langs->load('main'); + $langs->load('errors'); - $user->trigger_mesg='ErrorCantLoadUserFromDolibarrDatabase - login='.$login; - $_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login); - } - if ($resultFetchUser < 0) - { - $user->trigger_mesg=$user->error; - $_SESSION["dol_loginmesg"]=$user->error; - } + $user->trigger_mesg='ErrorCantLoadUserFromDolibarrDatabase - login='.$login; + $_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login); + } + if ($resultFetchUser < 0) + { + $user->trigger_mesg=$user->error; + $_SESSION["dol_loginmesg"]=$user->error; + } - // Call 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,(isset($_POST["entity"])?$_POST["entity"]:0)); - if ($result < 0) { $error++; } - // End call triggers + // Call 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,(isset($_POST["entity"])?$_POST["entity"]:0)); + if ($result < 0) { + $error++; + } + // End call triggers - header('Location: '.DOL_URL_ROOT.'/index.php'); - exit; - } - else - { - if (! empty($conf->global->MAIN_ACTIVATE_UPDATESESSIONTRIGGER)) // We do not execute such trigger at each page load by default - { - // Call triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($db); - $result=$interface->run_triggers('USER_UPDATE_SESSION',$user,$user,$langs,$conf,$conf->entity); - if ($result < 0) { $error++; } - // End call triggers - } - } - } + header('Location: '.DOL_URL_ROOT.'/index.php'); + exit; + } + else + { + if (! empty($conf->global->MAIN_ACTIVATE_UPDATESESSIONTRIGGER)) // We do not execute such trigger at each page load by default + { + // Call triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers('USER_UPDATE_SESSION',$user,$user,$langs,$conf,$conf->entity); + if ($result < 0) { + $error++; + } + // End call triggers + } + } + } - // Is it a new session that has started ? - // If we are here, this means authentication was successfull. - if (! isset($_SESSION["dol_login"])) - { - $error=0; + // Is it a new session that has started ? + // If we are here, this means authentication was successfull. + if (! isset($_SESSION["dol_login"])) + { + $error=0; - // New session for this login - $_SESSION["dol_login"]=$user->login; - $_SESSION["dol_authmode"]=isset($dol_authmode)?$dol_authmode:''; - $_SESSION["dol_tz"]=isset($dol_tz)?$dol_tz:''; - $_SESSION["dol_dst"]=isset($dol_dst)?$dol_dst:''; - $_SESSION["dol_dst_observed"]=isset($dol_dst_observed)?$dol_dst_observed:''; - $_SESSION["dol_dst_first"]=isset($dol_dst_first)?$dol_dst_first:''; - $_SESSION["dol_dst_second"]=isset($dol_dst_second)?$dol_dst_second:''; - $_SESSION["dol_screenwidth"]=isset($dol_screenwidth)?$dol_screenwidth:''; - $_SESSION["dol_screenheight"]=isset($dol_screenheight)?$dol_screenheight:''; - $_SESSION["dol_company"]=$conf->global->MAIN_INFO_SOCIETE_NOM; - $_SESSION["dol_entity"]=$conf->entity; - dol_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id()); + // New session for this login + $_SESSION["dol_login"]=$user->login; + $_SESSION["dol_authmode"]=isset($dol_authmode)?$dol_authmode:''; + $_SESSION["dol_tz"]=isset($dol_tz)?$dol_tz:''; + $_SESSION["dol_dst"]=isset($dol_dst)?$dol_dst:''; + $_SESSION["dol_dst_observed"]=isset($dol_dst_observed)?$dol_dst_observed:''; + $_SESSION["dol_dst_first"]=isset($dol_dst_first)?$dol_dst_first:''; + $_SESSION["dol_dst_second"]=isset($dol_dst_second)?$dol_dst_second:''; + $_SESSION["dol_screenwidth"]=isset($dol_screenwidth)?$dol_screenwidth:''; + $_SESSION["dol_screenheight"]=isset($dol_screenheight)?$dol_screenheight:''; + $_SESSION["dol_company"]=$conf->global->MAIN_INFO_SOCIETE_NOM; + $_SESSION["dol_entity"]=$conf->entity; + dol_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id()); - $db->begin(); + $db->begin(); - $user->update_last_login_date(); + $user->update_last_login_date(); - // Call triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($db); - $result=$interface->run_triggers('USER_LOGIN',$user,$user,$langs,$conf,$_POST["entity"]); - if ($result < 0) { $error++; } - // End call triggers + // Call triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers('USER_LOGIN',$user,$user,$langs,$conf,$_POST["entity"]); + if ($result < 0) { + $error++; + } + // End call triggers - if ($error) - { - $db->rollback(); - session_destroy(); - dol_print_error($db,'Error in some triggers on action USER_LOGIN',LOG_ERR); - exit; - } - else - { - $db->commit(); - } + if ($error) + { + $db->rollback(); + session_destroy(); + dol_print_error($db,'Error in some triggers on action USER_LOGIN',LOG_ERR); + exit; + } + else + { + $db->commit(); + } - // Create entity cookie, just used for login page - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_COOKIE_ENABLED) && isset($_POST["entity"])) - { - include_once(DOL_DOCUMENT_ROOT."/core/class/cookie.class.php"); + // Create entity cookie, just used for login page + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_COOKIE_ENABLED) && isset($_POST["entity"])) + { + include_once(DOL_DOCUMENT_ROOT."/core/class/cookie.class.php"); - $entity = $_SESSION["dol_login"].'|'.$_POST["entity"]; + $entity = $_SESSION["dol_login"].'|'.$_POST["entity"]; - $prefix=dol_getprefix(); - $entityCookieName = 'DOLENTITYID_'.$prefix; - // TTL : is defined in the config page multicompany - $ttl = (! empty($conf->global->MULTICOMPANY_COOKIE_TTL) ? dol_now()+$conf->global->MULTICOMPANY_COOKIE_TTL : dol_now()+60*60*8 ); - // Cryptkey : will be created randomly in the config page multicompany - $cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' ); + $prefix=dol_getprefix(); + $entityCookieName = 'DOLENTITYID_'.$prefix; + // TTL : is defined in the config page multicompany + $ttl = (! empty($conf->global->MULTICOMPANY_COOKIE_TTL) ? dol_now()+$conf->global->MULTICOMPANY_COOKIE_TTL : dol_now()+60*60*8 ); + // Cryptkey : will be created randomly in the config page multicompany + $cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' ); - $entityCookie = new DolCookie($cryptkey); - $entityCookie->_setCookie($entityCookieName, $entity, $ttl); - } + $entityCookie = new DolCookie($cryptkey); + $entityCookie->_setCookie($entityCookieName, $entity, $ttl); + } // Hooks on successfull login $action=''; @@ -593,101 +607,101 @@ if (! defined('NOLOGIN')) $hookmanager->callHooks(array('login')); $parameters=array('dol_authmode'=>$dol_authmode); $reshook=$hookmanager->executeHooks('afterLogin',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; - } + if ($reshook < 0) $error++; + } - // If user admin, we force the rights-based modules - if ($user->admin) - { - $user->rights->user->user->lire=1; - $user->rights->user->user->creer=1; - $user->rights->user->user->password=1; - $user->rights->user->user->supprimer=1; - $user->rights->user->self->creer=1; - $user->rights->user->self->password=1; - } + // If user admin, we force the rights-based modules + if ($user->admin) + { + $user->rights->user->user->lire=1; + $user->rights->user->user->creer=1; + $user->rights->user->user->password=1; + $user->rights->user->user->supprimer=1; + $user->rights->user->self->creer=1; + $user->rights->user->self->password=1; + } - /* - * Overwrite configs global by personal configs - */ - // Set liste_limit - if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) // Can be 0 - { - $conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT; - } - if (isset($user->conf->PRODUIT_LIMIT_SIZE)) // Can be 0 - { - $conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE; - } - // Replace conf->css by personalized value - if (isset($user->conf->MAIN_THEME) && $user->conf->MAIN_THEME) - { - $conf->theme=$user->conf->MAIN_THEME; - $conf->css = "/theme/".$conf->theme."/style.css.php"; - } + /* + * Overwrite configs global by personal configs + */ + // Set liste_limit + if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) // Can be 0 + { + $conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT; + } + if (isset($user->conf->PRODUIT_LIMIT_SIZE)) // Can be 0 + { + $conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE; + } + // Replace conf->css by personalized value + if (isset($user->conf->MAIN_THEME) && $user->conf->MAIN_THEME) + { + $conf->theme=$user->conf->MAIN_THEME; + $conf->css = "/theme/".$conf->theme."/style.css.php"; + } - // If theme support option like flip-hide left menu and we use a smartphone, we force it - if (! empty($conf->global->MAIN_SMARTPHONE_OPTIM) && $conf->browser->phone && $conf->theme == 'eldy') $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT='forced'; + // If theme support option like flip-hide left menu and we use a smartphone, we force it + if (! empty($conf->global->MAIN_SMARTPHONE_OPTIM) && $conf->browser->phone && $conf->theme == 'eldy') $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT='forced'; - // Set javascript option + // Set javascript option if (! GETPOST('nojs')) // If javascript was not disabled on URL { - if (! empty($user->conf->MAIN_DISABLE_JAVASCRIPT)) - { - $conf->use_javascript_ajax=! $user->conf->MAIN_DISABLE_JAVASCRIPT; - } + if (! empty($user->conf->MAIN_DISABLE_JAVASCRIPT)) + { + $conf->use_javascript_ajax=! $user->conf->MAIN_DISABLE_JAVASCRIPT; + } } else $conf->use_javascript_ajax=0; } if (! defined('NOREQUIRETRAN')) { - if (! GETPOST('lang')) // If language was not forced on URL - { - // If user has chosen its own language - if (! empty($user->conf->MAIN_LANG_DEFAULT)) - { - // If different than current language - //print ">>>".$langs->getDefaultLang()."-".$user->conf->MAIN_LANG_DEFAULT; - if ($langs->getDefaultLang() != $user->conf->MAIN_LANG_DEFAULT) - { - $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); - } - } - } - else // If language was forced on URL - { - $langs->setDefaultLang(GETPOST('lang','alpha',1)); - } + if (! GETPOST('lang')) // If language was not forced on URL + { + // If user has chosen its own language + if (! empty($user->conf->MAIN_LANG_DEFAULT)) + { + // If different than current language + //print ">>>".$langs->getDefaultLang()."-".$user->conf->MAIN_LANG_DEFAULT; + if ($langs->getDefaultLang() != $user->conf->MAIN_LANG_DEFAULT) + { + $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); + } + } + } + else // If language was forced on URL + { + $langs->setDefaultLang(GETPOST('lang','alpha',1)); + } } // Case forcing style from url if (GETPOST('theme')) { - $conf->theme=GETPOST('theme','alpha',1); - $conf->css = "/theme/".$conf->theme."/style.css.php"; + $conf->theme=GETPOST('theme','alpha',1); + $conf->css = "/theme/".$conf->theme."/style.css.php"; } if (! defined('NOLOGIN')) { - // If the login is not recovered, it is identified with an account that does not exist. - // Hacking attempt? - if (! $user->login) accessforbidden(); + // If the login is not recovered, it is identified with an account that does not exist. + // Hacking attempt? + if (! $user->login) accessforbidden(); - // Check if user is active - if ($user->statut < 1) - { - // If not active, we refuse the user - $langs->load("other"); - dol_syslog("Authentification ko as login is disabled"); - accessforbidden($langs->trans("ErrorLoginDisabled")); - exit; - } + // Check if user is active + if ($user->statut < 1) + { + // If not active, we refuse the user + $langs->load("other"); + dol_syslog("Authentification ko as login is disabled"); + accessforbidden($langs->trans("ErrorLoginDisabled")); + exit; + } - // Load permissions - $user->getrights(); + // Load permissions + $user->getrights(); } @@ -698,8 +712,8 @@ dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]); // Load main languages files if (! defined('NOREQUIRETRAN')) { - $langs->load("main"); - $langs->load("dict"); + $langs->load("main"); + $langs->load("dict"); } // Define some constants used for style of arrays @@ -710,27 +724,27 @@ $bcnd=array(0=>'class="impair nodrag nodrop"',1=>'class="pair nodrag nodrop"'); // Constants used to defined number of lines in textarea if (empty($conf->browser->firefox)) { - define('ROWS_1',1); - define('ROWS_2',2); - define('ROWS_3',3); - define('ROWS_4',4); - define('ROWS_5',5); - define('ROWS_6',6); - define('ROWS_7',7); - define('ROWS_8',8); - define('ROWS_9',9); + define('ROWS_1',1); + define('ROWS_2',2); + define('ROWS_3',3); + define('ROWS_4',4); + define('ROWS_5',5); + define('ROWS_6',6); + define('ROWS_7',7); + define('ROWS_8',8); + define('ROWS_9',9); } else { - define('ROWS_1',0); - define('ROWS_2',1); - define('ROWS_3',2); - define('ROWS_4',3); - define('ROWS_5',4); - define('ROWS_6',5); - define('ROWS_7',6); - define('ROWS_8',7); - define('ROWS_9',8); + define('ROWS_1',0); + define('ROWS_2',1); + define('ROWS_3',2); + define('ROWS_4',3); + define('ROWS_5',4); + define('ROWS_6',5); + define('ROWS_7',6); + define('ROWS_8',7); + define('ROWS_9',8); } $heightforframes=48; @@ -738,11 +752,11 @@ $heightforframes=48; // Switch to another entity if (! empty($conf->multicompany->enabled) && GETPOST('action') == 'switchentity') { - if ($mc->switchEntity(GETPOST('entity')) >= 0) - { - Header("Location: ".DOL_URL_ROOT.'/'); - exit; - } + if ($mc->switchEntity(GETPOST('entity')) >= 0) + { + Header("Location: ".DOL_URL_ROOT.'/'); + exit; + } } @@ -750,29 +764,29 @@ if (! empty($conf->multicompany->enabled) && GETPOST('action') == 'switchentity' if (! function_exists("llxHeader")) { - /** - * Show HTML header HTML + BODY + Top menu + left menu + DIV - * + /** + * Show HTML header HTML + BODY + Top menu + left menu + DIV + * * @param string $head Optionnal head lines * @param string $title HTML title * @param string $help_url Url links to help page - * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage - * For other external page: http://server/url - * @param string $target Target to use on links + * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage + * For other external page: http://server/url + * @param string $target Target to use on links * @param int $disablejs More content into html header * @param int $disablehead More content into html header * @param array $arrayofjs Array of complementary js files * @param array $arrayofcss Array of complementary css files - * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) - * @return void - */ - function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='') - { - top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers - top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring); - left_menu('', $help_url, '', '', 1, $title); - main_area($title); - } + * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) + * @return void + */ + function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='') + { + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers + top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring); + left_menu('', $help_url, '', '', 1, $title); + main_area($title); + } } @@ -789,7 +803,9 @@ function top_httphead() header("Content-type: text/html; charset=".$conf->file->character_set_client); // On the fly GZIP compression for all pages (if browser support it). Must set the bit 3 of constant to 1. - if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x04)) { ob_start("ob_gzhandler"); } + if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x04)) { + ob_start("ob_gzhandler"); + } } /** @@ -806,37 +822,37 @@ function top_httphead() */ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='') { - global $user, $conf, $langs, $db; + global $user, $conf, $langs, $db; - top_httphead(); + top_httphead(); - if (empty($conf->css)) $conf->css = '/theme/eldy/style.css.php'; // If not defined, eldy by default + if (empty($conf->css)) $conf->css = '/theme/eldy/style.css.php'; // If not defined, eldy by default - print ''; - //print ''; - //print ''; - //print ''; - //print ''; - print "\n"; - if (! empty($conf->global->MAIN_USE_CACHE_MANIFEST)) print ''."\n"; - else print ''."\n"; - //print ''."\n"; - if (empty($disablehead)) - { - print "\n"; + print ''; + //print ''; + //print ''; + //print ''; + //print ''; + print "\n"; + if (! empty($conf->global->MAIN_USE_CACHE_MANIFEST)) print ''."\n"; + else print ''."\n"; + //print ''."\n"; + if (empty($disablehead)) + { + print "\n"; - // Displays meta - print ''."\n"; // Evite indexation par robots - print ''."\n"; - $favicon=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/favicon.ico'; - print ''."\n"; - // Displays title - $appli='Dolibarr'; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; + // Displays meta + print ''."\n"; // Evite indexation par robots + print ''."\n"; + $favicon=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/favicon.ico'; + print ''."\n"; + // Displays title + $appli='Dolibarr'; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; - if ($title) print ''.$appli.' - '.$title.''; - else print "".$appli.""; - print "\n"; + if ($title) print ''.$appli.' - '.$title.''; + else print "".$appli.""; + print "\n"; if (! defined('DISABLE_JQUERY') && ! $disablejs && $conf->use_javascript_ajax) { @@ -850,16 +866,16 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs //print ''."\n"; // Lightbox if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD)) // jQuery fileupload { - print ''."\n"; + print ''."\n"; } - if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES)) // jQuery datatables + if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES)) // jQuery datatables { - //print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - //print ''."\n"; - print ''."\n"; + //print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + //print ''."\n"; + print ''."\n"; } } @@ -869,112 +885,115 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs $themeparam='?lang='.$langs->defaultlang.'&theme='.$conf->theme.(GETPOST('optioncss')?'&optioncss='.GETPOST('optioncss','alpha',1):''); if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&dol_resetcache='.$_SESSION['dol_resetcache']; //print 'themepath='.$themepath.' themeparam='.$themeparam;exit; - print ''."\n"; - // CSS forced by modules (relative url starting with /) - if (is_array($conf->css_modules)) - { - foreach($conf->css_modules as $cssfile) - { // cssfile is an absolute path - print ''."\n"; + // CSS forced by modules (relative url starting with /) + if (is_array($conf->css_modules)) + { + foreach($conf->css_modules as $cssfile) + { + // cssfile is an absolute path + print ''."\n"; - } - } - // CSS forced by page in top_htmlhead call (relative url starting with /) - if (is_array($arrayofcss)) - { - foreach($arrayofcss as $cssfile) - { - print ''."\n"; + } + } + // CSS forced by page in top_htmlhead call (relative url starting with /) + if (is_array($arrayofcss)) + { + foreach($arrayofcss as $cssfile) + { + print ''."\n"; - } - } + if (!preg_match('/\.css$/i',$cssfile)) print $themeparam; + print '">'."\n"; + } + } - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; - // Output standard javascript links - if (! $disablejs && $conf->use_javascript_ajax) - { - $ext='.js'; - if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) { $ext='.jgz'; } // mini='_mini', ext='.gz' + // Output standard javascript links + if (! $disablejs && $conf->use_javascript_ajax) + { + $ext='.js'; + if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) { + $ext='.jgz'; + } // mini='_mini', ext='.gz' - // JQuery. Must be before other includes - print ''."\n"; + // JQuery. Must be before other includes + print ''."\n"; if (constant('JS_JQUERY')) print ''."\n"; else print ''."\n"; - if (constant('JS_JQUERY_UI')) print ''."\n"; - else print ''."\n"; - print ''."\n"; + if (constant('JS_JQUERY_UI')) print ''."\n"; + else print ''."\n"; + print ''."\n"; print ''."\n"; //print ''."\n"; // jQuery Layout - if (! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) || defined('REQUIRE_JQUERY_LAYOUT')) - { + if (! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) || defined('REQUIRE_JQUERY_LAYOUT')) + { print ''."\n"; - } - // jQuery jnotify - if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY)) - { - print ''."\n"; - print ''."\n"; - } - // Flot - if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT)) - { - if (constant('JS_JQUERY_FLOT')) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - else - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - } + } + // jQuery jnotify + if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY)) + { + print ''."\n"; + print ''."\n"; + } + // Flot + if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT)) + { + if (constant('JS_JQUERY_FLOT')) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + } // jQuery jeditable if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; } // jQuery File Upload if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; } - // jQuery DataTables + // jQuery DataTables if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; } // CKEditor if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor')) @@ -1002,29 +1021,29 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs // Output module javascript if (is_array($arrayofjs)) { - print ''."\n"; - foreach($arrayofjs as $jsfile) - { - if (preg_match('/^http/i',$jsfile)) - { - print ''."\n"; - } - else - { - if (! preg_match('/^\//',$jsfile)) $jsfile='/'.$jsfile; // For backward compatibility - print ''."\n"; - } - } + print ''."\n"; + foreach($arrayofjs as $jsfile) + { + if (preg_match('/^http/i',$jsfile)) + { + print ''."\n"; + } + else + { + if (! preg_match('/^\//',$jsfile)) $jsfile='/'.$jsfile; // For backward compatibility + print ''."\n"; + } + } } - } + } - if (! empty($head)) print $head."\n"; - if (! empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n"; + if (! empty($head)) print $head."\n"; + if (! empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n"; - print "\n\n"; - } + print "\n\n"; + } - $conf->headerdone=1; // To tell header was output + $conf->headerdone=1; // To tell header was output } @@ -1043,24 +1062,30 @@ 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; - global $dolibarr_main_authentication; - global $mc; + global $user, $conf, $langs, $db; + global $dolibarr_main_authentication; + global $hookmanager; + global $mc; // TODO Remove this. This should not bee required because code called on MC must be inside the new hook toprightmenu - $form=new Form($db); + // Instantiate hooks of thirdparty module + include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); + $hookmanager=new HookManager($db); + $hookmanager->callHooks(array('toprightmenu')); - if (! $conf->top_menu) $conf->top_menu ='eldy_backoffice.php'; + $toprightmenu=''; - // For backward compatibility with old modules - if (empty($conf->headerdone)) top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + if (! $conf->top_menu) $conf->top_menu ='eldy_backoffice.php'; - print ''; + // For backward compatibility with old modules + if (empty($conf->headerdone)) top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); - if ($conf->use_javascript_ajax) - { - if ($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) - { - print ''; - } + } - if (! empty($conf->global->MAIN_MENU_USE_JQUERY_ACCORDION)) - { - print "\n".''; - } + } - // Wrapper to show tooltips - print "\n".''; - } + } - /* - * Top menu - */ + /* + * Top menu + */ $top_menu=empty($conf->browser->phone)?$conf->top_menu:$conf->smart_menu; if (GETPOST('menu')) $top_menu=GETPOST('menu'); // menu=eldy_backoffice.php - // Load the top menu manager + // Load the top menu manager // Load the top menu manager (only if not already done) if (! class_exists('MenuTop')) { $menufound=0; - $dirmenus=array_merge(array("/core/menus"),$conf->menus_modules); - foreach($dirmenus as $dirmenu) - { - $menufound=dol_include_once($dirmenu."/standard/".$top_menu); - if ($menufound) break; - } - if (! $menufound) // If failed to include, we try with standard - { - $top_menu='eldy_backoffice.php'; - include_once(DOL_DOCUMENT_ROOT."/core/menus/standard/".$top_menu); - } + $dirmenus=array_merge(array("/core/menus"),$conf->menus_modules); + foreach($dirmenus as $dirmenu) + { + $menufound=dol_include_once($dirmenu."/standard/".$top_menu); + if ($menufound) break; + } + if (! $menufound) // If failed to include, we try with standard + { + $top_menu='eldy_backoffice.php'; + include_once(DOL_DOCUMENT_ROOT."/core/menus/standard/".$top_menu); + } } print "\n".''."\n"; @@ -1169,103 +1194,112 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a // Show menu $menutop = new MenuTop($db); - $menutop->atarget=$target; - $menutop->showmenu(); // This contains a \n + $menutop->atarget=$target; + $menutop->showmenu(); // This contains a \n - print "\n"; + print "\n"; - // Link to login card - $loginhtmltext=''; $logintext=''; - if ($user->societe_id) - { - $thirdpartystatic=new Societe($db); - $thirdpartystatic->fetch($user->societe_id); - $companylink=' ('.$thirdpartystatic->getNomUrl('','').')'; - $company=' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; - } - $logintext=''; - $loginhtmltext.=''.$langs->trans("User").''; - $loginhtmltext.='
'.$langs->trans("Name").': '.$user->getFullName($langs); - $loginhtmltext.='
'.$langs->trans("Login").': '.$user->login; - $loginhtmltext.='
'.$langs->trans("Administrator").': '.yn($user->admin); - $type=($user->societe_id?$langs->trans("External").$company:$langs->trans("Internal")); - $loginhtmltext.='
'.$langs->trans("Type").': '.$type; + // Link to login card + $loginhtmltext=''; $logintext=''; + if ($user->societe_id) + { + $thirdpartystatic=new Societe($db); + $thirdpartystatic->fetch($user->societe_id); + $companylink=' ('.$thirdpartystatic->getNomUrl('','').')'; + $company=' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; + } + $logintext=''; + $loginhtmltext.=''.$langs->trans("User").''; + $loginhtmltext.='
'.$langs->trans("Name").': '.$user->getFullName($langs); + $loginhtmltext.='
'.$langs->trans("Login").': '.$user->login; + $loginhtmltext.='
'.$langs->trans("Administrator").': '.yn($user->admin); + $type=($user->societe_id?$langs->trans("External").$company:$langs->trans("Internal")); + $loginhtmltext.='
'.$langs->trans("Type").': '.$type; $loginhtmltext.='
'.$langs->trans("IPAddress").': '.$_SERVER["REMOTE_ADDR"]; - $loginhtmltext.='
'; - $loginhtmltext.='
'.$langs->trans("Connection").''; - if ($conf->global->MAIN_MODULE_MULTICOMPANY) $loginhtmltext.='
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; - $loginhtmltext.='
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin,"dayhour"); - $loginhtmltext.='
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin,"dayhour"); - $loginhtmltext.='
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"]; - $loginhtmltext.='
'.$langs->trans("CurrentTheme").': '.$conf->theme; - $s=picto_from_langcode($langs->getDefaultLang()); - $loginhtmltext.='
'.$langs->trans("CurrentUserLanguage").': '.($s?$s.' ':'').$langs->getDefaultLang(); - $loginhtmltext.='
'.$langs->trans("Browser").': '.$conf->browser->name.' ('.$_SERVER['HTTP_USER_AGENT'].')'; - if (! empty($conf->browser->phone)) $loginhtmltext.='
'.$langs->trans("Phone").': '.$conf->browser->phone; - if (! empty($_SESSION["disablemodules"])) $loginhtmltext.='
'.$langs->trans("DisabledModules").':
'.join(', ',explode(',',$_SESSION["disablemodules"])); + $loginhtmltext.='
'; + $loginhtmltext.='
'.$langs->trans("Connection").''; + if ($conf->global->MAIN_MODULE_MULTICOMPANY) $loginhtmltext.='
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; + $loginhtmltext.='
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin,"dayhour"); + $loginhtmltext.='
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin,"dayhour"); + $loginhtmltext.='
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"]; + $loginhtmltext.='
'.$langs->trans("CurrentTheme").': '.$conf->theme; + $s=picto_from_langcode($langs->getDefaultLang()); + $loginhtmltext.='
'.$langs->trans("CurrentUserLanguage").': '.($s?$s.' ':'').$langs->getDefaultLang(); + $loginhtmltext.='
'.$langs->trans("Browser").': '.$conf->browser->name.' ('.$_SERVER['HTTP_USER_AGENT'].')'; + if (! empty($conf->browser->phone)) $loginhtmltext.='
'.$langs->trans("Phone").': '.$conf->browser->phone; + if (! empty($_SESSION["disablemodules"])) $loginhtmltext.='
'.$langs->trans("DisabledModules").':
'.join(', ',explode(',',$_SESSION["disablemodules"])); - $appli='Dolibarr'; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; + $appli='Dolibarr'; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; - // Link info - $logouttext=''; - $logouthtmltext=$appli.' '.DOL_VERSION.'
'; - $logouthtmltext.=$langs->trans("Logout").'
'; - //$logouthtmltext.="
"; - if ($_SESSION["dol_authmode"] != 'forceuser' - && $_SESSION["dol_authmode"] != 'http') - { - $logouttext.='atarget?(' target="'.$menutop->atarget.'"'):''; - $logouttext.='>'; - $logouttext.='trans("Logout")).'" title=""'; - $logouttext.='>'; - $logouttext.=''; - } - else - { - $logouttext.='trans("Logout")).'" title=""'; - $logouttext.='>'; - } + // Link info + $logouttext=''; + $logouthtmltext=$appli.' '.DOL_VERSION.'
'; + $logouthtmltext.=$langs->trans("Logout").'
'; + //$logouthtmltext.="
"; + if ($_SESSION["dol_authmode"] != 'forceuser' + && $_SESSION["dol_authmode"] != 'http') + { + $logouttext.='atarget?(' target="'.$menutop->atarget.'"'):''; + $logouttext.='>'; + $logouttext.='trans("Logout")).'" title=""'; + $logouttext.='>'; + $logouttext.=''; + } + else + { + $logouttext.='trans("Logout")).'" title=""'; + $logouttext.='>'; + } - print '\n"; + // Link to print main content area + if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->browser->phone)) + { + $qs=$_SERVER["QUERY_STRING"].($_SERVER["QUERY_STRING"]?'&':'').$morequerystring; + $text =''; + $text.='textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'',1); + } - print "\n"; + print $toprightmenu; - if (! $conf->use_javascript_ajax || ! $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print ''; + print '
'."\n"; + print "\n"; + + if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n"; + + print "\n"; + + if (! $conf->use_javascript_ajax || ! $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print ''; } @@ -1286,59 +1320,60 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a */ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='') { - global $user, $conf, $langs, $db; + global $user, $conf, $langs, $db; + global $hookmanager; - $searchform=''; - $bookmarks=''; + $searchform=''; + $bookmarks=''; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n".'
'."\n"; - else print '
'; + if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print ''."\n"; + else print ''; - print "\n"; - print ''."\n"; - print "\n"; + print "\n"; + print ''."\n"; + print "\n"; print ''."\n"; - if (empty($leftmenuwithoutmainarea)) main_area($title); + if (empty($leftmenuwithoutmainarea)) main_area($title); } @@ -1474,19 +1509,19 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me */ function main_area($title='') { - global $conf, $langs; + global $conf, $langs; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) - { - print '
'."\n"; - print '
'; - - print "\n"; - - // Instantiate hooks of thirdparty module + // Instantiate hooks of thirdparty module include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); $hookmanager=new HookManager($db); - $hookmanager->callHooks(array('searchform','leftblock')); + $hookmanager->callHooks(array('searchform','leftblock','toprightmenu')); - // Define $searchform - if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_SOCIETE && $user->rights->societe->lire) - { - $langs->load("companies"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/societe.php', DOL_URL_ROOT.'/societe/societe.php', img_object('','company').' '.$langs->trans("ThirdParties"), 'soc', 'socname'); - } + if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n".'
'."\n"; + else print '
'; - if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_CONTACT && $user->rights->societe->lire) - { - $langs->load("companies"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', img_object('','contact').' '.$langs->trans("Contacts"), 'contact', 'contactname'); - } + print "\n"; - if ((($conf->product->enabled && $user->rights->produit->lire) || ($conf->service->enabled && $user->rights->service->lire)) - && $conf->global->MAIN_SEARCHFORM_PRODUITSERVICE) - { - $langs->load("products"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/product/liste.php', DOL_URL_ROOT.'/product/liste.php', img_object('','product').' '.$langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall'); - } + // Define $searchform + if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_SOCIETE && $user->rights->societe->lire) + { + $langs->load("companies"); + $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/societe.php', DOL_URL_ROOT.'/societe/societe.php', img_object('','company').' '.$langs->trans("ThirdParties"), 'soc', 'socname'); + } - if ($conf->adherent->enabled && $conf->global->MAIN_SEARCHFORM_ADHERENT && $user->rights->adherent->lire) - { - $langs->load("members"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/liste.php', DOL_URL_ROOT.'/adherents/liste.php', img_object('','user').' '.$langs->trans("Members"), 'member', 'sall'); - } + if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_CONTACT && $user->rights->societe->lire) + { + $langs->load("companies"); + $searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', img_object('','contact').' '.$langs->trans("Contacts"), 'contact', 'contactname'); + } - // Execute hook printSearchForm - $parameters=array(); + if ((($conf->product->enabled && $user->rights->produit->lire) || ($conf->service->enabled && $user->rights->service->lire)) + && $conf->global->MAIN_SEARCHFORM_PRODUITSERVICE) + { + $langs->load("products"); + $searchform.=printSearchForm(DOL_URL_ROOT.'/product/liste.php', DOL_URL_ROOT.'/product/liste.php', img_object('','product').' '.$langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall'); + } + + if ($conf->adherent->enabled && $conf->global->MAIN_SEARCHFORM_ADHERENT && $user->rights->adherent->lire) + { + $langs->load("members"); + $searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/liste.php', DOL_URL_ROOT.'/adherents/liste.php', img_object('','user').' '.$langs->trans("Members"), 'member', 'sall'); + } + + // Execute hook printSearchForm + $parameters=array(); $searchform.=$hookmanager->executeHooks('printSearchForm',$parameters); // Note that $action and $object may have been modified by some hooks - // Define $bookmarks - if ($conf->bookmark->enabled && $user->rights->bookmark->lire) - { - include_once (DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'); - $langs->load("bookmarks"); + // Define $bookmarks + if ($conf->bookmark->enabled && $user->rights->bookmark->lire) + { + include_once (DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'); + $langs->load("bookmarks"); - $bookmarks=printBookmarksList($db, $langs); - } + $bookmarks=printBookmarksList($db, $langs); + } $left_menu=empty($conf->browser->phone)?$conf->top_menu:$conf->smart_menu; if (GETPOST('menu')) $left_menu=GETPOST('menu'); // menu=eldy_backoffice.php @@ -1365,104 +1400,104 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me print '
'."\n"; - $menuleft=new MenuLeft($db,$menu_array_before,$menu_array_after); - $menuleft->showmenu(); // output menu_array and menu found in database + $menuleft=new MenuLeft($db,$menu_array_before,$menu_array_after); + $menuleft->showmenu(); // output menu_array and menu found in database - // Show other forms - if ($searchform) - { - print "\n"; - print "\n"; - print '
'."\n"; - print $searchform; - print '
'."\n"; - print "\n"; - } + // Show other forms + if ($searchform) + { + print "\n"; + print "\n"; + print '
'."\n"; + print $searchform; + print '
'."\n"; + print "\n"; + } - // More search form - if ($moresearchform) - { - print $moresearchform; - } + // More search form + if ($moresearchform) + { + print $moresearchform; + } - // Bookmarks - if ($bookmarks) - { - print "\n"; - print "\n"; - print '
'."\n"; - print $bookmarks; - print '
'."\n"; - print "\n"; - } + // Bookmarks + if ($bookmarks) + { + print "\n"; + print "\n"; + print '
'."\n"; + print $bookmarks; + print '
'."\n"; + print "\n"; + } - // Link to Dolibarr wiki pages - if ($helppagename && empty($conf->global->MAIN_HELP_DISABLELINK)) - { - $langs->load("help"); + // Link to Dolibarr wiki pages + if ($helppagename && empty($conf->global->MAIN_HELP_DISABLELINK)) + { + $langs->load("help"); - $helpbaseurl=''; - $helppage=''; - $mode=''; + $helpbaseurl=''; + $helppage=''; + $mode=''; - // Get helpbaseurl, helppage and mode from helppagename and langs - $arrayres=getHelpParamFor($helppagename,$langs); - $helpbaseurl=$arrayres['helpbaseurl']; - $helppage=$arrayres['helppage']; - $mode=$arrayres['mode']; + // Get helpbaseurl, helppage and mode from helppagename and langs + $arrayres=getHelpParamFor($helppagename,$langs); + $helpbaseurl=$arrayres['helpbaseurl']; + $helppage=$arrayres['helppage']; + $mode=$arrayres['mode']; - // Link to help pages - if ($helpbaseurl && $helppage) - { - print ''; - } - } + // Link to help pages + if ($helpbaseurl && $helppage) + { + print ''; + } + } // Link to bugtrack - if (! empty($conf->global->MAIN_SHOW_BUGTRACK_LINK)) - { - $bugbaseurl='http://savannah.nongnu.org/bugs/?'; - $bugbaseurl.='func=additem&group=dolibarr&privacy=1&'; - $bugbaseurl.="&details="; - $bugbaseurl.=urlencode("\n\n\n\n\n-------------\n"); - $bugbaseurl.=urlencode($langs->trans("Version").": ".DOL_VERSION."\n"); - $bugbaseurl.=urlencode($langs->trans("Server").": ".$_SERVER["SERVER_SOFTWARE"]."\n"); - $bugbaseurl.=urlencode($langs->trans("Url").": ".$_SERVER["REQUEST_URI"]."\n"); - print ''; - } - print "\n"; + if (! empty($conf->global->MAIN_SHOW_BUGTRACK_LINK)) + { + $bugbaseurl='http://savannah.nongnu.org/bugs/?'; + $bugbaseurl.='func=additem&group=dolibarr&privacy=1&'; + $bugbaseurl.="&details="; + $bugbaseurl.=urlencode("\n\n\n\n\n-------------\n"); + $bugbaseurl.=urlencode($langs->trans("Version").": ".DOL_VERSION."\n"); + $bugbaseurl.=urlencode($langs->trans("Server").": ".$_SERVER["SERVER_SOFTWARE"]."\n"); + $bugbaseurl.=urlencode($langs->trans("Url").": ".$_SERVER["REQUEST_URI"]."\n"); + print ''; + } + print "\n"; - print "
\n"; - print "\n"; + print "\n"; + print "\n"; - print "\n"; + print "\n"; - // Execute hook printLeftBlock - $parameters=array(); + // Execute hook printLeftBlock + $parameters=array(); $leftblock=$hookmanager->executeHooks('printLeftBlock',$parameters); // Note that $action and $object may have been modified by some hooks print $leftblock; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print ' '."\n"; - else print '
'; - } + if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) + { + print '
'."\n"; + print '
'; + } - print '
'."\n"; + print ''."\n"; - print "\n"; + print "\n"; - print '
'."\n"; + print '
'."\n"; if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone)) { print '
'; @@ -1502,7 +1537,7 @@ function main_area($title='') print '
'."\n"; } - if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) print info_admin($langs->trans("WarningYouAreInMaintenanceMode",$conf->global->MAIN_ONLY_LOGIN_ALLOWED)); + if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) print info_admin($langs->trans("WarningYouAreInMaintenanceMode",$conf->global->MAIN_ONLY_LOGIN_ALLOWED)); } @@ -1515,34 +1550,34 @@ function main_area($title='') */ function getHelpParamFor($helppagename,$langs) { - if (preg_match('/^http/i',$helppagename)) - { - // If complete URL - $helpbaseurl='%s'; - $helppage=$helppagename; - $mode='local'; - } - else - { - // If WIKI URL - if (preg_match('/^es/i',$langs->defaultlang)) - { - $helpbaseurl='http://wiki.dolibarr.org/index.php/%s'; - if (preg_match('/ES:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1]; - } - if (preg_match('/^fr/i',$langs->defaultlang)) - { - $helpbaseurl='http://wiki.dolibarr.org/index.php/%s'; - if (preg_match('/FR:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1]; - } - if (empty($helppage)) // If help page not already found - { - $helpbaseurl='http://wiki.dolibarr.org/index.php/%s'; - if (preg_match('/EN:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1]; - } - $mode='wiki'; - } - return array('helpbaseurl'=>$helpbaseurl,'helppage'=>$helppage,'mode'=>$mode); + if (preg_match('/^http/i',$helppagename)) + { + // If complete URL + $helpbaseurl='%s'; + $helppage=$helppagename; + $mode='local'; + } + else + { + // If WIKI URL + if (preg_match('/^es/i',$langs->defaultlang)) + { + $helpbaseurl='http://wiki.dolibarr.org/index.php/%s'; + if (preg_match('/ES:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1]; + } + if (preg_match('/^fr/i',$langs->defaultlang)) + { + $helpbaseurl='http://wiki.dolibarr.org/index.php/%s'; + if (preg_match('/FR:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1]; + } + if (empty($helppage)) // If help page not already found + { + $helpbaseurl='http://wiki.dolibarr.org/index.php/%s'; + if (preg_match('/EN:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1]; + } + $mode='wiki'; + } + return array('helpbaseurl'=>$helpbaseurl,'helppage'=>$helppage,'mode'=>$mode); } @@ -1558,24 +1593,24 @@ function getHelpParamFor($helppagename,$langs) */ function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch,$htmlinputname) { - global $conf,$langs; + global $conf,$langs; - $ret=''; - $ret.=''; - $ret.='
'; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.='global->MAIN_HTML5_PLACEHOLDER)) $ret.=' placeholder="'.$langs->trans("SearchOf").''.strip_tags($title).'"'; - else $ret.=' title="'.$langs->trans("SearchOf").''.strip_tags($title).'"'; - $ret.=' name="'.$htmlinputname.'" size="10" /> '; - $ret.=''; - $ret.="
\n"; - return $ret; + $ret=''; + $ret.=''; + $ret.='
'; + $ret.=''; + $ret.=''; + $ret.=''; + $ret.='global->MAIN_HTML5_PLACEHOLDER)) $ret.=' placeholder="'.$langs->trans("SearchOf").''.strip_tags($title).'"'; + else $ret.=' title="'.$langs->trans("SearchOf").''.strip_tags($title).'"'; + $ret.=' name="'.$htmlinputname.'" size="10" /> '; + $ret.=''; + $ret.="
\n"; + return $ret; } @@ -1589,27 +1624,27 @@ if (! function_exists("llxFooter")) * @return void */ function llxFooter($foot='') - { - global $conf, $langs, $dolibarr_auto_user, $micro_start_time; + { + global $conf, $langs, $dolibarr_auto_user, $micro_start_time; - // Core error message - if (defined("MAIN_CORE_ERROR") && constant("MAIN_CORE_ERROR") == 1) - { - // Ajax version - if ($conf->use_javascript_ajax) - { - $title = img_warning().' '.$langs->trans('CoreErrorTitle'); - print ajax_dialog($title, $langs->trans('CoreErrorMessage')); - } - // html version - else - { - $msg = img_warning().' '.$langs->trans('CoreErrorMessage'); - print '
'.$msg.'
'; - } + // Core error message + if (defined("MAIN_CORE_ERROR") && constant("MAIN_CORE_ERROR") == 1) + { + // Ajax version + if ($conf->use_javascript_ajax) + { + $title = img_warning().' '.$langs->trans('CoreErrorTitle'); + print ajax_dialog($title, $langs->trans('CoreErrorMessage')); + } + // html version + else + { + $msg = img_warning().' '.$langs->trans('CoreErrorMessage'); + print '
'.$msg.'
'; + } - define("MAIN_CORE_ERROR",0); - } + define("MAIN_CORE_ERROR",0); + } print "\n\n"; if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone)) @@ -1617,20 +1652,20 @@ if (! function_exists("llxFooter")) print '
'."\n"; print '
'."\n"; } - print '
'."\n"; + print '
'."\n"; - print "\n".'
'."\n"; - if ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print ' '."\n"; + print "\n".' '."\n"; + if ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print ' '."\n"; print "\n"; if ($foot) print ''."\n"; printCommonFooter(); - print "\n"; - print "\n"; - } + print "\n"; + print "\n"; + } } ?>