diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index cf42f294d03..6fbc3e4144a 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; // Load translation files required by the page $langs->loadLangs(array("other","admin")); +$cancel = GETPOST('cancel', 'alphanohtml'); // We click on a Cancel button + if (! $user->admin) accessforbidden(); $dirstandard = array(); @@ -64,46 +66,46 @@ if (GETPOST("menu_handler")) $menu_handler=GETPOST("menu_handler"); if ($action == 'update') { - if (! $_POST['cancel']) - { - $leftmenu=''; $mainmenu=''; - if (! empty($_POST['menuIdParent']) && ! is_numeric($_POST['menuIdParent'])) - { - $tmp=explode('&', $_POST['menuIdParent']); - foreach($tmp as $s) - { - if (preg_match('/fk_mainmenu=/', $s)) - { - $mainmenu=preg_replace('/fk_mainmenu=/', '', $s); - } - if (preg_match('/fk_leftmenu=/', $s)) - { - $leftmenu=preg_replace('/fk_leftmenu=/', '', $s); - } - } - } + if (!$cancel) + { + $leftmenu=''; $mainmenu=''; + if (GETPOST('menuIdParent', 'alphanohtml') && !is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) + { + $tmp=explode('&', GETPOST('menuIdParent', 'alphanohtml')); + foreach ($tmp as $s) + { + if (preg_match('/fk_mainmenu=/', $s)) + { + $mainmenu=preg_replace('/fk_mainmenu=/', '', $s); + } + if (preg_match('/fk_leftmenu=/', $s)) + { + $leftmenu=preg_replace('/fk_leftmenu=/', '', $s); + } + } + } $menu = new Menubase($db); $result=$menu->fetch(GETPOST('menuId', 'int')); if ($result > 0) { - $menu->titre=GETPOST('titre', 'alpha'); + $menu->titre=GETPOST('titre', 'alphanohtml'); $menu->leftmenu=GETPOST('leftmenu', 'aZ09'); - $menu->url=GETPOST('url', 'alpha'); - $menu->langs=GETPOST('langs', 'alpha'); + $menu->url=GETPOST('url', 'alphanohtml'); + $menu->langs=GETPOST('langs', 'alphanohtml'); $menu->position=GETPOST('position', 'int'); - $menu->enabled=GETPOST('enabled', 'alpha'); - $menu->perms=GETPOST('perms', 'alpha'); - $menu->target=GETPOST('target', 'alpha'); - $menu->user=GETPOST('user', 'alpha'); - $menu->mainmenu=GETPOST('propertymainmenu', 'alpha'); - if (is_numeric(GETPOST('menuIdParent', 'alpha'))) + $menu->enabled=GETPOST('enabled', 'alphanohtml'); + $menu->perms=GETPOST('perms', 'alphanohtml'); + $menu->target=GETPOST('target', 'alphanohtml'); + $menu->user=GETPOST('user', 'alphanohtml'); + $menu->mainmenu=GETPOST('propertymainmenu', 'alphanohtml'); + if (is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) { - $menu->fk_menu=GETPOST('menuIdParent', 'alpha'); + $menu->fk_menu=GETPOST('menuIdParent', 'alphanohtml'); } else { - if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu=0; + if (GETPOST('type', 'alphanohtml') == 'top') $menu->fk_menu=0; else $menu->fk_menu=-1; $menu->fk_mainmenu=$mainmenu; $menu->fk_leftmenu=$leftmenu; @@ -144,9 +146,9 @@ if ($action == 'add') } $leftmenu=''; $mainmenu=''; - if (GETPOST('menuId', 'alpha', 3) && ! is_numeric(GETPOST('menuId', 'alpha', 3))) + if (GETPOST('menuId', 'alphanohtml', 3) && ! is_numeric(GETPOST('menuId', 'alphanohtml', 3))) { - $tmp=explode('&', GETPOST('menuId', 'alpha', 3)); + $tmp=explode('&', GETPOST('menuId', 'alphanohtml', 3)); foreach($tmp as $s) { if (preg_match('/fk_mainmenu=/', $s)) @@ -204,23 +206,23 @@ if ($action == 'add') { $menu = new Menubase($db); $menu->menu_handler=preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); - $menu->type=GETPOST('type', 'alpha'); - $menu->titre=GETPOST('titre', 'alpha'); - $menu->url=GETPOST('url', 'alpha'); - $menu->langs=GETPOST('langs', 'alpha'); + $menu->type=GETPOST('type', 'alphanohtml'); + $menu->titre=GETPOST('titre', 'alphanohtml'); + $menu->url=GETPOST('url', 'alphanohtml'); + $menu->langs=GETPOST('langs', 'alphanohtml'); $menu->position=GETPOST('position', 'int'); - $menu->enabled=GETPOST('enabled', 'alpha'); - $menu->perms=GETPOST('perms', 'alpha'); - $menu->target=GETPOST('target', 'alpha'); - $menu->user=GETPOST('user', 'alpha'); - $menu->mainmenu=GETPOST('propertymainmenu', 'alpha'); - if (is_numeric(GETPOST('menuId', 'alpha', 3))) + $menu->enabled=GETPOST('enabled', 'alphanohtml'); + $menu->perms=GETPOST('perms', 'alphanohtml'); + $menu->target=GETPOST('target', 'alphanohtml'); + $menu->user=GETPOST('user', 'alphanohtml'); + $menu->mainmenu=GETPOST('propertymainmenu', 'alphanohtml'); + if (is_numeric(GETPOST('menuId', 'alphanohtml', 3))) { - $menu->fk_menu=GETPOST('menuId', 'alpha', 3); + $menu->fk_menu=GETPOST('menuId', 'alphanohtml', 3); } else { - if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu=0; + if (GETPOST('type', 'alphanohtml') == 'top') $menu->fk_menu=0; else $menu->fk_menu=-1; $menu->fk_mainmenu=$mainmenu; $menu->fk_leftmenu=$leftmenu; @@ -368,7 +370,7 @@ if ($action == 'create') // Mainmenu code print '