From ff505ba148ed48f2e9d29ed1d2d197efcdecc936 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 11:34:01 +0200 Subject: [PATCH] Work on a page dedicated for external frontend (mobile, ...) --- htdocs/core/get_info.php | 209 +++++++++++++++++++++++++++++++ htdocs/core/get_menudiv.php | 4 +- htdocs/main.inc.php | 11 +- htdocs/theme/eldy/style.css.php | 10 ++ htdocs/theme/md/style.css.php | 10 ++ htdocs/user/class/user.class.php | 14 +-- 6 files changed, 241 insertions(+), 17 deletions(-) create mode 100644 htdocs/core/get_info.php diff --git a/htdocs/core/get_info.php b/htdocs/core/get_info.php new file mode 100644 index 00000000000..7b2c57b42e3 --- /dev/null +++ b/htdocs/core/get_info.php @@ -0,0 +1,209 @@ + + * + * 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/get_info.php + * \brief File to return a single page with just logged user info, to be used by other frontend + */ + +//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', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // 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'); + + +/* + * View + */ + +$title=$langs->trans("Info"); + +// URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests +$head=''."\n"; +$arrayofjs=array(); +$arrayofcss=array(); +top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); + + + +print ''."\n"; +print '
'; +//print '
'; + +$nbofsearch=0; + +// Define link to login card +$appli=constant('DOL_APPLICATION_TITLE'); +if (! empty($conf->global->MAIN_APPLICATION_TITLE)) +{ + $appli=$conf->global->MAIN_APPLICATION_TITLE; + if (preg_match('/\d\.\d/', $appli)) + { + if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core + } + else $appli.=" ".DOL_VERSION; +} +else $appli.=" ".DOL_VERSION; + +if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $appli.="
".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL; + +$logouttext=''; +if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) +{ + //$logouthtmltext=$appli.'
'; + if ($_SESSION["dol_authmode"] != 'forceuser' && $_SESSION["dol_authmode"] != 'http') + { + $logouthtmltext.=$langs->trans("Logout").'
'; + + $logouttext .=''; + //$logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1); + $logouttext .=''; + $logouttext .=''; + } + else + { + $logouthtmltext.=$langs->trans("NoLogoutProcessWithAuthMode",$_SESSION["dol_authmode"]); + $logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1); + } +} + +print ''; + +print $toprightmenu; + +print "
\n"; // end div class="login_block" + +print ''; +print ''."\n"; + +$db->close(); diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index 3ff299fa00c..3b49482a217 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -20,7 +20,7 @@ /** * \file htdocs/core/get_menudiv.php - * \brief File to return menu into a div tree + * \brief File to return menu into a div tree, to be used by other frontend */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language @@ -37,8 +37,6 @@ if (! defined('DISABLE_JQUERY_TABLEDND')) define('DISABLE_JQUERY_TABLEDND',1); if (! defined('DISABLE_JQUERY_JNOTIFY')) define('DISABLE_JQUERY_JNOTIFY',1); if (! defined('DISABLE_JQUERY_FLOT')) define('DISABLE_JQUERY_FLOT',1); if (! defined('DISABLE_JQUERY_JEDITABLE')) define('DISABLE_JQUERY_JEDITABLE',1); -if (! defined('DISABLE_JQUERY_JEDITABLE')) define('DISABLE_JQUERY_JEDITABLE',1); -if (! defined('DISABLE_CKEDITOR')) define('DISABLE_CKEDITOR',1); if (! defined('DISABLE_CKEDITOR')) define('DISABLE_CKEDITOR',1); if (! defined('DISABLE_BROWSER_NOTIF')) define('DISABLE_BROWSER_NOTIF',1); if (! defined('DISABLE_DATE_PICKER')) define('DISABLE_DATE_PICKER',1); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c3bd5c184c0..0289fed4e14 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1116,12 +1116,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs if (empty($conf->css)) $conf->css = '/theme/eldy/style.css.php'; // If not defined, eldy by default - if (! empty($conf->global->MAIN_ACTIVATE_HTML4)) { - $doctype = ''; - }else { - $doctype = ''; - } - print $doctype."\n"; + print ''."\n"; + if (! empty($conf->global->MAIN_USE_CACHE_MANIFEST)) print ''."\n"; else print ''."\n"; //print ''."\n"; @@ -1572,7 +1568,8 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print $toprightmenu; - print "\n"; + print "\n"; // end div class="login_block" + print ''; //unset($form); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 382a37b9cc3..f3769f9d79e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1939,6 +1939,16 @@ div.login_block_other { padding-top: 3px; text-align: right; } color: # !important; font-weight: normal !important; } +.login_block_getinfo { + text-align: center; +} +.login_block_getinfo div.login_block_user { + display: block; +} +.login_block_getinfo .atoplogin, .login_block_getinfo .atoplogin:hover { + color: #333 !important; + font-weight: normal !important; +} .alogin, .alogin:hover { font-weight: normal !important; font-size: px !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ae3c08013e1..f1a276bc96d 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1201,6 +1201,16 @@ div.login_block { /* position: initial !important;*/ display: none; } +.login_block_getinfo { + text-align: center; +} +.login_block_getinfo div.login_block_user { + display: block; +} +.login_block_getinfo .atoplogin, .login_block_getinfo .atoplogin:hover { + color: #333 !important; + font-weight: normal !important; +} #id-right { padding-left: 0 ! important; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index bf9ff370e11..c70ab1acf13 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2109,7 +2109,7 @@ class User extends CommonObject * * @param int $withpictoimg Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) * @param string $option On what the link point to ('leave', 'nolink', ) - * @param integer $infologin Add complete info tooltip + * @param integer $infologin 0=Add default info tooltip, 1=Add complete info tooltip, -1=No info tooltip * @param integer $notooltip 1=Disable tooltip on picto and name * @param int $maxlen Max length of visible user name * @param int $hidethirdpartylogo Hide logo of thirdparty if user is external user @@ -2136,6 +2136,7 @@ class User extends CommonObject $label.= '
'; } + // Info Login $label.= '
'; $label.= '' . $langs->trans("User") . '
'; $label.= '' . $langs->trans('Name') . ': ' . $this->getFullName($langs,''); @@ -2144,20 +2145,18 @@ class User extends CommonObject $label.= '
' . $langs->trans("EMail").': '.$this->email; if (! empty($this->admin)) $label.= '
' . $langs->trans("Administrator").': '.yn($this->admin); - if (! empty($this->societe_id) ) // Add thirdparty for external users + if (! empty($this->socid) ) // Add thirdparty for external users { $thirdpartystatic = new Societe($db); - $thirdpartystatic->fetch($this->societe_id); + $thirdpartystatic->fetch($this->socid); if (empty($hidethirdpartylogo)) $companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink')?'nolink':'')); // picto only of company $company=' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; } - $type=($this->societe_id?$langs->trans("External").$company:$langs->trans("Internal")); + $type=($this->socid?$langs->trans("External").$company:$langs->trans("Internal")); $label.= '
' . $langs->trans("Type") . ': ' . $type; $label.= '
' . $langs->trans("Status").': '.$this->getLibStatut(0); $label.='
'; - - // Info Login - if ($infologin) + if ($infologin > 0) { $label.= '
'; $label.= '
'.$langs->trans("Connection").''; @@ -2176,6 +2175,7 @@ class User extends CommonObject if (! empty($conf->browser->phone)) $label.= '
'.$langs->trans("Phone").': '.$conf->browser->phone; if (! empty($_SESSION["disablemodules"])) $label.= '
'.$langs->trans("DisabledModules").':
'.join(', ',explode(',',$_SESSION["disablemodules"])); } + if ($infologin < 0) $label=''; $url = DOL_URL_ROOT.'/user/card.php?id='.$this->id; if ($option == 'leave') $url = DOL_URL_ROOT.'/holiday/list.php?id='.$this->id;