X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-admin_add.php;h=fe314901936ed66a2e4a11b1f069094dcb9fd4d5;hp=acc0bb2f8277d1d9669dc4e970d226e62050bd7a;hb=4001187f22197f55e5a1f211fc8defcc180f7c32;hpb=08b3c51b70b6498fd92a2760979d64470ad1b586 diff --git a/inc/modules/admin/what-admin_add.php b/inc/modules/admin/what-admin_add.php index acc0bb2f82..fe31490193 100644 --- a/inc/modules/admin/what-admin_add.php +++ b/inc/modules/admin/what-admin_add.php @@ -41,36 +41,35 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) { ADD_DESCR("admin", __FILE__); // Check if the admin has entered title and what-php file name... -if (((empty($_POST['title'])) || (empty($_POST['menu'])) || (empty($_POST['descr']))) && (isset($_POST['ok']))) { - unset($_POST['ok']); +if (((!REQUEST_ISSET_POST(('title'))) || (!REQUEST_ISSET_POST(('menu'))) || (!REQUEST_ISSET_POST(('descr')))) && (IS_FORM_SENT())) { + REQUEST_UNSET_POST('ok'); } -if (!isset($_POST['ok'])) +if (!IS_FORM_SENT()) { // Create arrays $menus = array(); $titles = array(); $below = array(); // Get all available main menus $result = SQL_QUERY("SELECT action, title, sort FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE (what='' OR `what` IS NULL) ORDER BY `sort`", __FILE__, __LINE__); - if (SQL_NUMROWS($result) > 0) - { + if (SQL_NUMROWS($result) > 0) { // Read menu structure - while (list($act, $title, $sort) = SQL_FETCHROW($result)) - { + while ($content = SQL_FETCHARRAY($result)) { // Menu actions - $menus[] = $act; + $menus[] = $content['action']; // Menu titles - $titles[] = $title; + $titles[] = $content['title']; // Below this menu point should the new be added so we simply increase the sort value by 1 :-) - $below[] = $sort + 1; - } + $below[] = $content['sort'] + 1; + } // END - while // Free memory SQL_FREERESULT($result); // Remove double eintries + // @TODO This can be somehow rewritten to a function $prev = ""; $dmy = $menus; $dmy2 = $titles; $dmy3 = $below; foreach ($menus as $key => $value) { @@ -87,47 +86,45 @@ if (!isset($_POST['ok'])) } $menus = $dmy; $titles = $dmy2; $below = $dmy3; // Load sub menus :) - foreach ($menus as $key_main => $value_main) - { + foreach ($menus as $key_main => $value_main) { $result = SQL_QUERY_ESC("SELECT what, title, sort FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort`", - array($value_main), __FILE__, __LINE__); - if (SQL_NUMROWS($result) > 0) - { + array($value_main), __FILE__, __LINE__); + if (SQL_NUMROWS($result) > 0) { + // Init arrays $menus[$value_main] = array(); $titles[$value_main] = array(); $below[$value_main] = array(); + // Read menu structure - while (list($act, $title, $sort) = SQL_FETCHROW($result)) - { + while ($content = SQL_FETCHROW($result)) { // Menu actions - $menus[$value_main][] = $act; + $menus[$value_main][] = $content['action']; // Menu titles - $titles[$value_main][] = $title; + $titles[$value_main][] = $content['title']; // Below this menu point should the new be added so we simply increase the sort value by 1 :-) - $below[$value_main][] = $sort + 1; - } + $below[$value_main][] = $content['sort'] + 1; + } // END - while // Free memory SQL_FREERESULT($result); // Remove double eintries + // @TODO This can be somehow rewritten to a function $prev = ""; $dmy = $menus[$value_main]; $dmy2 = $titles[$value_main]; $dmy3 = $below[$value_main]; - foreach ($menus[$value_main] as $key => $value) - { - if ($value == $prev) - { + foreach ($menus[$value_main] as $key => $value) { + if ($value == $prev) { unset($dmy[$key]); unset($dmy2[$key]); unset($dmy3[$key]); - } - else - { + } else { $prev = $value; } } - $menus[$value_main] = $dmy; $titles[$value_main] = $dmy2; $below[$value_main] = $dmy3; + $menus[$value_main] = $dmy; + $titles[$value_main] = $dmy2; + $below[$value_main] = $dmy3; } } } @@ -163,41 +160,34 @@ if (!isset($_POST['ok'])) // Display form LOAD_TEMPLATE("admin_admin_add"); -} - elseif (!IS_DEMO()) -{ +} elseif (!IS_DEMO()) { // Insert new menu entry - if (!empty($_POST['menu'])) - { + if (REQUEST_ISSET_POST(('menu'))) { // Add sub menu SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('%s','%s','%s','%s','%s')", array( - $_POST['menu'], - $_POST['name'], - $_POST['title'], - $_POST['descr'], - bigintval($_POST['sort']), + REQUEST_POST('menu'), + REQUEST_POST('name'), + REQUEST_POST('title'), + REQUEST_POST('descr'), + bigintval(REQUEST_POST('sort')), ), __FILE__, __LINE__ ); - CACHE_PURGE_ADMIN_MENU(0, $_POST['menu'], $_POST['name']); - } - else - { + CACHE_PURGE_ADMIN_MENU(0, REQUEST_POST('menu'), REQUEST_POST('name')); + } else { // Add main menu SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (action, title, descr, sort) VALUES ('%s','%s','%s','%s')", array( - $_POST['name'], - $_POST['title'], - $_POST['descr'], - bigintval($_POST['sort']), + REQUEST_POST('name'), + REQUEST_POST('title'), + REQUEST_POST('descr'), + bigintval(REQUEST_POST('sort')), ), __FILE__, __LINE__ ); - CACHE_PURGE_ADMIN_MENU(0, $_POST['name']); + CACHE_PURGE_ADMIN_MENU(0, REQUEST_POST('name')); } LOAD_TEMPLATE("admin_settings_saved", false, getMessage('SETTINGS_SAVED')); -} - else -{ +} else { // Is demo login! LOAD_TEMPLATE("admin_settings_saved", false, getMessage('SETTINGS_NOT_SAVED')); }