From 6f0bf07fbe56e45faf37afc58402fa6b1a5ea849 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Sep 2022 16:55:52 +0200 Subject: [PATCH] Move tabs of external modules at end --- htdocs/core/lib/company.lib.php | 12 ++++++------ htdocs/core/lib/functions.lib.php | 19 +++++++++++++++++-- htdocs/core/modules/modTicket.class.php | 4 ++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index b4ae935677b..288f3e236ac 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -281,7 +281,7 @@ function societe_prepare_head(Societe $object) // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty', 'add', 'core'); if ($user->socid == 0) { // Notifications @@ -392,11 +392,11 @@ function societe_prepare_head(Societe $object) $head[$h][2] = 'agenda'; $h++; - // Log - /*$head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Info"); - $head[$h][2] = 'info'; - $h++;*/ + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty', 'add', 'external'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty', 'remove'); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a3c538954dc..0009ba93240 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9042,9 +9042,10 @@ function getLanguageCodeFromCountryCode($countrycode) * 'ecm' to add a tab for another ecm view * 'stock' to add a tab for warehouse view * @param string $mode 'add' to complete head, 'remove' to remove entries + * @param string $filterorigmodule Filter on module origin. 'external' will show only external modules. 'core' only core modules. No filter by default. * @return void */ -function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode = 'add') +function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode = 'add', $filterorigmodule = '') { global $hookmanager, $db; @@ -9064,15 +9065,29 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, if (verifCond($values[4])) { if ($values[3]) { + if ($filterorigmodule) { // If a filter of module origin has been requested + if (strpos($values[3], '@')) { // This is an external module + if ($filterorigmodule != 'external') { + continue; + } + } else { // This looks a core module + if ($filterorigmodule != 'core') { + continue; + } + } + } $langs->load($values[3]); } if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) { + // If label is "SUBSTITUION_..." $substitutionarray = array(); complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey'=>$values[2])); $label = make_substitutions($reg[1], $substitutionarray); } else { + // If label is "Label,Class,File,Method", we call the method to show content inside the badge $labeltemp = explode(',', $values[2]); $label = $langs->trans($labeltemp[0]); + if (!empty($labeltemp[1]) && is_object($object) && !empty($object->id)) { dol_include_once($labeltemp[2]); $classtoload = $labeltemp[1]; @@ -9092,7 +9107,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $head[$h][2] = str_replace('+', '', $values[1]); $h++; } - } elseif (count($values) == 5) { // deprecated + } elseif (count($values) == 5) { // case deprecated dol_syslog('Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING); if ($values[0] != $type) { diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 13967fc4096..22e2bed3ee9 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -122,8 +122,8 @@ class modTicket extends DolibarrModules $this->tabs = array( - 'thirdparty:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?socid=__ID__', - 'project:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?projectid=__ID__', + 'thirdparty:+ticket:Tickets:ticket:$user->rights->ticket->read:/ticket/list.php?socid=__ID__', + 'project:+ticket:Tickets:ticket:$user->rights->ticket->read:/ticket/list.php?projectid=__ID__', ); // Dictionaries