From f03930e55ebe009ba6f2eba369a1846956016798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 26 Nov 2020 23:49:42 +0100 Subject: [PATCH] doxygen --- htdocs/admin/menus/edit.php | 213 +++++++++++++++++------------------- 1 file changed, 101 insertions(+), 112 deletions(-) diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index 6181754e979..787a1af66c7 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -34,13 +34,14 @@ $langs->loadLangs(array("other", "admin")); $cancel = GETPOST('cancel', 'alphanohtml'); // We click on a Cancel button $confirm = GETPOST('confirm'); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $dirstandard = array(); $dirsmartphone = array(); $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); -foreach ($dirmenus as $dirmenu) -{ +foreach ($dirmenus as $dirmenu) { $dirstandard[] = $dirmenu.'standard'; $dirsmartphone[] = $dirmenu.'smartphone'; } @@ -56,8 +57,12 @@ $menu_handler_smartphone = preg_replace('/_frontoffice.php/i', '', $menu_handler $menu_handler = $menu_handler_top; -if (GETPOST("handler_origine")) $menu_handler = GETPOST("handler_origine"); -if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler"); +if (GETPOST("handler_origine")) { + $menu_handler = GETPOST("handler_origine"); +} +if (GETPOST("menu_handler")) { + $menu_handler = GETPOST("menu_handler"); +} @@ -65,22 +70,16 @@ if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler"); * Actions */ -if ($action == 'update') -{ - if (!$cancel) - { +if ($action == 'update') { + if (!$cancel) { $leftmenu = ''; $mainmenu = ''; - if (GETPOST('menuIdParent', 'alphanohtml') && !is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) - { + if (GETPOST('menuIdParent', 'alphanohtml') && !is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) { $tmp = explode('&', GETPOST('menuIdParent', 'alphanohtml')); - foreach ($tmp as $s) - { - if (preg_match('/fk_mainmenu=/', $s)) - { + foreach ($tmp as $s) { + if (preg_match('/fk_mainmenu=/', $s)) { $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); } - if (preg_match('/fk_leftmenu=/', $s)) - { + if (preg_match('/fk_leftmenu=/', $s)) { $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); } } @@ -88,31 +87,31 @@ if ($action == 'update') $menu = new Menubase($db); $result = $menu->fetch(GETPOST('menuId', 'int')); - if ($result > 0) - { - $menu->title = GETPOST('titre', 'alphanohtml'); - $menu->leftmenu = GETPOST('leftmenu', 'aZ09'); - $menu->url = GETPOST('url', 'alphanohtml'); - $menu->langs = GETPOST('langs', 'alphanohtml'); - $menu->position = GETPOST('position', 'int'); - $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', 'alphanohtml'); + if ($result > 0) { + $menu->title = (string) GETPOST('titre', 'alphanohtml'); + $menu->leftmenu = (string) GETPOST('leftmenu', 'aZ09'); + $menu->url = (string) GETPOST('url', 'alphanohtml'); + $menu->langs = (string) GETPOST('langs', 'alphanohtml'); + $menu->position = (int) GETPOST('position', 'int'); + $menu->enabled = (string) GETPOST('enabled', 'alphanohtml'); + $menu->perms = (string) GETPOST('perms', 'alphanohtml'); + $menu->target = (string) GETPOST('target', 'alphanohtml'); + $menu->user = (string) GETPOST('user', 'alphanohtml'); + $menu->mainmenu = (string) GETPOST('propertymainmenu', 'alphanohtml'); + if (is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) { + $menu->fk_menu = (int) GETPOST('menuIdParent', 'alphanohtml'); } else { - if (GETPOST('type', 'alphanohtml') == 'top') $menu->fk_menu = 0; - else $menu->fk_menu = -1; + if (GETPOST('type', 'alphanohtml') == 'top') { + $menu->fk_menu = 0; + } else { + $menu->fk_menu = -1; + } $menu->fk_mainmenu = $mainmenu; $menu->fk_leftmenu = $leftmenu; } $result = $menu->update($user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } else { setEventMessages($menu->error, $menu->errors, 'errors'); @@ -130,26 +129,21 @@ if ($action == 'update') } } -if ($action == 'add') -{ - if ($cancel) - { +if ($action == 'add') { + if ($cancel) { header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); exit; } - $leftmenu = ''; $mainmenu = ''; - if (GETPOST('menuId', 'alphanohtml', 3) && !is_numeric(GETPOST('menuId', 'alphanohtml', 3))) - { + $leftmenu = ''; + $mainmenu = ''; + if (GETPOST('menuId', 'alphanohtml', 3) && !is_numeric(GETPOST('menuId', 'alphanohtml', 3))) { $tmp = explode('&', GETPOST('menuId', 'alphanohtml', 3)); - foreach ($tmp as $s) - { - if (preg_match('/fk_mainmenu=/', $s)) - { + foreach ($tmp as $s) { + if (preg_match('/fk_mainmenu=/', $s)) { $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); } - if (preg_match('/fk_leftmenu=/', $s)) - { + if (preg_match('/fk_leftmenu=/', $s)) { $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); } } @@ -158,70 +152,64 @@ if ($action == 'add') $langs->load("errors"); $error = 0; - if (!$error && !$_POST['menu_handler']) - { + if (!$error && !$_POST['menu_handler']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors'); $action = 'create'; $error++; } - if (!$error && !$_POST['type']) - { + if (!$error && !$_POST['type']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); $action = 'create'; $error++; } - if (!$error && !$_POST['url']) - { + if (!$error && !$_POST['url']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); $action = 'create'; $error++; } - if (!$error && !$_POST['titre']) - { + if (!$error && !$_POST['titre']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); $action = 'create'; $error++; } - if (!$error && $_POST['menuId'] && $_POST['type'] == 'top') - { + if (!$error && $_POST['menuId'] && $_POST['type'] == 'top') { setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors'); $action = 'create'; $error++; } - if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left') - { + if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left') { setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors'); $action = 'create'; $error++; } - if (!$error) - { + if (!$error) { $menu = new Menubase($db); $menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); - $menu->type = GETPOST('type', 'alphanohtml'); - $menu->title = GETPOST('titre', 'alphanohtml'); - $menu->url = GETPOST('url', 'alphanohtml'); - $menu->langs = GETPOST('langs', 'alphanohtml'); - $menu->position = GETPOST('position', 'int'); - $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', 'alphanohtml', 3); + $menu->type = (string) GETPOST('type', 'alphanohtml'); + $menu->title = (string) GETPOST('titre', 'alphanohtml'); + $menu->url = (string) GETPOST('url', 'alphanohtml'); + $menu->langs = (string) GETPOST('langs', 'alphanohtml'); + $menu->position = (int) GETPOST('position', 'int'); + $menu->enabled = (string) GETPOST('enabled', 'alphanohtml'); + $menu->perms = (string) GETPOST('perms', 'alphanohtml'); + $menu->target = (string) GETPOST('target', 'alphanohtml'); + $menu->user = (string) GETPOST('user', 'alphanohtml'); + $menu->mainmenu = (string) GETPOST('propertymainmenu', 'alphanohtml'); + if (is_numeric(GETPOST('menuId', 'alphanohtml', 3))) { + $menu->fk_menu = (int) GETPOST('menuId', 'alphanohtml', 3); } else { - if (GETPOST('type', 'alphanohtml') == 'top') $menu->fk_menu = 0; - else $menu->fk_menu = -1; + if (GETPOST('type', 'alphanohtml') == 'top') { + $menu->fk_menu = 0; + } else { + $menu->fk_menu = -1; + } $menu->fk_mainmenu = $mainmenu; $menu->fk_leftmenu = $leftmenu; } $result = $menu->create($user); - if ($result > 0) - { + if ($result > 0) { header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler', 'aZ09')); exit; } else { @@ -232,15 +220,13 @@ if ($action == 'add') } // delete -if ($action == 'confirm_delete' && $confirm == 'yes') -{ +if ($action == 'confirm_delete' && $confirm == 'yes') { $db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int'); $result = $db->query($sql); - if ($result == 0) - { + if ($result == 0) { $db->commit(); llxHeader(); @@ -268,8 +254,7 @@ $formadmin = new FormAdmin($db); llxHeader('', $langs->trans("Menu")); -if ($action == 'create') -{ +if ($action == 'create') { print '