2
0
forked from Wavyzz/dolibarr

Fix external links ko when substitution key are inside domain

This commit is contained in:
Laurent Destailleur
2018-03-24 12:46:52 +01:00
parent a3c199e9e3
commit 224fa1c03e
3 changed files with 21 additions and 6 deletions

View File

@@ -5650,8 +5650,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
}
/**
* Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newval).
* Texts like __(TranslationKey|langfile)__ and __[ConstantKey]__ are also replaced.
* Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newval),
* and texts like __(TranslationKey|langfile)__ and __[ConstantKey]__ are also replaced.
* Example of usage:
* $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $thirdparty);
* complete_substitutions_array($substitutionarray, $langs, $thirdparty);

View File

@@ -237,9 +237,16 @@ class MenuManager
{
$substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user);
$substitarray['__USERID__'] = $user->id; // For backward compatibility
$val2['url'] = make_substitutions($val2['url'], $substitarray);
$val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__
$relurl2=dol_buildpath($val2['url'],1);
if (! preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url']))
{
$relurl2=dol_buildpath($val2['url'],1);
}
else
{
$relurl2=$val2['url'];
}
$canonurl2=preg_replace('/\?.*$/','',$val2['url']);
//var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']);
if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2='';

View File

@@ -185,6 +185,7 @@ class MenuManager
$tmpleftmenu='all';
$submenu=new Menu();
print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home)
// Note: $submenu contains menu entry with substitution not yet done
//if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; }
//if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; }
$nexturl=dol_buildpath($submenu->liste[0]['url'],1);
@@ -247,9 +248,16 @@ class MenuManager
{
$substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user);
$substitarray['__USERID__'] = $user->id; // For backward compatibility
$val2['url'] = make_substitutions($val2['url'], $substitarray);
$val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__
$relurl2=dol_buildpath($val2['url'],1);
if (! preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url']))
{
$relurl2=dol_buildpath($val2['url'],1);
}
else
{
$relurl2=$val2['url'];
}
$canonurl2=preg_replace('/\?.*$/','',$val2['url']);
//var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']);
if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2='';