From 3d2dc3c66e1e8105355b77073449f09e0efff7ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 26 Jul 2016 21:12:52 +0200 Subject: [PATCH] NEW Each user can select its landing page. --- htdocs/core/lib/functions.lib.php | 6 +-- htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/core/menus/standard/eldy.lib.php | 4 +- htdocs/hrm/{hrm.php => index.php} | 2 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/user/param_ihm.php | 62 +++++++++++++++++++++++-- 6 files changed, 67 insertions(+), 10 deletions(-) rename htdocs/hrm/{hrm.php => index.php} (99%) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1549a2603b6..5e44d9768ad 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2668,10 +2668,10 @@ function img_searchclear($titlealt = 'default', $other = '') * @param string $text Text info * @param integer $infoonimgalt Info is shown only on alt of star picto, otherwise it is show on output after the star picto * @param int $nodiv No div - * @param int $admin 1=Info for admin users. 0=Info for standard users (change only the look) + * @param string $admin '1'=Info for admin users. '0'=Info for standard users (change only the look), 'xxx'=Other * @return string String with info text */ -function info_admin($text, $infoonimgalt = 0, $nodiv=0, $admin=1) +function info_admin($text, $infoonimgalt = 0, $nodiv=0, $admin='1') { global $conf, $langs; @@ -2680,7 +2680,7 @@ function info_admin($text, $infoonimgalt = 0, $nodiv=0, $admin=1) return img_picto($text, 'info', 'class="hideonsmartphone"'); } - return ($nodiv?'':'<div class="'.($admin?'info':'').' hideonsmartphone">').img_picto($admin?$langs->trans('InfoAdmin'):$langs->trans('Note'), ($nodiv?'info':'info_black'), 'class="hideonsmartphone"').' '.$text.($nodiv?'':'</div>'); + return ($nodiv?'':'<div class="'.(empty($admin)?'':($admin=='1'?'info':$admin)).' hideonsmartphone">').img_picto($admin?$langs->trans('InfoAdmin'):$langs->trans('Note'), ($nodiv?'info':'info_black'), 'class="hideonsmartphone"').' '.$text.($nodiv?'':'</div>'); } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 39a8241b465..e27ca3e596a 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -17,7 +17,7 @@ insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, left insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('projet', '$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 70, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('mailing|export|import|opensurvey', '$conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled || $conf->opensurvey->enabled', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '$user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run || $user->rights->opensurvey->read', '', 2, 90, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('adherent', '$conf->adherent->enabled', 13__+MAX_llx_menu__, __HANDLER__, 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&leftmenu=', 'Members', -1, 'members', '$user->rights->adherent->lire', '', 2, 110, __ENTITY__); -insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm|holiday|deplacement|expensereport', '$conf->hrm->enabled || $conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/hrm/hrm.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->hrm->employee->read || $user->rights->holiday->write || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__); +insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm|holiday|deplacement|expensereport', '$conf->hrm->enabled || $conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/hrm/index.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->hrm->employee->read || $user->rights->holiday->write || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__); -- Home - Dashboard insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'Dashboard', 0, '', '', '', 2, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 41a556c6a30..a3f9c04a666 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -237,9 +237,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $idsel='hrm'; if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("HRM"), $showmode, DOL_URL_ROOT.'/hrm/hrm.php?mainmenu=hrm&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_text_menu_entry($langs->trans("HRM"), $showmode, DOL_URL_ROOT.'/hrm/index.php?mainmenu=hrm&leftmenu=', $id, $idsel, $classname, $atarget); if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/hrm/hrm.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", ''); + $menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", ''); } diff --git a/htdocs/hrm/hrm.php b/htdocs/hrm/index.php similarity index 99% rename from htdocs/hrm/hrm.php rename to htdocs/hrm/index.php index cc2366d7e4c..9f1ecaa6c5d 100644 --- a/htdocs/hrm/hrm.php +++ b/htdocs/hrm/index.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/hrm/hrm.php + * \file htdocs/hrm/index.php * \ingroup hrm * \brief Home page for HRM area. */ diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c8e5549ce3f..48de4bda8fc 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1603,3 +1603,4 @@ UrlToGetKeyToUseAPIs=Url to get token to use API (once token has been received i ListOfAvailableAPIs=List of available APIs activateModuleDependNotSatisfied=Module "%s" depends on module "%s" that is missing, so module "%1$s" may not work correclty. Please install module "%2$s" or disable module "%1$s" if you want to be safe from any surprise CommandIsNotInsideAllowedCommands=The command you try to run is not inside list of allowed commands defined into parameter <strong>$dolibarr_main_restrict_os_commands</strong> into <strong>conf.php</strong> file. +LandingPage=Landing page \ No newline at end of file diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 4d254349a7d..f0ca0f17c31 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -32,6 +32,8 @@ $langs->load("products"); $langs->load("admin"); $langs->load("users"); $langs->load("languages"); +$langs->load("projects"); +$langs->load("members"); // Defini si peux lire/modifier permisssions $canreaduser=($user->admin || $user->rights->user->user->lire); @@ -91,6 +93,12 @@ if (empty($reshook)) { if (!$_POST["cancel"]) { $tabparam = array(); + if (GETPOST("check_MAIN_LANDING_PAGE") == "on") { + $tabparam["MAIN_LANDING_PAGE"] = $_POST["MAIN_LANDING_PAGE"]; + } else { + $tabparam["MAIN_LANDING_PAGE"] = ''; + } + if (GETPOST("check_MAIN_LANG_DEFAULT") == "on") { $tabparam["MAIN_LANG_DEFAULT"] = $_POST["main_lang_default"]; } else { @@ -145,6 +153,17 @@ if (empty($reshook)) { llxHeader(); +// List of possible landing pages +$tmparray=array('index.php'=>'Dashboard'); +if (! empty($conf->societe->enabled)) $tmparray['societe/index.php?mainmenu=companies&leftmenu=']='ThirdPartiesArea'; +if (! empty($conf->projet->enabled)) $tmparray['projet/index.php?mainmenu=project&leftmenu=']='ProjectsArea'; +if (! empty($conf->holiday->enabled) || ! empty($conf->expensereport->enabled)) $tmparray['hrm/index.php?mainmenu=hrm&leftmenu=']='HRMArea'; // TODO Complete list with first level of menus +if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) $tmparray['product/index.php?mainmenu=products&leftmenu=']='ProductsAndServicesArea'; +if (! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) || ! empty($conf->fichinter->enabled) || ! empty($conf->contrat->enabled)) $tmparray['comm/index.php?mainmenu=commercial&leftmenu=']='CommercialArea'; +if (! empty($conf->compta->enabled) || ! empty($conf->accounting->enabled)) $tmparray['compta/index.php?mainmenu=compta&leftmenu=']='AccountancyTreasuryArea'; +if (! empty($conf->adherent->enabled)) $tmparray['adherents/index.php?mainmenu=members&leftmenu=']='MembersArea'; +if (! empty($conf->agenda->enabled)) $tmparray['comm/action/index.php?mainmenu=agenda&leftmenu=']='Agenda'; + $head = user_prepare_head($object); $title = $langs->trans("User"); @@ -186,7 +205,10 @@ if ($action == 'edit') jQuery(document).ready(function() { function init_myfunc() { - if (jQuery("#check_MAIN_LANG_DEFAULT").prop("checked")) { jQuery("#main_lang_default").removeAttr(\'disabled\'); } + if (jQuery("#check_MAIN_LANDING_PAGE").prop("checked")) { jQuery("#MAIN_LANDING_PAGE").removeAttr(\'disabled\'); } + else { jQuery("#MAIN_LANDING_PAGE").attr(\'disabled\',\'disabled\'); } + + if (jQuery("#check_MAIN_LANG_DEFAULT").prop("checked")) { jQuery("#main_lang_default").removeAttr(\'disabled\'); } else { jQuery("#main_lang_default").attr(\'disabled\',\'disabled\'); } if (jQuery("#check_SIZE_LISTE_LIMIT").prop("checked")) { jQuery("#main_size_liste_limit").removeAttr(\'disabled\'); } @@ -199,7 +221,8 @@ if ($action == 'edit') else { jQuery("#colorpickerTHEME_ELDY_TOPMENU_BACK1").attr(\'disabled\',\'disabled\'); } } init_myfunc(); - jQuery("#check_SIZE_LISTE_LIMIT").click(function() { init_myfunc(); }); + jQuery("#check_MAIN_LANDING_PAGE").click(function() { init_myfunc(); }); + jQuery("#check_SIZE_LISTE_LIMIT").click(function() { init_myfunc(); }); jQuery("#check_MAIN_LANG_DEFAULT").click(function() { init_myfunc(); }); jQuery("#check_MAIN_THEME").click(function() { init_myfunc(); }); jQuery("#check_THEME_ELDY_TOPMENU_BACK1").click(function() { init_myfunc(); }); @@ -215,6 +238,20 @@ if ($action == 'edit') print '<table class="noborder" width="100%">'; print '<tr class="liste_titre"><td width="25%">'.$langs->trans("Parameter").'</td><td width="25%">'.$langs->trans("DefaultValue").'</td><td> </td><td>'.$langs->trans("PersonalValue").'</td></tr>'; + // Landing page + $var=!$var; + print '<tr '.$bc[$var].'><td>'.$langs->trans("LandingPage").'</td>'; + print '<td>'; + print (empty($conf->global->MAIN_LANDING_PAGE)?'':$conf->global->MAIN_LANDING_PAGE); + print '</td>'; + print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_MAIN_LANDING_PAGE" id="check_MAIN_LANDING_PAGE" type="checkbox" '.(! empty($object->conf->MAIN_LANDING_PAGE)?" checked":""); + print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo + print '> '.$langs->trans("UsePersonalValue").'</td>'; + print '<td>'; + print $form->selectarray('MAIN_LANDING_PAGE', $tmparray, (! empty($object->conf->MAIN_LANDING_PAGE)?$object->conf->MAIN_LANDING_PAGE:''), 0, 0, 0, '', 1); + //print info_admin($langs->trans("WarningYouMayLooseAccess"), 0, 0, 0); + print '</td></tr>'; + // Langue par defaut $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("Language").'</td>'; @@ -267,6 +304,25 @@ else print '<table class="noborder" width="100%">'; print '<tr class="liste_titre"><td width="25%">'.$langs->trans("Parameter").'</td><td width="25%">'.$langs->trans("DefaultValue").'</td><td> </td><td>'.$langs->trans("PersonalValue").'</td></tr>'; + // Landing page + $var=!$var; + print '<tr '.$bc[$var].'><td>'.$langs->trans("LandingPage").'</td>'; + print '<td>'; + print (empty($conf->global->MAIN_LANDING_PAGE)?'':$conf->global->MAIN_LANDING_PAGE); + print '</td>'; + print '<td align="left" class="nowrap"><input '.$bc[$var].' name="check_MAIN_LANDING_PAGE" disabled id="check_MAIN_LANDING_PAGE" type="checkbox" '.(! empty($object->conf->MAIN_LANDING_PAGE)?" checked":""); + print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo + print '> '.$langs->trans("UsePersonalValue").'</td>'; + print '<td>'; + if (! empty($tmparray[$object->conf->MAIN_LANDING_PAGE])) + { + print $langs->trans($tmparray[$object->conf->MAIN_LANDING_PAGE]); + } + else print $object->conf->MAIN_LANDING_PAGE; + //print $form->selectarray('MAIN_LANDING_PAGE', $tmparray, (! empty($object->conf->MAIN_LANDING_PAGE)?$object->conf->MAIN_LANDING_PAGE:''), 0, 0, 0, '', 1); + print '</td></tr>'; + + // Language $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("Language").'</td>'; print '<td>'; @@ -274,7 +330,7 @@ else print ($s?$s.' ':''); print (isset($conf->global->MAIN_LANG_DEFAULT) && $conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT)); print '</td>'; - print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' type="checkbox" disabled '.(! empty($object->conf->MAIN_LANG_DEFAULT)?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>'; + print '<td align="left" class="nowrap"><input '.$bc[$var].' type="checkbox" disabled '.(! empty($object->conf->MAIN_LANG_DEFAULT)?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>'; print '<td>'; $s=(isset($object->conf->MAIN_LANG_DEFAULT) ? picto_from_langcode($object->conf->MAIN_LANG_DEFAULT) : ''); print ($s?$s.' ':''); -- GitLab