From c62f87380c6448c55c1a8d31a703a5426a87ef79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Feb 2013 02:41:46 +0100 Subject: [PATCH 1/6] Qual: use div instead of table --- htdocs/core/tpl/login.tpl.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 60e8f79274c..3452fbe9e86 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -190,9 +190,9 @@ if ($forgetpasslink || $helpcenterlink) { -
+
-
+ @@ -200,10 +200,9 @@ if ($forgetpasslink || $helpcenterlink) { -
-
+
-

+
From d786e8ca6e38e2d72a8b6c7c175be695cbb6c608 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Feb 2013 02:42:37 +0100 Subject: [PATCH 2/6] Code comment --- htdocs/core/class/translate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index ae4e2fd2e8f..2110b68d388 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -61,7 +61,7 @@ class Translate /** * Set accessor for this->defaultlang * - * @param string $srclang Language to use + * @param string $srclang Language to use. If '' or 'auto', we use browser lang. * @return void */ function setDefaultLang($srclang='en_US') From d31306609cdc66924190b4564b9b0d085ae227af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Feb 2013 02:47:30 +0100 Subject: [PATCH 3/6] Fix: Bad translation if error --- htdocs/main.inc.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index caec4de00ae..bb4819010ae 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -301,7 +301,7 @@ if (! empty($_SESSION["disablemodules"])) /* * Phase authentication / login -*/ + */ $login=''; if (! defined('NOLOGIN')) { @@ -384,10 +384,18 @@ if (! defined('NOLOGIN')) if ($dolibarr_main_authentication == 'forceuser' && ! empty($dolibarr_auto_user)) $goontestloop=true; if (GETPOST("username","alpha",2) || ! empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode','alpha',1)) $goontestloop=true; + $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); + if ($test && $goontestloop) { - $login = checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode); - if ($login) + $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"]; @@ -434,11 +442,6 @@ if (! defined('NOLOGIN')) 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,(! empty($mysoc)?$mysoc:'')); exit; } From d3c2d088a9c52619a0b871ddad1da9800975b380 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Feb 2013 02:55:25 +0100 Subject: [PATCH 4/6] New: Add url to get menu only. Work on progress. --- htdocs/core/getmenu_jmobile.php | 62 +++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 htdocs/core/getmenu_jmobile.php diff --git a/htdocs/core/getmenu_jmobile.php b/htdocs/core/getmenu_jmobile.php new file mode 100644 index 00000000000..f9bf587db2b --- /dev/null +++ b/htdocs/core/getmenu_jmobile.php @@ -0,0 +1,62 @@ + + * + * This file is a modified version of datepicker.php from phpBSM to fix some + * bugs, to add new features and to dramatically increase speed. + * + * 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 3 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/core/getmenu_jmobile.php + * \brief File to return menu + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); +//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); + +require_once '../main.inc.php'; + +if (GETPOST('lang')) $langs->setDefaultLang(GETPOST('lang')); // If language was forced on URL by the main.inc.php +$langs->load("main"); +$right=($langs->trans("DIRECTION")=='rtl'?'left':'right'); +$left=($langs->trans("DIRECTION")=='rtl'?'right':'left'); + +//var_dump($langs->defaultlang); +//var_dump($conf->format_date_short_java); +//var_dump($langs->trans("FormatDateShortJava")); + + + +/* + * View + */ + +// URL http://mydolibarr/core/getmenu_jmobime?mainmenu=mainmenu&leftmenu=leftmenu can be used for tests +top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + +print ''."\n"; + +print 'zzz'."\n"; + +print ''."\n"; + +?> From 50de5a944a6fba1e319ffad37175b58cce203feb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Feb 2013 03:29:03 +0100 Subject: [PATCH 5/6] Fix: compatibility with new menu manager --- htdocs/core/class/conf.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 685dfa93b9a..2ea053062b0 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -218,10 +218,10 @@ class Conf $this->bank->cheque = new stdClass(); // Clean some variables - if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD="eldy_backoffice.php"; - if (empty($this->global->MAIN_MENUFRONT_STANDARD)) $this->global->MAIN_MENUFRONT_STANDARD="eldy_frontoffice.php"; - if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE="eldy_backoffice.php"; // Use eldy by default because smartphone does not work on all phones - if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) $this->global->MAIN_MENUFRONT_SMARTPHONE="eldy_frontoffice.php"; // Ue eldy by default because smartphone does not work on all phones + if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD="eldy_menu.php"; + if (empty($this->global->MAIN_MENUFRONT_STANDARD)) $this->global->MAIN_MENUFRONT_STANDARD="eldy_menu.php"; + if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE="eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones + if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) $this->global->MAIN_MENUFRONT_SMARTPHONE="eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones // Variable globales LDAP if (empty($this->global->LDAP_FIELD_FULLNAME)) $this->global->LDAP_FIELD_FULLNAME=''; From 08bde6faa5864ef9e42ad4eb121125e52d57b6f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Feb 2013 03:45:19 +0100 Subject: [PATCH 6/6] Fix: Do not load menu when not required. --- htdocs/core/class/menubase.class.php | 8 ++-- htdocs/main.inc.php | 55 ++++++++++++++-------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 549b5b8f956..4ae86208292 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -494,7 +494,7 @@ class Menubase /** * Load entries found in database into variable $tabMenu. Note that only "database menu entries" are loaded here, hardcoded will not be present into output. * - * @param string $mymainmenu Value for left that defined mainmenu + * @param string $mymainmenu Value for mainmenu that defined mainmenu * @param string $myleftmenu Value for left that defined leftmenu * @param int $type_user Looks for menu entry for 0=Internal users, 1=External users * @param string $menu_handler Name of menu_handler used ('auguria', 'eldy'...) @@ -584,7 +584,7 @@ class Menubase } //$tmp4=dol_microtime_float(); //print '>>> 3 '.($tmp4 - $tmp3).'
'; - + // We complete tabMenu $tabMenu[$b]['rowid'] = $menu['rowid']; $tabMenu[$b]['module'] = $menu['module']; @@ -606,10 +606,10 @@ class Menubase $tabMenu[$b]['fk_mainmenu'] = $menu['fk_mainmenu']; $tabMenu[$b]['fk_leftmenu'] = $menu['fk_leftmenu']; $tabMenu[$b]['position'] = $menu['position']; - + $b++; } - + $a++; } $this->db->free($resql); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index bb4819010ae..10d67ff3a64 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -768,41 +768,42 @@ if (! empty($conf->multicompany->enabled) && GETPOST('action') == 'switchentity' } } -//print 'eee'.$conf->standard_menu; // Init menu manager -if (empty($user->societe_id)) // If internal user or not defined +if (! defined('NOREQUIREMENU')) { - $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); -} -else // If external user -{ - $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); -} - -// Load the menu manager (only if not already done) -$file_menu=empty($conf->browser->phone)?$conf->standard_menu:$conf->smart_menu; -if (GETPOST('menu')) $file_menu=GETPOST('menu'); // example: menu=eldy_menu.php -if (! class_exists('MenuManager')) -{ - $menufound=0; - $dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']); - foreach($dirmenus as $dirmenu) + if (empty($user->societe_id)) // If internal user or not defined { - $menufound=dol_include_once($dirmenu."standard/".$file_menu); - if ($menufound) break; + $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); } - if (! $menufound) // If failed to include, we try with standard + else // If external user { - dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING); - $file_menu='eldy_menu.php'; - include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu; + $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); } -} -$menumanager = new MenuManager($db, empty($user->societe_id)?0:1); + // Load the menu manager (only if not already done) + $file_menu=empty($conf->browser->phone)?$conf->standard_menu:$conf->smart_menu; + if (GETPOST('menu')) $file_menu=GETPOST('menu'); // example: menu=eldy_menu.php + 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 + { + dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING); + $file_menu='eldy_menu.php'; + include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu; + } + } + $menumanager = new MenuManager($db, empty($user->societe_id)?0:1); +}