forked from Wavyzz/dolibarr
NEW : customize position in complete_head_from_modules (#26406)
* NEW : customize position in complete_head_from_modules * fix parenthesis search * fix position search --------- Co-authored-by: Christophe Battarel <christophe@altairis.fr>
This commit is contained in:
committed by
GitHub
parent
80734cc945
commit
23c944a104
@@ -9894,6 +9894,21 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
|
|||||||
|
|
||||||
$reg = array();
|
$reg = array();
|
||||||
if ($mode == 'add' && !preg_match('/^\-/', $values[1])) {
|
if ($mode == 'add' && !preg_match('/^\-/', $values[1])) {
|
||||||
|
$newtab = array();
|
||||||
|
$postab = $h;
|
||||||
|
// detect if position set in $values[1] ie : +(2)mytab@mymodule (first tab is 0, second is one, ...)
|
||||||
|
$str = $values[1];
|
||||||
|
$posstart = strpos($str, '(');
|
||||||
|
if ($posstart > 0) {
|
||||||
|
$posend = strpos($str, ')');
|
||||||
|
if ($posstart > 0) {
|
||||||
|
$res1 = substr($str, $posstart + 1, $posend - $posstart -1);
|
||||||
|
if (is_numeric($res1)) {
|
||||||
|
$postab = (int) $res1;
|
||||||
|
$values[1] = '+' . substr($str, $posend + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (count($values) == 6) {
|
if (count($values) == 6) {
|
||||||
// new declaration with permissions:
|
// new declaration with permissions:
|
||||||
// $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'
|
// $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'
|
||||||
@@ -9943,9 +9958,9 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
|
$newtab[0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
|
||||||
$head[$h][1] = $label;
|
$newtab[1] = $label;
|
||||||
$head[$h][2] = str_replace('+', '', $values[1]);
|
$newtab[2] = str_replace('+', '', $values[1]);
|
||||||
$h++;
|
$h++;
|
||||||
}
|
}
|
||||||
} elseif (count($values) == 5) { // case deprecated
|
} elseif (count($values) == 5) { // case deprecated
|
||||||
@@ -9976,11 +9991,13 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
|
|||||||
$label = $langs->trans($values[2]);
|
$label = $langs->trans($values[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[4]), 1);
|
$newtab[0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[4]), 1);
|
||||||
$head[$h][1] = $label;
|
$newtab[1] = $label;
|
||||||
$head[$h][2] = str_replace('+', '', $values[1]);
|
$newtab[2] = str_replace('+', '', $values[1]);
|
||||||
$h++;
|
$h++;
|
||||||
}
|
}
|
||||||
|
// set tab at its position
|
||||||
|
$head = array_merge(array_slice($head, 0, $postab), array($newtab), array_slice($head, $postab));
|
||||||
} elseif ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
|
} elseif ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
|
||||||
if ($values[0] != $type) {
|
if ($values[0] != $type) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user