2004-10-20 23:06:45 +02:00
< ? php
2008-09-30 02:10:49 +02:00
/* Copyright ( C ) 2002 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2004-01-28 01:25:15 +01:00
* Copyright ( C ) 2003 Xavier Dutoit < doli @ sydesy . com >
2012-02-23 08:45:26 +01:00
* Copyright ( C ) 2004 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
2012-12-30 15:11:07 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2012-02-23 08:45:26 +01:00
* Copyright ( C ) 2011 Philippe Grand < philippe . grand @ atoo - net . com >
* Copyright ( C ) 2008 Matteli
* Copyright ( C ) 2011 Juanjo Menent < jmenent @ 2 byte . es >
2012-12-05 19:56:23 +01:00
* Copyright ( C ) 2012 Christophe Battarel < christophe . battarel @ altairis . fr >
2012-02-29 19:41:12 +01:00
*
2012-02-23 08:45:26 +01:00
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2012-02-23 08:45:26 +01:00
* ( at your option ) any later version .
2012-02-29 19:41:12 +01:00
*
2012-02-23 08:45:26 +01:00
* 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 .
2012-02-29 19:41:12 +01:00
*
2012-02-23 08:45:26 +01:00
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
2003-06-18 15:56:26 +02:00
2005-03-21 20:53:50 +01:00
/**
2008-11-28 00:02:49 +01:00
* \file htdocs / main . inc . php
2012-02-23 08:45:26 +01:00
* \ingroup core
* \brief File that defines environment for Dolibarr pages only ( variables not required by scripts )
*/
2004-10-29 00:15:31 +02:00
2011-09-30 09:24:28 +02:00
//@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP
2010-02-28 03:01:46 +01:00
2008-11-28 00:02:49 +01:00
// For optionnal tuning. Enabled if environment variable DOL_TUNING is defined.
2010-02-19 14:50:49 +01:00
// A call first. Is the equivalent function dol_microtime_float not yet loaded.
2008-01-10 18:12:07 +01:00
$micro_start_time = 0 ;
if ( ! empty ( $_SERVER [ 'DOL_TUNING' ]))
{
2012-02-22 12:02:12 +01:00
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 ();
}
2008-01-10 18:12:07 +01:00
}
2011-03-07 23:35:35 +01:00
// Removed magic_quotes
2008-11-28 00:02:49 +01:00
if ( function_exists ( 'get_magic_quotes_gpc' )) // magic_quotes_* removed in PHP6
2005-11-22 23:27:20 +01:00
{
2012-02-22 12:02:12 +01:00
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).
2012-06-01 20:51:31 +02:00
// Off mode recommended (just do $db->escape for insert / update).
2012-02-22 12:02:12 +01:00
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 );
2012-06-01 20:51:31 +02:00
$_FILES = array_map ( 'stripslashes_deep' , $_FILES );
2012-02-22 12:02:12 +01:00
//$_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 );
}
2005-11-22 23:27:20 +01:00
}
2011-09-12 19:08:02 +02:00
/**
2011-11-26 12:36:36 +01:00
* Security : SQL Injection and XSS Injection ( scripts ) protection ( Filters on GET , POST , PHP_SELF ) .
2011-09-12 19:08:02 +02:00
*
* @ param string $val Value
2011-11-09 13:40:13 +01:00
* @ param string $type 1 = GET , 0 = POST , 2 = PHP_SELF
2011-09-21 00:28:31 +02:00
* @ return boolean true if there is an injection
2011-09-12 19:08:02 +02:00
*/
2011-11-09 13:40:13 +01:00
function test_sql_and_script_inject ( $val , $type )
2007-01-19 19:25:10 +01:00
{
2012-02-22 12:02:12 +01:00
$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 '<script', 'javascript:', '<style', 'onload\s=' on body tag, '="&' on a tag size with old browsers
// All examples on page: http://ha.ckers.org/xss.html#XSScalc
2011-11-02 22:15:59 +01:00
$sql_inj += preg_match ( '/<script/i' , $val );
2011-11-09 14:10:49 +01:00
$sql_inj += preg_match ( '/<style/i' , $val );
2011-11-08 17:11:30 +01:00
$sql_inj += preg_match ( '/base[\s]+href/i' , $val );
2011-11-09 13:40:13 +01:00
if ( $type == 1 )
{
2012-02-22 12:02:12 +01:00
$sql_inj += preg_match ( '/javascript:/i' , $val );
$sql_inj += preg_match ( '/vbscript:/i' , $val );
2011-11-09 13:40:13 +01:00
}
2012-02-22 12:02:12 +01:00
// For XSS Injection done by adding javascript closing html tags like with onmousemove, etc... (closing a src or href tag with not cleaned param)
if ( $type == 1 ) $sql_inj += preg_match ( '/"/i' , $val ); // We refused " in GET parameters value
if ( $type == 2 ) $sql_inj += preg_match ( '/[\s;"]/' , $val ); // PHP_SELF is an url and must match url syntax
return $sql_inj ;
2007-01-19 19:25:10 +01:00
}
2011-09-12 19:43:31 +02:00
2011-09-12 19:08:02 +02:00
/**
2011-11-26 12:36:36 +01:00
* Security : Return true if OK , false otherwise .
2011-09-12 19:08:02 +02:00
*
2011-09-21 00:28:31 +02:00
* @ param string & $var Variable name
2011-11-09 13:40:13 +01:00
* @ param string $type 1 = GET , 0 = POST , 2 = PHP_SELF
2011-09-12 20:15:11 +02:00
* @ return boolean true if ther is an injection
2011-09-12 19:08:02 +02:00
*/
2011-11-09 13:40:13 +01:00
function analyse_sql_and_script ( & $var , $type )
2007-01-19 19:25:10 +01:00
{
2012-02-22 12:02:12 +01:00
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 );
}
2007-01-19 19:25:10 +01:00
}
2011-09-12 20:15:11 +02:00
2011-03-07 23:35:35 +01:00
// Sanity check on URL
2011-03-08 17:38:58 +01:00
if ( ! empty ( $_SERVER [ " PHP_SELF " ]))
{
$morevaltochecklikepost = array ( $_SERVER [ " PHP_SELF " ]);
2011-11-09 13:40:13 +01:00
analyse_sql_and_script ( $morevaltochecklikepost , 2 );
2011-03-08 17:38:58 +01:00
}
2011-03-07 23:35:35 +01:00
// Sanity check on GET parameters
2011-03-08 17:38:58 +01:00
if ( ! empty ( $_SERVER [ " QUERY_STRING " ]))
{
$morevaltochecklikeget = array ( $_SERVER [ " QUERY_STRING " ]);
analyse_sql_and_script ( $morevaltochecklikeget , 1 );
}
2011-03-07 23:35:35 +01:00
// Sanity check on POST
analyse_sql_and_script ( $_POST , 0 );
2011-03-06 21:42:36 +01:00
2010-12-15 00:27:17 +01:00
// This is to make Dolibarr working with Plesk
2011-01-26 16:29:45 +01:00
if ( ! empty ( $_SERVER [ 'DOCUMENT_ROOT' ])) set_include_path ( $_SERVER [ 'DOCUMENT_ROOT' ] . '/htdocs' );
2008-01-20 22:53:43 +01:00
2010-12-29 13:13:36 +01:00
// Include the conf.php and functions.lib.php
2012-08-22 23:11:24 +02:00
require_once 'filefunc.inc.php' ;
2010-12-29 13:13:36 +01:00
2009-05-22 00:28:05 +02:00
// Init session. Name of session is specific to Dolibarr instance.
2010-12-29 13:13:36 +01:00
$prefix = dol_getprefix ();
$sessionname = 'DOLSESSID_' . $prefix ;
$sessiontimeout = 'DOLSESSTIMEOUT_' . $prefix ;
2009-06-14 18:25:23 +02:00
if ( ! empty ( $_COOKIE [ $sessiontimeout ])) ini_set ( 'session.gc_maxlifetime' , $_COOKIE [ $sessiontimeout ]);
2009-05-20 20:18:25 +02:00
session_name ( $sessionname );
session_start ();
2012-04-20 20:38:49 +02:00
if ( ini_get ( 'register_globals' )) // To solve bug in using $_SESSION
{
foreach ( $_SESSION as $key => $value )
{
if ( isset ( $GLOBALS [ $key ])) unset ( $GLOBALS [ $key ]);
}
}
2009-05-22 00:28:05 +02:00
2010-12-29 13:13:36 +01:00
// Init the 5 global objects
// This include will set: $conf, $db, $langs, $user, $mysoc objects
2012-08-22 23:11:24 +02:00
require_once 'master.inc.php' ;
2008-01-10 18:12:07 +01:00
2011-04-30 03:17:51 +02:00
// Activate end of page function
2011-03-09 16:06:33 +01:00
register_shutdown_function ( 'dol_shutdown' );
2010-12-29 13:13:36 +01:00
2011-02-20 13:16:18 +01:00
// Detection browser
if ( isset ( $_SERVER [ " HTTP_USER_AGENT " ]))
{
2012-02-29 19:41:12 +01:00
$tmp = getBrowserInfo ();
$conf -> browser -> phone = $tmp [ 'phone' ];
$conf -> browser -> name = $tmp [ 'browsername' ];
$conf -> browser -> os = $tmp [ 'browseros' ];
$conf -> browser -> firefox = $tmp [ 'browserfirefox' ];
$conf -> browser -> version = $tmp [ 'browserversion' ];
2011-02-20 13:16:18 +01:00
}
2010-02-20 12:40:36 +01:00
// Force HTTPS if required ($conf->file->main_force_https is 0/1 or https dolibarr root url)
2010-05-10 06:50:39 +02:00
if ( ! empty ( $conf -> file -> main_force_https ))
2008-04-06 22:17:11 +02:00
{
2012-02-22 12:02:12 +01:00
$newurl = '' ;
2012-12-12 02:37:15 +01:00
if ( is_numeric ( $conf -> file -> main_force_https ))
2012-02-22 12:02:12 +01:00
{
2012-12-12 02:37:15 +01:00
if ( $conf -> file -> main_force_https == '1' && ! empty ( $_SERVER [ " SCRIPT_URI " ])) // If SCRIPT_URI supported by server
2012-02-22 12:02:12 +01:00
{
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
{
2012-12-12 02:37:15 +01:00
// 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 = $conf -> file -> main_force_https . $_SERVER [ " REQUEST_URI " ];
}
2012-02-22 12:02:12 +01:00
}
// 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 );
}
2008-04-06 22:17:11 +02:00
}
2008-03-12 22:26:53 +01:00
2009-02-02 19:33:44 +01:00
2008-11-28 00:24:50 +01:00
// Chargement des includes complementaires de presentation
2012-08-22 23:11:24 +02:00
if ( ! defined ( 'NOREQUIREMENU' )) require_once DOL_DOCUMENT_ROOT . '/core/class/menu.class.php' ; // Need 10ko memory (11ko in 2.2)
if ( ! defined ( 'NOREQUIREHTML' )) require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php' ; // Need 660ko memory (800ko in 2.2)
if ( ! defined ( 'NOREQUIREAJAX' ) && $conf -> use_javascript_ajax ) require_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php' ; // Need 22ko memory
2006-06-03 01:20:36 +02:00
2009-08-08 18:26:06 +02:00
// 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 ))
{
2012-02-22 12:02:12 +01:00
dol_syslog ( " main.inc: A previous install or upgrade was not complete. Redirect to install page. " , LOG_WARNING );
2012-08-31 05:58:38 +02:00
header ( " Location: " . DOL_URL_ROOT . " /install/index.php " );
2012-02-22 12:02:12 +01:00
exit ;
2009-08-08 18:26:06 +02:00
}
// If an upgrade process is required, we call the install page.
2010-02-15 22:22:04 +01:00
if (( ! empty ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE ) && ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE != DOL_VERSION ))
|| ( empty ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE ) && ! empty ( $conf -> global -> MAIN_VERSION_LAST_INSTALL ) && ( $conf -> global -> MAIN_VERSION_LAST_INSTALL != DOL_VERSION )))
2009-08-08 18:26:06 +02:00
{
2011-07-12 22:16:03 +02:00
$versiontocompare = empty ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE ) ? $conf -> global -> MAIN_VERSION_LAST_INSTALL : $conf -> global -> MAIN_VERSION_LAST_UPGRADE ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
2012-02-22 12:02:12 +01:00
$dolibarrversionlastupgrade = preg_split ( '/[.-]/' , $versiontocompare );
$dolibarrversionprogram = preg_split ( '/[.-]/' , DOL_VERSION );
2011-07-12 22:16:03 +02:00
$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
2012-02-22 12:02:12 +01:00
{
dol_syslog ( " main.inc: database version " . $versiontocompare . " is lower than programs version " . DOL_VERSION . " . Redirect to install page. " , LOG_WARNING );
2012-08-31 05:58:38 +02:00
header ( " Location: " . DOL_URL_ROOT . " /install/index.php " );
2012-02-22 12:02:12 +01:00
exit ;
}
2009-08-08 18:26:06 +02:00
}
2010-02-19 14:50:49 +01:00
// Creation of a token against CSRF vulnerabilities
2009-05-26 19:01:18 +02:00
if ( ! defined ( 'NOTOKENRENEWAL' ))
{
2012-02-22 12:02:12 +01:00
$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 ;
2009-05-26 19:01:18 +02:00
}
2009-12-28 02:53:45 +01:00
if ( ! empty ( $conf -> global -> MAIN_SECURITY_CSRF )) // Check validity of token, only if option enabled (this option breaks some features sometimes)
2009-05-15 14:48:13 +02:00
{
2012-02-22 12:02:12 +01:00
if ( isset ( $_POST [ 'token' ]) && isset ( $_SESSION [ 'token' ]))
{
if (( $_POST [ 'token' ] != $_SESSION [ 'token' ]))
{
2012-07-13 10:15:47 +02:00
dol_syslog ( " Invalid token in " . $_SERVER [ 'HTTP_REFERER' ] . " , action= " . GETPOST ( 'action' ) . " , _POST['token']= " . GETPOST ( 'token' ) . " , _SESSION['token']= " . $_SESSION [ 'token' ], LOG_WARNING );
2012-02-22 12:02:12 +01:00
//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 );
}
}
2009-05-16 17:45:26 +02:00
}
2009-05-22 02:20:45 +02:00
// Disable modules (this must be after session_start and after conf has been loaded)
2011-04-26 23:06:45 +02:00
if ( GETPOST ( 'disablemodules' )) $_SESSION [ " disablemodules " ] = GETPOST ( 'disablemodules' );
2009-01-21 14:06:34 +01:00
if ( ! empty ( $_SESSION [ " disablemodules " ]))
2008-11-28 00:24:50 +01:00
{
2012-02-22 12:02:12 +01:00
$disabled_modules = explode ( ',' , $_SESSION [ " disablemodules " ]);
foreach ( $disabled_modules as $module )
{
if ( $module ) $conf -> $module -> enabled = false ;
}
2008-11-28 00:24:50 +01:00
}
2010-09-22 08:30:32 +02:00
2006-07-02 02:43:40 +02:00
/*
2009-05-08 03:23:33 +02:00
* Phase authentication / login
2013-02-24 02:47:30 +01:00
*/
2006-07-02 02:43:40 +02:00
$login = '' ;
2009-12-29 19:10:48 +01:00
if ( ! defined ( 'NOLOGIN' ))
2005-11-01 18:48:46 +01:00
{
2012-02-22 12:02:12 +01:00
// $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 );
// No authentication mode
2012-06-12 18:35:29 +02:00
if ( ! count ( $authmode ))
2012-02-22 12:02:12 +01:00
{
$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
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php' ;
2012-02-22 12:02:12 +01:00
// If in demo mode, we check we go to home page through the public/demo/index.php page
2012-07-13 10:15:47 +02:00
if ( ! empty ( $dolibarr_main_demo ) && $_SERVER [ 'PHP_SELF' ] == DOL_URL_ROOT . '/index.php' ) // We ask index page
2011-03-05 19:02:25 +01:00
{
if ( ! preg_match ( '/public/' , $_SERVER [ 'HTTP_REFERER' ]))
{
dol_syslog ( " Call index page from another url than demo page " );
header ( " Location: " . DOL_URL_ROOT . '/public/demo/index.php' );
exit ;
}
}
2012-02-22 12:02:12 +01:00
// Verification security graphic code
if ( GETPOST ( " username " , " alpha " , 2 ) && ! empty ( $conf -> global -> MAIN_SECURITY_ENABLECAPTCHA ))
{
2012-01-07 23:31:25 +01:00
$sessionkey = 'dol_antispam_value' ;
2012-01-07 21:32:35 +01:00
$ok = ( array_key_exists ( $sessionkey , $_SESSION ) === TRUE && ( strtolower ( $_SESSION [ $sessionkey ]) == strtolower ( $_POST [ 'code' ])));
2010-01-11 00:54:42 +01:00
2012-02-22 12:02:12 +01:00
// 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 ;
// Appel des triggers
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php' ;
2012-02-22 12:02:12 +01:00
$interface = new Interfaces ( $db );
2012-07-07 12:49:40 +02:00
$result = $interface -> run_triggers ( 'USER_LOGIN_FAILED' , $user , $user , $langs , $conf , GETPOST ( 'entity' , 'int' ));
2012-02-22 12:02:12 +01:00
if ( $result < 0 ) {
$error ++ ;
}
// Fin appel triggers
}
}
$usertotest = ( ! empty ( $_COOKIE [ 'login_dolibarr' ]) ? $_COOKIE [ 'login_dolibarr' ] : GETPOST ( " username " , " alpha " , 2 ));
2012-07-13 10:15:47 +02:00
$passwordtotest = ( ! empty ( $_COOKIE [ 'password_dolibarr' ]) ? $_COOKIE [ 'password_dolibarr' ] : GETPOST ( 'password' ));
$entitytotest = ( GETPOST ( 'entity' , 'int' ) ? GETPOST ( 'entity' , 'int' ) : 1 );
2012-02-22 12:02:12 +01:00
// 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 ;
2012-09-08 18:10:19 +02:00
if ( $dolibarr_main_authentication == 'forceuser' && ! empty ( $dolibarr_auto_user )) $goontestloop = true ;
2012-02-22 12:02:12 +01:00
if ( GETPOST ( " username " , " alpha " , 2 ) || ! empty ( $_COOKIE [ 'login_dolibarr' ]) || GETPOST ( 'openid_mode' , 'alpha' , 1 )) $goontestloop = true ;
2013-02-24 02:47:30 +01:00
$langcode = ( GETPOST ( 'lang' ) ? (( is_object ( $langs ) && $langs -> defaultlang ) ? $langs -> defaultlang : 'auto' ) : GETPOST ( 'lang' ));
if ( ! is_object ( $langs )) // This can occurs when calling page with NOREQUIRETRAN defined, however we need lang for error messages.
{
include_once DOL_DOCUMENT_ROOT . '/core/class/translate.class.php' ;
$langs = new Translate ( " " , $conf );
}
$langs -> setDefaultLang ( $langcode );
2012-02-22 12:02:12 +01:00
if ( $test && $goontestloop )
{
2013-02-24 02:47:30 +01:00
$login = checkLoginPassEntity ( $usertotest , $passwordtotest , $entitytotest , $authmode );
if ( $login )
2012-02-22 12:02:12 +01:00
{
$dol_authmode = $conf -> authmode ; // This properties is defined only when logged to say what mode was successfully used
$dol_tz = $_POST [ " tz " ];
2012-05-15 01:41:12 +02:00
$dol_tz_string = $_POST [ " tz_string " ];
2012-02-22 12:02:12 +01:00
$dol_dst = 0 ;
if ( isset ( $_POST [ " dst_first " ]) && isset ( $_POST [ " dst_second " ]))
{
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2011-11-01 04:57:45 +01:00
$datenow = dol_now ();
$datefirst = dol_stringtotime ( $_POST [ " dst_first " ]);
$datesecond = dol_stringtotime ( $_POST [ " dst_second " ]);
if ( $datenow >= $datefirst && $datenow < $datesecond ) $dol_dst = 1 ;
2012-02-22 12:02:12 +01:00
}
//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' );
// 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
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php' ;
2012-02-22 12:02:12 +01:00
$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
2012-09-08 17:43:14 +02:00
dol_loginfunction ( $langs , $conf ,( ! empty ( $mysoc ) ? $mysoc : '' ));
2012-02-22 12:02:12 +01:00
exit ;
}
$resultFetchUser = $user -> fetch ( '' , $login );
if ( $resultFetchUser <= 0 )
{
dol_syslog ( 'User not found, connexion refused' );
session_destroy ();
session_name ( $sessionname );
2012-04-20 20:38:49 +02:00
session_start (); // Fixing the bug of register_globals here is useless since session is empty
2012-02-22 12:02:12 +01:00
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 ;
}
// Call triggers
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php' ;
2012-02-22 12:02:12 +01:00
$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 );
$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 );
2012-04-20 20:38:49 +02:00
session_start (); // Fixing the bug of register_globals here is useless since session is empty
2012-02-22 12:02:12 +01:00
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 ;
}
// Call triggers
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php' ;
2012-02-22 12:02:12 +01:00
$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
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php' ;
2012-02-22 12:02:12 +01:00
$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 ;
// 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 : '' ;
2012-05-15 01:41:12 +02:00
$_SESSION [ " dol_tz_string " ] = isset ( $dol_tz_string ) ? $dol_tz_string : '' ;
2012-02-22 12:02:12 +01:00
$_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 ;
2012-08-05 21:14:17 +02:00
if ( GETPOST ( 'dol_hide_topmenu' )) $_SESSION [ 'dol_hide_topmenu' ] = 1 ;
if ( GETPOST ( 'dol_hide_leftmenu' )) $_SESSION [ 'dol_hide_leftmenu' ] = 1 ;
2012-02-22 12:02:12 +01:00
dol_syslog ( " This is a new started user session. _SESSION['dol_login']= " . $_SESSION [ " dol_login " ] . ' Session id=' . session_id ());
$db -> begin ();
$user -> update_last_login_date ();
// Call triggers
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php' ;
2012-02-22 12:02:12 +01:00
$interface = new Interfaces ( $db );
2012-07-13 10:15:47 +02:00
$result = $interface -> run_triggers ( 'USER_LOGIN' , $user , $user , $langs , $conf , GETPOST ( 'entity' , 'int' ));
2012-02-22 12:02:12 +01:00
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 ();
}
// Create entity cookie, just used for login page
2013-02-11 21:23:25 +01:00
// TODO Multicompany Move this into hook
2012-02-22 12:02:12 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && ! empty ( $conf -> global -> MULTICOMPANY_COOKIE_ENABLED ) && isset ( $_POST [ " entity " ]))
{
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/cookie.class.php' ;
2012-02-22 12:02:12 +01:00
$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 : '' );
$entityCookie = new DolCookie ( $cryptkey );
$entityCookie -> _setCookie ( $entityCookieName , $entity , $ttl );
}
2010-01-11 00:54:42 +01:00
2011-11-01 23:22:10 +01:00
// Hooks on successfull login
$action = '' ;
2012-03-02 14:51:16 +01:00
$hookmanager -> initHooks ( array ( 'login' ));
2011-11-01 23:22:10 +01:00
$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
2012-02-22 12:02:12 +01:00
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 ;
}
/*
* 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' ;
// Set javascript option
2011-04-26 23:06:45 +02:00
if ( ! GETPOST ( 'nojs' )) // If javascript was not disabled on URL
2010-08-27 23:02:31 +02:00
{
2012-02-22 12:02:12 +01:00
if ( ! empty ( $user -> conf -> MAIN_DISABLE_JAVASCRIPT ))
{
$conf -> use_javascript_ajax =! $user -> conf -> MAIN_DISABLE_JAVASCRIPT ;
}
2010-08-27 23:02:31 +02:00
}
else $conf -> use_javascript_ajax = 0 ;
2007-10-02 15:54:34 +02:00
}
2006-07-02 02:43:40 +02:00
2010-02-28 15:49:39 +01:00
if ( ! defined ( 'NOREQUIRETRAN' ))
2005-08-11 22:04:33 +02:00
{
2012-02-22 12:02:12 +01:00
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 ));
}
2005-08-11 22:04:33 +02:00
}
2005-10-02 22:38:46 +02:00
2010-02-19 14:50:49 +01:00
// Case forcing style from url
2011-04-26 22:11:18 +02:00
if ( GETPOST ( 'theme' ))
2007-08-02 21:07:50 +02:00
{
2012-02-22 12:02:12 +01:00
$conf -> theme = GETPOST ( 'theme' , 'alpha' , 1 );
$conf -> css = " /theme/ " . $conf -> theme . " /style.css.php " ;
2007-08-02 21:07:50 +02:00
}
2005-10-02 22:38:46 +02:00
2005-08-11 22:04:33 +02:00
2009-12-29 19:10:48 +01:00
if ( ! defined ( 'NOLOGIN' ))
{
2012-02-22 12:02:12 +01:00
// 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 ;
}
// Load permissions
$user -> getrights ();
2006-09-02 03:17:50 +02:00
}
2009-01-21 14:06:34 +01:00
2011-02-16 20:59:16 +01:00
2010-07-14 16:25:48 +02:00
dol_syslog ( " --- Access to " . $_SERVER [ " PHP_SELF " ]);
2009-08-29 00:46:40 +02:00
//Another call for easy debugg
//dol_syslog("Access to ".$_SERVER["PHP_SELF"].' GET='.join(',',array_keys($_GET)).'->'.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST));
2005-08-11 22:04:33 +02:00
2010-02-28 15:16:46 +01:00
// Load main languages files
if ( ! defined ( 'NOREQUIRETRAN' ))
{
2012-02-22 12:02:12 +01:00
$langs -> load ( " main " );
$langs -> load ( " dict " );
2010-02-28 15:16:46 +01:00
}
2003-03-11 17:25:07 +01:00
2008-04-09 20:13:45 +02:00
// Define some constants used for style of arrays
2010-08-29 19:43:51 +02:00
$bc = array ( 0 => 'class="impair"' , 1 => 'class="pair"' );
2010-10-02 22:47:55 +02:00
$bcdd = array ( 0 => 'class="impair drag drop"' , 1 => 'class="pair drag drop"' );
2010-09-14 09:05:31 +02:00
$bcnd = array ( 0 => 'class="impair nodrag nodrop"' , 1 => 'class="pair nodrag nodrop"' );
2003-09-06 14:41:17 +02:00
2012-07-23 20:52:55 +02:00
// Define messages variables
2012-07-29 08:26:33 +02:00
$mesg = '' ; $warning = '' ; $error = 0 ;
// deprecated, see setEventMessage() and dol_htmloutput_events()
$mesgs = array (); $warnings = array (); $errors = array ();
2012-07-23 20:52:55 +02:00
2009-06-14 14:38:45 +02:00
// Constants used to defined number of lines in textarea
if ( empty ( $conf -> browser -> firefox ))
2005-09-29 21:30:59 +02:00
{
2012-02-22 12:02:12 +01:00
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 );
2005-09-29 21:30:59 +02:00
}
else
{
2012-02-22 12:02:12 +01:00
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 );
2005-09-29 21:30:59 +02:00
}
2012-05-05 13:32:31 +02:00
$heightforframes = 52 ;
2010-04-03 17:08:09 +02:00
2011-04-01 11:50:30 +02:00
// Switch to another entity
2013-02-11 21:23:25 +01:00
// TODO Multicompany Remove this
2012-01-11 10:38:29 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && GETPOST ( 'action' ) == 'switchentity' )
2011-04-01 11:50:30 +02:00
{
2012-07-07 12:49:40 +02:00
if ( $mc -> switchEntity ( GETPOST ( 'entity' , 'int' )) > 0 )
2012-02-22 12:02:12 +01:00
{
2012-08-31 05:58:38 +02:00
header ( " Location: " . DOL_URL_ROOT . '/' );
2012-02-22 12:02:12 +01:00
exit ;
}
2011-04-01 11:50:30 +02:00
}
2010-04-03 17:08:09 +02:00
2013-01-17 18:39:15 +01:00
//print 'eee'.$conf->standard_menu;
2013-01-19 16:29:16 +01:00
// Init menu manager
if ( empty ( $user -> societe_id )) // If internal user or not defined
{
2013-01-25 17:44:23 +01:00
$conf -> standard_menu = ( empty ( $conf -> global -> MAIN_MENU_STANDARD_FORCED ) ? ( empty ( $conf -> global -> MAIN_MENU_STANDARD ) ? 'eldy_menu.php' : $conf -> global -> MAIN_MENU_STANDARD ) : $conf -> global -> MAIN_MENU_STANDARD_FORCED );
$conf -> smart_menu = ( empty ( $conf -> global -> MAIN_MENU_SMARTPHONE_FORCED ) ? ( empty ( $conf -> global -> MAIN_MENU_SMARTPHONE ) ? 'smartphone_menu.php' : $conf -> global -> MAIN_MENU_SMARTPHONE ) : $conf -> global -> MAIN_MENU_SMARTPHONE_FORCED );
2013-01-19 16:29:16 +01:00
}
else // If external user
{
2013-01-25 17:44:23 +01:00
$conf -> standard_menu = ( empty ( $conf -> global -> MAIN_MENUFRONT_STANDARD_FORCED ) ? ( empty ( $conf -> global -> MAIN_MENUFRONT_STANDARD ) ? 'eldy_menu.php' : $conf -> global -> MAIN_MENUFRONT_STANDARD ) : $conf -> global -> MAIN_MENUFRONT_STANDARD_FORCED );
$conf -> smart_menu = ( empty ( $conf -> global -> MAIN_MENUFRONT_SMARTPHONE_FORCED ) ? ( empty ( $conf -> global -> MAIN_MENUFRONT_SMARTPHONE ) ? 'smartphone_menu.php' : $conf -> global -> MAIN_MENUFRONT_SMARTPHONE ) : $conf -> global -> MAIN_MENUFRONT_SMARTPHONE_FORCED );
2013-01-19 16:29:16 +01:00
}
// Load the menu manager (only if not already done)
$file_menu = empty ( $conf -> browser -> phone ) ? $conf -> standard_menu : $conf -> smart_menu ;
2013-01-25 17:44:23 +01:00
if ( GETPOST ( 'menu' )) $file_menu = GETPOST ( 'menu' ); // example: menu=eldy_menu.php
2013-01-19 16:29:16 +01:00
if ( ! class_exists ( 'MenuManager' ))
{
$menufound = 0 ;
$dirmenus = array_merge ( array ( " /core/menus/ " ),( array ) $conf -> modules_parts [ 'menus' ]);
foreach ( $dirmenus as $dirmenu )
{
$menufound = dol_include_once ( $dirmenu . " standard/ " . $file_menu );
if ( $menufound ) break ;
}
if ( ! $menufound ) // If failed to include, we try with standard
{
2013-01-25 17:44:23 +01:00
dol_syslog ( " You define a menu manager ' " . $file_menu . " ' that can not be loaded. " , LOG_WARNING );
$file_menu = 'eldy_menu.php' ;
2013-01-19 16:29:16 +01:00
include_once DOL_DOCUMENT_ROOT . " /core/menus/standard/ " . $file_menu ;
}
}
2013-01-25 17:44:23 +01:00
$menumanager = new MenuManager ( $db , empty ( $user -> societe_id ) ? 0 : 1 );
2013-01-19 16:29:16 +01:00
2013-01-17 18:39:15 +01:00
2010-04-03 17:08:09 +02:00
2011-04-01 11:50:30 +02:00
// Functions
2004-02-21 01:15:04 +01:00
2010-02-28 05:32:18 +01:00
if ( ! function_exists ( " llxHeader " ))
{
2012-02-22 12:02:12 +01:00
/**
* Show HTML header HTML + BODY + Top menu + left menu + DIV
*
2011-09-12 19:43:31 +02:00
* @ param string $head Optionnal head lines
* @ param string $title HTML title
* @ param string $help_url Url links to help page
2012-02-22 12:02:12 +01:00
* 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
2011-09-12 19:43:31 +02:00
* @ 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
2012-02-22 12:02:12 +01:00
* @ param string $morequerystring Query string to add to the link " print " to get same parameters ( use only if autodetect fails )
* @ return void
*/
2012-05-07 17:05:15 +02:00
function llxHeader ( $head = '' , $title = '' , $help_url = '' , $target = '' , $disablejs = 0 , $disablehead = 0 , $arrayofjs = '' , $arrayofcss = '' , $morequerystring = '' )
{
2012-12-11 15:14:43 +01:00
global $conf ;
2013-01-28 20:30:33 +01:00
2013-01-17 18:39:15 +01:00
// html header
top_htmlhead ( $head , $title , $disablejs , $disablehead , $arrayofjs , $arrayofcss );
2012-12-12 02:37:15 +01:00
2013-01-17 18:39:15 +01:00
// top menu and left menu area
2012-08-05 21:14:17 +02:00
if ( empty ( $conf -> global -> MAIN_HIDE_TOP_MENU ))
{
top_menu ( $head , $title , $target , $disablejs , $disablehead , $arrayofjs , $arrayofcss , $morequerystring );
}
if ( empty ( $conf -> global -> MAIN_HIDE_LEFT_MENU ))
{
2012-05-07 17:05:15 +02:00
left_menu ( '' , $help_url , '' , '' , 1 , $title );
}
2013-01-28 20:30:33 +01:00
2013-01-17 18:39:15 +01:00
// main area
2012-05-07 17:05:15 +02:00
main_area ( $title );
}
2010-02-28 05:32:18 +01:00
}
2010-08-30 20:31:59 +02:00
/**
2011-03-08 12:32:52 +01:00
* Show HTTP header
2011-09-25 00:43:52 +02:00
*
* @ return void
2010-08-30 20:31:59 +02:00
*/
function top_httphead ()
{
global $conf ;
//header("Content-type: text/html; charset=UTF-8");
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.
2012-02-22 12:02:12 +01:00
if ( isset ( $conf -> global -> MAIN_OPTIMIZE_SPEED ) && ( $conf -> global -> MAIN_OPTIMIZE_SPEED & 0x04 )) {
ob_start ( " ob_gzhandler " );
}
2010-08-30 20:31:59 +02:00
}
2005-01-01 20:48:22 +01:00
/**
2012-02-18 17:10:29 +01:00
* Ouput html header of a page .
* This code is also duplicated into security2 . lib . php :: dol_loginfunction
2011-08-28 16:18:14 +02:00
*
* @ param string $head Optionnal head lines
* @ param string $title HTML title
* @ 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
2011-09-12 19:43:31 +02:00
* @ return void
2002-12-31 15:10:59 +01:00
*/
2008-09-30 02:10:49 +02:00
function top_htmlhead ( $head , $title = '' , $disablejs = 0 , $disablehead = 0 , $arrayofjs = '' , $arrayofcss = '' )
2002-12-31 15:10:59 +01:00
{
2012-02-22 12:02:12 +01:00
global $user , $conf , $langs , $db ;
top_httphead ();
if ( empty ( $conf -> css )) $conf -> css = '/theme/eldy/style.css.php' ; // If not defined, eldy by default
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' ;
//print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">';
//print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
//print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
//print '<!DOCTYPE HTML>';
print " \n " ;
if ( ! empty ( $conf -> global -> MAIN_USE_CACHE_MANIFEST )) print '<html manifest="cache.manifest">' . " \n " ;
else print '<html>' . " \n " ;
//print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">'."\n";
if ( empty ( $disablehead ))
{
print " <head> \n " ;
// Displays meta
print '<meta name="robots" content="noindex,nofollow">' . " \n " ; // Evite indexation par robots
print '<meta name="author" content="Dolibarr Development Team">' . " \n " ;
2013-01-10 09:23:52 +01:00
$favicon = dol_buildpath ( '/theme/' . $conf -> theme . '/img/favicon.ico' , 1 );
2012-02-22 12:02:12 +01:00
print '<link rel="shortcut icon" type="image/x-icon" href="' . $favicon . '"/>' . " \n " ;
// Displays title
$appli = 'Dolibarr' ;
if ( ! empty ( $conf -> global -> MAIN_APPLICATION_TITLE )) $appli = $conf -> global -> MAIN_APPLICATION_TITLE ;
if ( $title ) print '<title>' . $appli . ' - ' . $title . '</title>' ;
else print " <title> " . $appli . " </title> " ;
print " \n " ;
2005-04-17 02:23:43 +02:00
2011-10-31 11:01:26 +01:00
if ( ! defined ( 'DISABLE_JQUERY' ) && ! $disablejs && $conf -> use_javascript_ajax )
2010-08-22 20:02:32 +02:00
{
print '<!-- Includes for JQuery (Ajax library) -->' . " \n " ;
2010-10-11 14:06:43 +02:00
$jquerytheme = 'smoothness' ;
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_THEME )) $jquerytheme = $conf -> global -> MAIN_USE_JQUERY_THEME ;
2012-02-18 17:19:50 +01:00
if ( constant ( 'JS_JQUERY_UI' )) print '<link rel="stylesheet" type="text/css" href="' . JS_JQUERY_UI . 'css/' . $jquerytheme . '/jquery-ui.min.css" />' . " \n " ; // JQuery
2012-02-18 17:10:29 +01:00
else print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . '/includes/jquery/css/' . $jquerytheme . '/jquery-ui-latest.custom.css" />' . " \n " ; // JQuery
2011-07-06 14:09:19 +02:00
print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . '/includes/jquery/plugins/tiptip/tipTip.css" />' . " \n " ; // Tooltip
print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . '/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css" />' . " \n " ; // JNotify
2012-12-29 05:14:07 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_FILEUPLOAD ) || ( defined ( 'REQUIRE_JQUERY_FILEUPLOAD' ) && constant ( 'REQUIRE_JQUERY_FILEUPLOAD' ))) // jQuery fileupload
2011-07-03 15:16:46 +02:00
{
2012-05-30 11:55:16 +02:00
print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . '/includes/jquery/plugins/fileupload/css/jquery.fileupload-ui.css" />' . " \n " ;
2011-07-03 15:16:46 +02:00
}
2013-01-03 19:13:09 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_DATATABLES ) || ( defined ( 'REQUIRE_JQUERY_DATATABLES' ) && constant ( 'REQUIRE_JQUERY_DATATABLES' ))) // jQuery datatables
2011-08-30 20:30:38 +02:00
{
2012-02-22 12:02:12 +01:00
//print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/css/jquery.dataTables.css" />'."\n";
print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . '/includes/jquery/plugins/datatables/css/jquery.dataTables_jui.css" />' . " \n " ;
print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . '/includes/jquery/plugins/datatables/extras/ColReorder/css/ColReorder.css" />' . " \n " ;
print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . '/includes/jquery/plugins/datatables/extras/ColVis/css/ColVis.css" />' . " \n " ;
//print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/ColVis/css/ColVisAlt.css" />'."\n";
print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . '/includes/jquery/plugins/datatables/extras/TableTools/css/TableTools.css" />' . " \n " ;
2011-08-30 20:30:38 +02:00
}
2013-01-03 19:13:09 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_MULTISELECT ) || ( defined ( 'REQUIRE_JQUERY_MULTISELECT' ) && constant ( 'REQUIRE_JQUERY_MULTISELECT' ))) // jQuery multiselect
2012-03-24 12:49:11 +01:00
{
print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . '/includes/jquery/plugins/multiselect/css/ui.multiselect.css" />' . " \n " ;
}
2012-11-03 19:15:45 +01:00
// jQuery Timepicker
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_TIMEPICKER ) || defined ( 'REQUIRE_JQUERY_TIMEPICKER' ))
{
print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . '/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.css" />' . " \n " ;
}
2010-08-22 20:02:32 +02:00
}
print '<!-- Includes for Dolibarr, modules or specific pages-->' . " \n " ;
2013-01-08 15:21:56 +01:00
// Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
2011-03-26 13:26:55 +01:00
$themepath = dol_buildpath (( empty ( $conf -> global -> MAIN_FORCETHEMEDIR ) ? '' : $conf -> global -> MAIN_FORCETHEMEDIR ) . $conf -> css , 1 );
2013-01-12 16:00:38 +01:00
$themesubdir = '' ;
2013-01-08 15:21:56 +01:00
if ( ! empty ( $conf -> modules_parts [ 'theme' ])) // This slow down
{
2013-01-10 08:27:12 +01:00
foreach ( $conf -> modules_parts [ 'theme' ] as $reldir )
2013-01-08 15:21:56 +01:00
{
2013-01-12 16:00:38 +01:00
if ( file_exists ( dol_buildpath ( $reldir . $conf -> css , 0 )))
2013-01-08 15:21:56 +01:00
{
$themepath = dol_buildpath ( $reldir . $conf -> css , 1 );
2013-01-12 16:00:38 +01:00
$themesubdir = $reldir ;
2013-01-08 15:21:56 +01:00
break ;
2013-01-10 08:27:12 +01:00
}
2013-01-08 15:21:56 +01:00
}
}
2012-12-08 18:38:14 +01:00
$themeparam = '?lang=' . $langs -> defaultlang . '&theme=' . $conf -> theme . ( GETPOST ( 'optioncss' ) ? '&optioncss=' . GETPOST ( 'optioncss' , 'alpha' , 1 ) : '' ) . '&userid=' . $user -> id . '&entity=' . $conf -> entity ;
2012-04-05 19:25:58 +02:00
if ( ! empty ( $_SESSION [ 'dol_resetcache' ])) $themeparam .= '&dol_resetcache=' . $_SESSION [ 'dol_resetcache' ];
2013-01-08 15:21:56 +01:00
//print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
2012-02-22 12:02:12 +01:00
print '<link rel="stylesheet" type="text/css" title="default" href="' . $themepath . $themeparam . '">' . " \n " ;
2012-08-08 20:43:23 +02:00
2012-02-22 12:02:12 +01:00
// CSS forced by modules (relative url starting with /)
2013-01-08 15:21:56 +01:00
if ( ! empty ( $conf -> modules_parts [ 'css' ]))
2012-02-22 12:02:12 +01:00
{
2012-08-08 20:43:23 +02:00
$arraycss = ( array ) $conf -> modules_parts [ 'css' ];
foreach ( $arraycss as $modcss => $filescss )
2012-07-08 23:22:22 +02:00
{
2012-08-08 20:43:23 +02:00
$filescss = ( array ) $filescss ; // To be sure filecss is an array
foreach ( $filescss as $cssfile )
{
// cssfile is a relative path
2013-01-08 12:27:17 +01:00
print '<!-- Added by module ' . $modcss . '-->' . " \n " . '<link rel="stylesheet" type="text/css" title="default" href="' . dol_buildpath ( $cssfile , 1 );
2012-08-08 20:43:23 +02:00
// We add params only if page is not static, because some web server setup does not return content type text/css if url has parameters, so browser cache is not used.
if ( ! preg_match ( '/\.css$/i' , $cssfile )) print $themeparam ;
2013-01-08 12:27:17 +01:00
print '">' . " \n " ;
2012-08-08 20:43:23 +02:00
}
2012-07-08 23:22:22 +02:00
}
2012-02-22 12:02:12 +01:00
}
// CSS forced by page in top_htmlhead call (relative url starting with /)
if ( is_array ( $arrayofcss ))
{
foreach ( $arrayofcss as $cssfile )
{
2013-01-08 12:27:17 +01:00
print '<!-- Added by page -->' . " \n " . '<link rel="stylesheet" type="text/css" title="default" href="' . dol_buildpath ( $cssfile , 1 );
2011-05-18 14:59:09 +02:00
// We add params only if page is not static, because some web server setup does not return content type text/css if url has parameters and browser cache is not used.
2012-02-22 12:02:12 +01:00
if ( ! preg_match ( '/\.css$/i' , $cssfile )) print $themeparam ;
2013-01-08 12:27:17 +01:00
print '">' . " \n " ;
2012-02-22 12:02:12 +01:00
}
}
if ( empty ( $conf -> global -> MAIN_OPTIMIZEFORTEXTBROWSER )) print '<link rel="top" title="' . $langs -> trans ( " Home " ) . '" href="' . ( DOL_URL_ROOT ? DOL_URL_ROOT : '/' ) . '">' . " \n " ;
if ( empty ( $conf -> global -> MAIN_OPTIMIZEFORTEXTBROWSER )) print '<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1">' . " \n " ;
if ( empty ( $conf -> global -> MAIN_OPTIMIZEFORTEXTBROWSER )) print '<link rel="author" title="Dolibarr Development Team" href="http://www.dolibarr.org">' . " \n " ;
// Output standard javascript links
2012-09-03 11:45:01 +02:00
if ( ! $disablejs && ! empty ( $conf -> use_javascript_ajax ))
2012-02-22 12:02:12 +01:00
{
$ext = '.js' ;
// JQuery. Must be before other includes
print '<!-- Includes JS for JQuery -->' . " \n " ;
2012-11-17 11:48:51 +01:00
if ( constant ( 'JS_JQUERY' )) print '<script type="text/javascript" src="' . JS_JQUERY . 'jquery.min' . $ext . '"></script>' . " \n " ;
2012-02-18 14:55:41 +01:00
else print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/js/jquery-latest.min' . $ext . '"></script>' . " \n " ;
2012-02-22 12:02:12 +01:00
if ( constant ( 'JS_JQUERY_UI' )) print '<script type="text/javascript" src="' . JS_JQUERY_UI . 'jquery-ui.min.js"></script>' . " \n " ;
else print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/js/jquery-ui-latest.custom.min' . $ext . '"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/tablednd/jquery.tablednd_0_5' . $ext . '"></script>' . " \n " ;
2011-07-02 07:49:56 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/tiptip/jquery.tipTip.min' . $ext . '"></script>' . " \n " ;
2011-06-13 00:13:05 +02:00
// jQuery Layout
2012-02-22 12:02:12 +01:00
if ( ! empty ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT ) || defined ( 'REQUIRE_JQUERY_LAYOUT' ))
{
2011-07-06 13:43:39 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/layout/jquery.layout-latest' . $ext . '"></script>' . " \n " ;
2012-02-22 12:02:12 +01:00
}
// jQuery jnotify
2012-09-04 18:34:36 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLE_JQUERY_JNOTIFY ) && ! defined ( 'DISABLE_JQUERY_JNOTIFY' ))
2012-02-22 12:02:12 +01:00
{
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/jnotify/jquery.jnotify.min.js"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/core/js/jnotify.js"></script>' . " \n " ;
}
2012-09-07 17:23:16 +02:00
// jQuery blockUI
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_BLOCKUI ) || defined ( 'REQUIRE_JQUERY_BLOCKUI' ))
{
2012-09-03 22:05:13 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/blockUI/jquery.blockUI.js"></script>' . " \n " ;
2012-10-31 15:50:14 +01:00
print '<script type="text/javascript">' . " \n " ;
2012-10-31 16:15:37 +01:00
print 'var indicatorBlockUI = \'' . DOL_URL_ROOT . " /theme/ " . $conf -> theme . " /img/working2.gif " . '\';' . " \n " ;
2012-10-31 15:50:14 +01:00
print '</script>' . " \n " ;
2012-09-07 17:23:16 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/core/js/blockUI.js"></script>' . " \n " ;
2012-09-03 11:45:01 +02:00
}
2012-02-22 12:02:12 +01:00
// Flot
if ( empty ( $conf -> global -> MAIN_DISABLE_JQUERY_FLOT ))
{
if ( constant ( 'JS_JQUERY_FLOT' ))
{
print '<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="/javascript/excanvas/excanvas.min.js"></script><![endif]-->' . " \n " ;
print '<script type="text/javascript" src="' . JS_JQUERY_FLOT . 'jquery.flot.js"></script>' . " \n " ;
print '<script type="text/javascript" src="' . JS_JQUERY_FLOT . 'jquery.flot.pie.js"></script>' . " \n " ;
print '<script type="text/javascript" src="' . JS_JQUERY_FLOT . 'jquery.flot.stack.js"></script>' . " \n " ;
}
else
{
print '<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/flot/excanvas.min.js"></script><![endif]-->' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/flot/jquery.flot.min.js"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/flot/jquery.flot.pie.min.js"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/flot/jquery.flot.stack.min.js"></script>' . " \n " ;
}
}
2011-10-31 16:57:10 +01:00
// jQuery jeditable
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_JEDITABLE ))
{
2012-02-22 12:02:12 +01:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/jeditable/jquery.jeditable.min' . $ext . '"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/jeditable/jquery.jeditable.ui-datepicker.js"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/jeditable/jquery.jeditable.ui-autocomplete.js"></script>' . " \n " ;
print '<script type="text/javascript">' . " \n " ;
print 'var urlSaveInPlace = \'' . DOL_URL_ROOT . '/core/ajax/saveinplace.php\';' . " \n " ;
print 'var urlLoadInPlace = \'' . DOL_URL_ROOT . '/core/ajax/loadinplace.php\';' . " \n " ;
print 'var tooltipInPlace = \'' . $langs -> transnoentities ( 'ClickToEdit' ) . '\';' . " \n " ;
print 'var placeholderInPlace = \'' . $langs -> trans ( 'ClickToEdit' ) . '\';' . " \n " ;
print 'var cancelInPlace = \'' . $langs -> trans ( 'Cancel' ) . '\';' . " \n " ;
print 'var submitInPlace = \'' . $langs -> trans ( 'Ok' ) . '\';' . " \n " ;
print 'var indicatorInPlace = \'<img src="' . DOL_URL_ROOT . " /theme/ " . $conf -> theme . " /img/working.gif " . '">\';' . " \n " ;
print '</script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/core/js/editinplace.js"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js"></script>' . " \n " ;
2011-10-31 16:57:10 +01:00
}
2012-02-18 17:30:58 +01:00
// jQuery File Upload
2012-09-03 10:17:58 +02:00
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_FILEUPLOAD ) || ( defined ( 'REQUIRE_JQUERY_FILEUPLOAD' ) && constant ( 'REQUIRE_JQUERY_FILEUPLOAD' )))
2011-07-03 15:16:46 +02:00
{
2012-05-30 11:55:16 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/template/tmpl.min.js"></script>' . " \n " ;
2012-06-08 11:35:32 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/fileupload/js/jquery.iframe-transport.js"></script>' . " \n " ;
2012-05-30 11:55:16 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/fileupload/js/jquery.fileupload.js"></script>' . " \n " ;
2012-05-30 22:10:44 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/fileupload/js/jquery.fileupload-fp.js"></script>' . " \n " ;
2012-05-30 11:55:16 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/fileupload/js/jquery.fileupload-ui.js"></script>' . " \n " ;
2012-05-30 22:10:44 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/fileupload/js/jquery.fileupload-jui.js"></script>' . " \n " ;
2012-07-02 19:30:37 +02:00
print '<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE8+ -->' . " \n " ;
2012-08-06 20:38:03 +02:00
print '<!--[if gte IE 8]><script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/fileupload/js/cors/jquery.xdr-transport.js"></script><![endif]-->' . " \n " ;
2011-08-30 20:30:38 +02:00
}
2012-02-22 12:02:12 +01:00
// jQuery DataTables
2013-01-03 19:13:09 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_DATATABLES ) || ( defined ( 'REQUIRE_JQUERY_DATATABLES' ) && constant ( 'REQUIRE_JQUERY_DATATABLES' )))
2011-08-30 20:30:38 +02:00
{
2012-02-22 12:02:12 +01:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/datatables/js/jquery.dataTables.min' . $ext . '"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/datatables/extras/ColReorder/js/ColReorder.min' . $ext . '"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/datatables/extras/ColVis/js/ColVis.min' . $ext . '"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/datatables/extras/TableTools/js/TableTools.min' . $ext . '"></script>' . " \n " ;
2011-07-03 15:16:46 +02:00
}
2012-07-02 19:30:37 +02:00
// jQuery Multiselect
2013-01-03 19:13:09 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_MULTISELECT ) || ( defined ( 'REQUIRE_JQUERY_MULTISELECT' ) && constant ( 'REQUIRE_JQUERY_MULTISELECT' )))
2012-07-02 19:30:37 +02:00
{
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/multiselect/js/ui.multiselect.js"></script>' . " \n " ;
2012-03-24 12:49:11 +01:00
}
2012-02-18 17:30:58 +01:00
// CKEditor
if ( ! empty ( $conf -> fckeditor -> enabled ) && ( empty ( $conf -> global -> FCKEDITOR_EDITORNAME ) || $conf -> global -> FCKEDITOR_EDITORNAME == 'ckeditor' ))
{
print '<!-- Includes JS for CKEditor -->' . " \n " ;
2012-06-23 20:17:51 +02:00
$pathckeditor = DOL_URL_ROOT . '/includes/ckeditor/' ;
if ( constant ( 'JS_CKEDITOR' )) $pathckeditor = JS_CKEDITOR ; // To use external ckeditor js lib
print '<script type="text/javascript">' ;
print 'var CKEDITOR_BASEPATH = \'' . $pathckeditor . '\';' . " \n " ;
2013-01-12 16:00:38 +01:00
print 'var ckeditorConfig = \'' . dol_buildpath ( $themesubdir . '/theme/' . $conf -> theme . '/ckeditor/config.js' , 1 ) . '\';' . " \n " ; // $themesubdir='' in standard usage
2012-06-23 20:17:51 +02:00
print 'var ckeditorFilebrowserBrowseUrl = \'' . DOL_URL_ROOT . '/core/filemanagerdol/browser/default/browser.php?Connector=' . DOL_URL_ROOT . '/core/filemanagerdol/connectors/php/connector.php\';' . " \n " ;
print 'var ckeditorFilebrowserImageBrowseUrl = \'' . DOL_URL_ROOT . '/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector=' . DOL_URL_ROOT . '/core/filemanagerdol/connectors/php/connector.php\';' . " \n " ;
print '</script>' . " \n " ;
print '<script type="text/javascript" src="' . $pathckeditor . 'ckeditor_basic.js"></script>' . " \n " ;
2012-02-18 17:30:58 +01:00
}
2012-11-03 19:15:45 +01:00
// jQuery Timepicker
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_TIMEPICKER ) || defined ( 'REQUIRE_JQUERY_TIMEPICKER' ))
{
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js"></script>' . " \n " ;
}
2011-11-01 04:57:45 +01:00
2011-02-05 04:34:25 +01:00
// Global js function
print '<!-- Includes JS of Dolibarr -->' . " \n " ;
2011-10-24 09:36:58 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/core/js/lib_head.js"></script>' . " \n " ;
2011-11-01 04:57:45 +01:00
2011-10-31 11:01:26 +01:00
// Add datepicker default options
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/core/js/datepicker.js.php?lang=' . $langs -> defaultlang . '"></script>' . " \n " ;
2011-11-01 04:57:45 +01:00
2012-11-03 20:41:59 +01:00
// add timepicker default options
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_TIMEPICKER ) || defined ( 'REQUIRE_JQUERY_TIMEPICKER' ))
{
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/core/js/timepicker.js.php?lang=' . $langs -> defaultlang . '"></script>' . " \n " ;
}
2012-06-12 18:35:29 +02:00
// JS forced by modules (relative url starting with /)
2013-01-08 15:21:56 +01:00
if ( ! empty ( $conf -> modules_parts [ 'js' ])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2'))
2012-08-08 20:43:23 +02:00
{
$arrayjs = ( array ) $conf -> modules_parts [ 'js' ];
foreach ( $arrayjs as $modjs => $filesjs )
{
$filesjs = ( array ) $filesjs ; // To be sure filejs is an array
foreach ( $filesjs as $jsfile )
{
// jsfile is a relative path
2013-01-08 12:27:17 +01:00
print '<!-- Added by module ' . $modjs . '-->' . " \n " . '<script type="text/javascript" src="' . dol_buildpath ( $jsfile , 1 ) . '"></script>' . " \n " ;
2012-08-08 20:43:23 +02:00
}
}
}
2012-06-12 18:35:29 +02:00
// JS forced by page in top_htmlhead (relative url starting with /)
2011-10-31 11:01:26 +01:00
if ( is_array ( $arrayofjs ))
{
2012-02-22 12:02:12 +01:00
print '<!-- Includes JS specific to page -->' . " \n " ;
foreach ( $arrayofjs as $jsfile )
{
if ( preg_match ( '/^http/i' , $jsfile ))
{
print '<script type="text/javascript" src="' . $jsfile . '"></script>' . " \n " ;
}
else
{
if ( ! preg_match ( '/^\//' , $jsfile )) $jsfile = '/' . $jsfile ; // For backward compatibility
print '<script type="text/javascript" src="' . dol_buildpath ( $jsfile , 1 ) . '"></script>' . " \n " ;
}
}
2011-10-31 11:01:26 +01:00
}
2012-02-22 12:02:12 +01:00
}
2009-08-09 13:37:32 +02:00
2012-02-22 12:02:12 +01:00
if ( ! empty ( $head )) print $head . " \n " ;
if ( ! empty ( $conf -> global -> MAIN_HTML_HEADER )) print $conf -> global -> MAIN_HTML_HEADER . " \n " ;
2009-10-16 19:15:32 +02:00
2012-02-22 12:02:12 +01:00
print " </head> \n \n " ;
}
2010-04-06 23:56:03 +02:00
2012-02-22 12:02:12 +01:00
$conf -> headerdone = 1 ; // To tell header was output
2005-08-20 18:43:30 +02:00
}
2006-09-10 20:07:09 +02:00
2004-08-21 14:18:03 +02:00
2010-04-05 20:41:34 +02:00
/**
2011-01-19 11:37:59 +01:00
* Show an HTML header + a BODY + The top menu bar
2011-08-28 16:18:14 +02:00
*
2011-09-12 19:08:02 +02:00
* @ param string $head Lines in the HEAD
* @ param string $title Title of web page
* @ param string $target Target to use in menu links
* @ param int $disablejs Do not output links to js ( Ex : qd fonction utilisee par sous formulaire Ajax )
* @ param int $disablehead Do not output head section
* @ param array $arrayofjs Array of js files to add in header
* @ param array $arrayofcss Array of css files to add in header
* @ param string $morequerystring Query string to add to the link " print " to get same parameters ( use only if autodetect fails )
2011-09-25 00:43:52 +02:00
* @ return void
2010-04-05 20:41:34 +02:00
*/
2011-01-19 11:37:59 +01:00
function top_menu ( $head , $title = '' , $target = '' , $disablejs = 0 , $disablehead = 0 , $arrayofjs = '' , $arrayofcss = '' , $morequerystring = '' )
2010-04-05 20:41:34 +02:00
{
2012-02-22 12:02:12 +01:00
global $user , $conf , $langs , $db ;
global $dolibarr_main_authentication ;
2013-01-17 18:39:15 +01:00
global $hookmanager , $menumanager ;
2012-02-29 19:41:12 +01:00
2013-01-25 19:12:54 +01:00
// Instantiate hooks of thirdparty module
2012-03-02 14:51:16 +01:00
$hookmanager -> initHooks ( array ( 'toprightmenu' ));
2010-04-05 20:41:34 +02:00
2012-02-22 12:02:12 +01:00
$toprightmenu = '' ;
2010-06-27 15:19:38 +02:00
2012-02-22 12:02:12 +01:00
// For backward compatibility with old modules
if ( empty ( $conf -> headerdone )) top_htmlhead ( $head , $title , $disablejs , $disablehead , $arrayofjs , $arrayofcss );
2010-11-02 13:14:06 +01:00
2012-02-22 12:02:12 +01:00
print '<body id="mainbody">' ;
2010-11-02 13:14:06 +01:00
2012-02-22 12:02:12 +01:00
if ( $conf -> use_javascript_ajax )
{
2012-05-24 23:22:45 +02:00
if ( ! empty ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT ))
2012-02-22 12:02:12 +01:00
{
print ' < script type = " text/javascript " >
2010-10-30 09:54:26 +02:00
jQuery ( document ) . ready ( function () {
2011-09-20 11:40:27 +02:00
jQuery ( " body " ) . layout ( layoutSettings );
2010-10-30 09:54:26 +02:00
});
var layoutSettings = {
2010-11-04 08:13:17 +01:00
name : " mainlayout " ,
2010-10-30 09:54:26 +02:00
defaults : {
2010-10-30 10:40:53 +02:00
useStateCookie : true ,
2010-10-30 09:54:26 +02:00
size : " auto " ,
2010-10-30 12:11:48 +02:00
resizable : false ,
2010-10-31 10:05:56 +01:00
//paneClass: "none",
2010-10-30 09:54:26 +02:00
//resizerClass: "resizer",
//togglerClass: "toggler",
2010-10-30 10:32:16 +02:00
//buttonClass: "button",
//contentSelector: ".content",
//contentIgnoreSelector: "span",
2010-10-30 09:54:26 +02:00
togglerTip_open : " Close This Pane " ,
togglerTip_closed : " Open This Pane " ,
2011-08-15 19:43:40 +02:00
resizerTip : " Resize This Pane " ,
fxSpeed : " fast "
2010-10-30 12:26:56 +02:00
},
west : {
2010-10-31 10:05:56 +01:00
paneClass : " leftContent " ,
2011-08-15 19:43:40 +02:00
//spacing_closed: 14,
//togglerLength_closed: 14,
//togglerAlign_closed: "auto",
2010-10-30 12:26:56 +02:00
//togglerLength_open: 0,
2010-10-30 09:54:26 +02:00
// effect defaults - overridden on some panes
2010-10-30 12:26:56 +02:00
//slideTrigger_open: "mouseover",
2011-09-01 00:33:37 +02:00
initClosed : '.(empty($conf->browser->phone)?' false ':' true ').' ,
2010-10-30 12:26:56 +02:00
fxName : " drop " ,
2011-08-15 19:43:40 +02:00
fxSpeed : " fast " ,
2010-10-30 12:26:56 +02:00
fxSettings : { easing : " " }
2010-10-30 09:54:26 +02:00
},
north : {
paneClass : " none " ,
resizerClass : " none " ,
togglerClass : " none " ,
2010-10-30 10:32:16 +02:00
spacing_open : 0 ,
2010-10-30 09:54:26 +02:00
togglerLength_open : 0 ,
togglerLength_closed : - 1 ,
slidable : false ,
2011-08-15 19:43:40 +02:00
fxName : " none " ,
fxSpeed : " fast "
2010-10-30 09:54:26 +02:00
},
center : {
paneSelector : " #mainContent "
}
}
</ script > ' ;
2012-02-22 12:02:12 +01:00
}
2010-11-02 13:14:06 +01:00
2012-02-22 12:02:12 +01:00
if ( ! empty ( $conf -> global -> MAIN_MENU_USE_JQUERY_ACCORDION ))
{
print " \n " . ' < script type = " text/javascript " >
2010-11-01 10:49:34 +01:00
jQuery ( document ) . ready ( function () {
jQuery ( " .vmenu " ) . accordion ({
autoHeight : false ,
event : " mouseover " ,
2010-11-01 12:12:26 +01:00
//collapsible: true,
//active: 2,
2010-11-01 10:49:34 +01:00
header : " > .blockvmenupair > .menu_titre "
});
});
</ script > ' ;
2012-02-22 12:02:12 +01:00
}
2010-10-22 21:18:45 +02:00
2012-02-22 12:02:12 +01:00
// Wrapper to show tooltips
print " \n " . ' < script type = " text/javascript " >
2011-07-02 03:26:30 +02:00
jQuery ( document ) . ready ( function () {
jQuery ( function () {
2011-08-15 19:43:40 +02:00
jQuery ( " .classfortooltip " ) . tipTip ({ maxWidth : " '.dol_size(600,'width').'px " , edgeOffset : 10 , delay : 50 , fadeIn : 50 , fadeOut : 50 });
2011-07-02 03:26:30 +02:00
});
2010-10-22 21:18:45 +02:00
});
2011-07-02 03:26:30 +02:00
</ script > ' ;
2012-02-22 12:02:12 +01:00
}
2010-04-05 20:41:34 +02:00
2012-02-22 12:02:12 +01:00
/*
* Top menu
2012-05-07 17:05:15 +02:00
*/
2013-01-17 18:39:15 +01:00
print " \n " . '<!-- Start top horizontal -->' . " \n " ;
2010-11-02 13:14:06 +01:00
2012-07-08 23:22:22 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ) && ! empty ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT )) print '<div class="ui-layout-north"> <!-- Begin top layout -->' . " \n " ;
2010-10-22 21:18:45 +02:00
2012-08-05 21:14:17 +02:00
if ( empty ( $_SESSION [ 'dol_hide_topmenu' ]))
2012-02-22 12:02:12 +01:00
{
2012-08-05 21:14:17 +02:00
print '<div id="tmenu_tooltip" class="tmenu">' . " \n " ;
// Show menu
2013-01-17 18:39:15 +01:00
$menumanager -> atarget = $target ;
$menumanager -> showmenu ( 'top' ); // This contains a \n
2012-08-05 21:14:17 +02:00
print " </div> \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 = '<div class="login"><a href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $user -> id . '"' ;
2013-01-17 18:39:15 +01:00
$logintext .= $target ? ( ' target="' . $target . '"' ) : '' ;
2012-08-05 21:14:17 +02:00
$logintext .= '>' . $user -> login . '</a>' ;
if ( $user -> societe_id ) $logintext .= $companylink ;
$logintext .= '</div>' ;
$loginhtmltext .= '<u>' . $langs -> trans ( " User " ) . '</u>' ;
$loginhtmltext .= '<br><b>' . $langs -> trans ( " Name " ) . '</b>: ' . $user -> getFullName ( $langs );
$loginhtmltext .= '<br><b>' . $langs -> trans ( " Login " ) . '</b>: ' . $user -> login ;
$loginhtmltext .= '<br><b>' . $langs -> trans ( " Administrator " ) . '</b>: ' . yn ( $user -> admin );
$type = ( $user -> societe_id ? $langs -> trans ( " External " ) . $company : $langs -> trans ( " Internal " ));
$loginhtmltext .= '<br><b>' . $langs -> trans ( " Type " ) . '</b>: ' . $type ;
$loginhtmltext .= '<br><b>' . $langs -> trans ( " IPAddress " ) . '</b>: ' . $_SERVER [ " REMOTE_ADDR " ];
$loginhtmltext .= '<br>' ;
$loginhtmltext .= '<br><u>' . $langs -> trans ( " Connection " ) . '</u>' ;
if ( ! empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY )) $loginhtmltext .= '<br><b>' . $langs -> trans ( " ConnectedOnMultiCompany " ) . '</b>: ' . $conf -> entity . ' (user entity ' . $user -> entity . ')' ;
$loginhtmltext .= '<br><b>' . $langs -> trans ( " ConnectedSince " ) . '</b>: ' . dol_print_date ( $user -> datelastlogin , " dayhour " );
$loginhtmltext .= '<br><b>' . $langs -> trans ( " PreviousConnexion " ) . '</b>: ' . dol_print_date ( $user -> datepreviouslogin , " dayhour " );
$loginhtmltext .= '<br><b>' . $langs -> trans ( " AuthenticationMode " ) . '</b>: ' . $_SESSION [ " dol_authmode " ];
$loginhtmltext .= '<br><b>' . $langs -> trans ( " CurrentTheme " ) . '</b>: ' . $conf -> theme ;
2013-01-25 17:44:23 +01:00
$loginhtmltext .= '<br><b>' . $langs -> trans ( " CurrentMenuManager " ) . '</b>: ' . $menumanager -> name ;
2012-08-05 21:14:17 +02:00
$s = picto_from_langcode ( $langs -> getDefaultLang ());
$loginhtmltext .= '<br><b>' . $langs -> trans ( " CurrentUserLanguage " ) . '</b>: ' . ( $s ? $s . ' ' : '' ) . $langs -> getDefaultLang ();
$loginhtmltext .= '<br><b>' . $langs -> trans ( " Browser " ) . '</b>: ' . $conf -> browser -> name . ( $conf -> browser -> version ? ' ' . $conf -> browser -> version : '' ) . ' (' . $_SERVER [ 'HTTP_USER_AGENT' ] . ')' ;
if ( ! empty ( $conf -> browser -> phone )) $loginhtmltext .= '<br><b>' . $langs -> trans ( " Phone " ) . '</b>: ' . $conf -> browser -> phone ;
if ( ! empty ( $_SESSION [ " disablemodules " ])) $loginhtmltext .= '<br><b>' . $langs -> trans ( " DisabledModules " ) . '</b>: <br>' . join ( ', ' , explode ( ',' , $_SESSION [ " disablemodules " ]));
$appli = 'Dolibarr' ;
if ( ! empty ( $conf -> global -> MAIN_APPLICATION_TITLE )) $appli = $conf -> global -> MAIN_APPLICATION_TITLE ;
// Link info
$logouttext = '' ;
$logouthtmltext = $appli . ' ' . DOL_VERSION . '<br>' ;
$logouthtmltext .= $langs -> trans ( " Logout " ) . '<br>' ;
//$logouthtmltext.="<br>";
if ( $_SESSION [ " dol_authmode " ] != 'forceuser'
&& $_SESSION [ " dol_authmode " ] != 'http' )
{
2012-08-18 20:51:30 +02:00
$logouttext .= '<a href="' . DOL_URL_ROOT . '/user/logout.php"' ;
2013-01-28 14:40:15 +01:00
//$logouttext .=empty($atarget?(' target="'.$atarget.'"'):'';
2012-08-18 20:51:30 +02:00
$logouttext .= '>' ;
$logouttext .= img_picto ( $langs -> trans ( 'Logout' ), 'logout.png' , 'class="login"' );
$logouttext .= '</a>' ;
2012-08-05 21:14:17 +02:00
}
else
{
2012-08-18 20:51:30 +02:00
$logouttext .= img_picto ( $langs -> trans ( 'Logout' ), 'logout.png' , 'class="login"' );
2012-08-05 21:14:17 +02:00
}
print '<div class="login_block">' . " \n " ;
print '<table class="nobordernopadding" summary=""><tr>' ;
$form = new Form ( $db );
$toprightmenu .= $form -> textwithtooltip ( '' , $loginhtmltext , 2 , 1 , $logintext , '' , 1 );
// Execute hook printTopRightMenu (hooks should output string like '<td><div class="login"><a href="">mylink</a></div></td>')
$parameters = array ();
$toprightmenu .= $hookmanager -> executeHooks ( 'printTopRightMenu' , $parameters ); // Note that $action and $object may have been modified by some hooks
// Logout link
$toprightmenu .= $form -> textwithtooltip ( '' , $logouthtmltext , 2 , 1 , $logouttext , '' , 1 );
// 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 ;
2013-02-21 23:08:58 +01:00
$text = '<a href="' . $_SERVER [ " PHP_SELF " ] . '?' . $qs . ( $qs ? '&' : '' ) . 'optioncss=print" target="_blank">' ;
2012-08-18 20:51:30 +02:00
$text .= img_picto ( '' , 'printer.png' , 'class="printer"' );
2012-08-05 21:14:17 +02:00
$text .= '</a>' ;
$toprightmenu .= $form -> textwithtooltip ( '' , $langs -> trans ( " PrintContentArea " ), 2 , 1 , $text , '' , 1 );
}
print $toprightmenu ;
print '</tr></table>' . " \n " ;
print " </div> \n " ;
2012-02-22 12:02:12 +01:00
}
2012-07-08 23:22:22 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ) && ! empty ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT )) print " </div><!-- End top layout --> \n " ;
2010-11-02 13:28:27 +01:00
2012-02-22 12:02:12 +01:00
print " <!-- End top horizontal menu --> \n " ;
2010-11-02 13:28:27 +01:00
2012-07-08 23:22:22 +02:00
if ( empty ( $conf -> use_javascript_ajax ) || empty ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT )) print '<table width="100%" class="notopnoleftnoright" summary="leftmenutable" id="undertopmenu"><tr>' ;
2011-02-16 20:59:16 +01:00
2010-04-05 20:41:34 +02:00
}
2005-01-01 20:48:22 +01:00
/**
2010-11-05 21:11:33 +01:00
* Show left menu bar
2011-09-25 00:43:52 +02:00
*
* @ param array $menu_array_before Table of menu entries to show before entries of menu handler
* @ param string $helppagename Name of wiki page for help ( '' by default ) .
* Syntax is : For a wiki page : EN : EnglishPage | FR : FrenchPage | ES : SpanishPage
* For other external page : http :// server / url
* @ param string $moresearchform Search Form Permanent Supplemental
* @ param array $menu_array_after Table of menu entries to show after entries of menu handler
* @ param int $leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules .
* @ param string $title Title of web page
* @ return void
2003-01-13 22:33:41 +01:00
*/
2011-02-16 20:59:16 +01:00
function left_menu ( $menu_array_before , $helppagename = '' , $moresearchform = '' , $menu_array_after = '' , $leftmenuwithoutmainarea = 0 , $title = '' )
2003-01-13 22:33:41 +01:00
{
2012-02-22 12:02:12 +01:00
global $user , $conf , $langs , $db ;
2013-01-17 18:39:15 +01:00
global $hookmanager , $menumanager ;
2002-05-09 16:57:48 +02:00
2012-02-22 12:02:12 +01:00
$searchform = '' ;
$bookmarks = '' ;
2009-02-24 03:41:21 +01:00
2012-02-22 12:02:12 +01:00
// Instantiate hooks of thirdparty module
2012-03-15 22:37:42 +01:00
$hookmanager -> initHooks ( array ( 'searchform' , 'leftblock' ));
2012-02-22 12:02:12 +01:00
2012-08-06 08:17:36 +02:00
if ( empty ( $_SESSION [ 'dol_hide_leftmenu' ]))
{
2012-08-05 21:14:17 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ) && ! empty ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT )) print " \n " . '<div class="ui-layout-west"> <!-- Begin left layout -->' . " \n " ;
else print '<td class="vmenu" valign="top">' ;
print " \n " ;
// Define $searchform
if ( ! empty ( $conf -> societe -> enabled ) && ! empty ( $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 ( ! empty ( $conf -> societe -> enabled ) && ! empty ( $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' );
}
if ((( ! empty ( $conf -> product -> enabled ) && $user -> rights -> produit -> lire ) || ( ! empty ( $conf -> service -> enabled ) && $user -> rights -> service -> lire ))
&& ! empty ( $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' );
}
2012-12-05 19:56:23 +01:00
if ((( ! empty ( $conf -> product -> enabled ) && $user -> rights -> produit -> lire ) || ( ! empty ( $conf -> service -> enabled ) && $user -> rights -> service -> lire ))
&& ! empty ( $conf -> global -> MAIN_SEARCHFORM_PRODUITSERVICE ))
{
$langs -> load ( " products " );
$searchform .= printSearchForm ( DOL_URL_ROOT . '/fourn/product/liste.php' , DOL_URL_ROOT . '/fourn/product/liste.php' , img_object ( '' , 'product' ) . ' ' . $langs -> trans ( " SupplierRef " ), 'products' , 'srefsupplier' );
}
2012-08-05 21:14:17 +02:00
if ( ! empty ( $conf -> adherent -> enabled ) && ! empty ( $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
2012-09-05 14:41:45 +02:00
if ( ! empty ( $conf -> bookmark -> enabled ) && $user -> rights -> bookmark -> lire )
2012-08-05 21:14:17 +02:00
{
include_once ( DOL_DOCUMENT_ROOT . '/bookmarks/bookmarks.lib.php' );
$langs -> load ( " bookmarks " );
$bookmarks = printBookmarksList ( $db , $langs );
}
// Left column
2013-01-17 18:39:15 +01:00
print '<!-- Begin left menu -->' . " \n " ;
2012-08-05 21:14:17 +02:00
print '<div class="vmenu">' . " \n " ;
2013-01-17 18:39:15 +01:00
$menumanager -> menu_array = $menu_array_before ;
$menumanager -> menu_array_after = $menu_array_after ;
$menumanager -> showmenu ( 'left' ); // output menu_array and menu found in database
2012-08-05 21:14:17 +02:00
// Show other forms
if ( $searchform )
{
print " \n " ;
print " <!-- Begin SearchForm --> \n " ;
print '<div id="blockvmenusearch" class="blockvmenusearch">' . " \n " ;
print $searchform ;
print '</div>' . " \n " ;
print " <!-- End SearchForm --> \n " ;
}
// More search form
if ( $moresearchform )
{
print $moresearchform ;
}
// Bookmarks
if ( $bookmarks )
{
print " \n " ;
print " <!-- Begin Bookmarks --> \n " ;
print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">' . " \n " ;
print $bookmarks ;
print '</div>' . " \n " ;
print " <!-- End Bookmarks --> \n " ;
}
// Link to Dolibarr wiki pages
if ( $helppagename && empty ( $conf -> global -> MAIN_HELP_DISABLELINK ))
{
$langs -> load ( " help " );
$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' ];
// Link to help pages
if ( $helpbaseurl && $helppage )
{
print '<div id="blockvmenuhelp" class="blockvmenuhelp">' ;
print '<a class="help" target="_blank" title="' . $langs -> trans ( $mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage' );
if ( $mode == 'wiki' ) print ' - ' . $langs -> trans ( " PageWiki " ) . ' "' . dol_escape_htmltag ( strtr ( $helppage , '_' , ' ' )) . '"' ;
print '" href="' ;
2012-11-10 16:24:20 +01:00
if ( $mode == 'wiki' ) print sprintf ( $helpbaseurl , urlencode ( html_entity_decode ( $helppage )));
else print sprintf ( $helpbaseurl , $helppage );
2012-08-05 21:14:17 +02:00
print '">' ;
print img_picto ( '' , 'helpdoc' ) . ' ' ;
print $langs -> trans ( $mode == 'wiki' ? 'OnlineHelp' : 'Help' );
//if ($mode == 'wiki') print ' ('.dol_trunc(strtr($helppage,'_',' '),8).')';
print '</a>' ;
print '</div>' ;
}
}
// Link to bugtrack
2012-09-19 17:18:52 +02:00
if ( ! empty ( $conf -> global -> MAIN_BUGTRACK_ENABLELINK ))
2012-08-05 21:14:17 +02:00
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2012-08-06 08:17:36 +02:00
$bugbaseurl = 'https://doliforge.org/tracker/?' ;
$bugbaseurl .= 'func=add&group_id=144&atid=246' ;
2012-08-05 21:14:17 +02:00
$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 " );
2012-08-06 08:17:36 +02:00
$bugbaseurl .= urlencode ( $langs -> trans ( " PHP " ) . " : " . version_php () . " \n " );
2012-08-05 21:14:17 +02:00
$bugbaseurl .= urlencode ( $langs -> trans ( " Url " ) . " : " . $_SERVER [ " REQUEST_URI " ] . " \n " );
2012-08-06 08:17:36 +02:00
print '<div id="blockvmenubugtracker" class="blockvmenuhelp"><a class="help" target="_blank" href="' . $bugbaseurl . '">' . $langs -> trans ( " FindBug " ) . '</a></div>' ;
2012-08-05 21:14:17 +02:00
}
print " \n " ;
print " </div> \n " ;
print " <!-- End left menu --> \n " ;
print " \n " ;
// 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 ( ! empty ( $conf -> use_javascript_ajax ) && ! empty ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT )) print '</div> <!-- End left layout -->' . " \n " ;
else print '</td>' ;
2012-02-22 12:02:12 +01:00
}
print " \n " ;
2011-02-16 20:59:16 +01:00
print '<!-- Begin right area -->' . " \n " ;
2010-11-05 21:11:33 +01:00
2012-02-22 12:02:12 +01:00
if ( empty ( $leftmenuwithoutmainarea )) main_area ( $title );
2010-10-29 19:54:15 +02:00
}
2008-09-30 02:10:49 +02:00
2011-09-25 00:43:52 +02:00
2010-10-29 19:54:15 +02:00
/**
* Begin main area
2011-09-25 00:43:52 +02:00
*
* @ param string $title Title
* @ return void
2010-10-29 19:54:15 +02:00
*/
2011-02-16 20:59:16 +01:00
function main_area ( $title = '' )
2010-10-29 19:54:15 +02:00
{
2012-02-22 12:02:12 +01:00
global $conf , $langs ;
2010-11-02 13:14:06 +01:00
2012-07-08 23:22:22 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ) && ! empty ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT ))
2012-02-22 12:02:12 +01:00
{
print '<div id="mainContent"><div class="ui-layout-center"> <!-- begin main layout -->' . " \n " ;
print '<table width="100%" class="notopnoleftnoright" summary="centermenutable" id="undertopmenu"><tr>' ;
}
2010-11-02 13:14:06 +01:00
2012-02-22 12:02:12 +01:00
print '<td valign="top">' . " \n " ;
2010-11-02 13:14:06 +01:00
2012-02-22 12:02:12 +01:00
print " \n " ;
2010-11-02 13:14:06 +01:00
2012-02-22 12:02:12 +01:00
print '<div class="fiche"> <!-- begin div class="fiche" -->' . " \n " ;
2012-02-29 20:58:05 +01:00
if ( preg_match ( '/^smartphone/' , $conf -> smart_menu ) && ! empty ( $conf -> browser -> phone ))
2011-02-16 20:59:16 +01:00
{
print '<div data-role="page"> <!-- begin div data-role="page" -->' ;
print '<div data-role="header" data-nobackbtn="false" data-theme="b">' ;
print '<div id="dol-homeheader">' . " \n " ;
$appli = 'Dolibarr' ;
if ( ! empty ( $conf -> global -> MAIN_APPLICATION_TITLE )) $appli = $conf -> global -> MAIN_APPLICATION_TITLE ;
print $appli ;
print '</div>' . " \n " ;
print '</div>' . " \n " ;
print " \n " ;
print '<div data-role="content"> <!-- begin div data-role="content" -->' . " \n " ;
}
2012-02-22 12:02:12 +01:00
if ( ! empty ( $conf -> global -> MAIN_ONLY_LOGIN_ALLOWED )) print info_admin ( $langs -> trans ( " WarningYouAreInMaintenanceMode " , $conf -> global -> MAIN_ONLY_LOGIN_ALLOWED ));
2002-05-04 01:01:45 +02:00
}
2004-08-13 23:45:23 +02:00
2009-10-04 00:32:10 +02:00
/**
2011-02-20 14:04:53 +01:00
* Return helpbaseurl , helppage and mode
2011-09-25 00:43:52 +02:00
*
2012-11-10 16:24:20 +01:00
* @ param string $helppagename Page name ( 'EN:xxx,ES:eee,FR:fff...' or 'http://localpage' )
2011-09-25 00:43:52 +02:00
* @ param Translate $langs Language
* @ return array Array of help urls
2009-10-04 00:32:10 +02:00
*/
function getHelpParamFor ( $helppagename , $langs )
{
2012-07-09 12:31:21 +02:00
$helpbaseurl = '' ;
$helppage = '' ;
$mode = '' ;
2012-02-22 12:02:12 +01:00
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 );
2009-10-04 00:32:10 +02:00
}
2004-08-13 23:45:23 +02:00
2005-01-01 20:48:22 +01:00
/**
2011-02-16 20:59:16 +01:00
* Show a search area
2011-08-23 00:26:57 +02:00
*
2011-09-25 00:43:52 +02:00
* @ param string $urlaction Url post
* @ param string $urlobject Url of the link under the search box
* @ param string $title Title search area
* @ param string $htmlmodesearch Value to set into parameter " mode_search " ( 'soc' , 'contact' , 'products' , 'member' , ... )
* @ param string $htmlinputname Field Name input form
* @ return void
2004-08-13 23:45:23 +02:00
*/
2011-09-25 00:43:52 +02:00
function printSearchForm ( $urlaction , $urlobject , $title , $htmlmodesearch , $htmlinputname )
2004-08-13 23:45:23 +02:00
{
2012-02-22 12:02:12 +01:00
global $conf , $langs ;
$ret = '' ;
$ret .= '<div class="menu_titre">' ;
$ret .= '<a class="vsmenu" href="' . $urlobject . '">' ;
$ret .= $title . '</a><br>' ;
$ret .= '</div>' ;
$ret .= '<form action="' . $urlaction . '" method="post">' ;
$ret .= '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
$ret .= '<input type="hidden" name="mode" value="search">' ;
$ret .= '<input type="hidden" name="mode_search" value="' . $htmlmodesearch . '">' ;
$ret .= '<input type="text" class="flat" ' ;
if ( ! empty ( $conf -> 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 .= '<input type="submit" class="button" value="' . $langs -> trans ( " Go " ) . '">' ;
$ret .= " </form> \n " ;
return $ret ;
2004-08-13 23:45:23 +02:00
}
2010-03-16 02:18:25 +01:00
if ( ! function_exists ( " llxFooter " ))
2002-12-12 17:42:08 +01:00
{
2011-09-25 00:43:52 +02:00
/**
* Show HTML footer
2011-11-26 12:36:36 +01:00
* Close div / DIV data - role = page + / DIV class = fiche + / DIV / DIV main layout + / BODY + / HTML .
2011-09-25 00:43:52 +02:00
*
* @ param string $foot A text to add in HTML generated page
* @ return void
*/
function llxFooter ( $foot = '' )
2012-02-22 12:02:12 +01:00
{
2012-09-08 18:10:19 +02:00
global $conf , $langs ;
2012-02-22 12:02:12 +01:00
2012-07-29 08:26:33 +02:00
// Global html output events ($mesgs, $errors, $warnings)
dol_htmloutput_events ();
2012-02-22 12:02:12 +01:00
// 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 '<div class="error">' . $msg . '</div>' ;
}
define ( " MAIN_CORE_ERROR " , 0 );
}
2008-09-30 02:10:49 +02:00
2011-02-16 20:59:16 +01:00
print " \n \n " ;
2012-02-29 20:58:05 +01:00
if ( preg_match ( '/^smartphone/' , $conf -> smart_menu ) && ! empty ( $conf -> browser -> phone ))
2011-02-16 20:59:16 +01:00
{
print '</div> <!-- end div data-role="content" -->' . " \n " ;
print '</div> <!-- end div data-role="page" -->' . " \n " ;
}
2012-02-22 12:02:12 +01:00
print '</div> <!-- end div class="fiche" -->' . " \n " ;
2011-02-16 20:59:16 +01:00
2008-06-19 00:56:02 +02:00
2012-02-22 12:02:12 +01:00
print " \n " . '</td></tr></table> <!-- end right area -->' . " \n " ;
if ( $conf -> use_javascript_ajax && ! empty ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT )) print '</div></div> <!-- end main layout -->' . " \n " ;
2008-09-30 02:10:49 +02:00
2011-03-09 16:06:33 +01:00
print " \n " ;
if ( $foot ) print '<!-- ' . $foot . ' -->' . " \n " ;
2011-02-16 20:59:16 +01:00
2011-10-18 16:40:44 +02:00
printCommonFooter ();
2011-02-16 20:59:16 +01:00
2012-02-22 12:02:12 +01:00
print " </body> \n " ;
print " </html> \n " ;
}
2002-05-09 16:57:48 +02:00
}
2007-01-03 01:07:57 +01:00
2011-10-29 23:42:40 +02:00
?>