Move tabs of external modules at end

This commit is contained in:
Laurent Destailleur 2022-09-15 16:55:52 +02:00
parent 27f817d940
commit 6f0bf07fbe
3 changed files with 25 additions and 10 deletions

View File

@ -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');

View File

@ -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) {

View File

@ -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