From: Roland Häder Date: Mon, 28 Jan 2008 20:27:32 +0000 (+0000) Subject: Category edit/delete fixed X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1f511db7044b4232204062245de5797733fa1576;p=mailer.git Category edit/delete fixed --- diff --git a/0.2.1/inc/language/de.php b/0.2.1/inc/language/de.php index 5e2207bd33..cd608fc704 100644 --- a/0.2.1/inc/language/de.php +++ b/0.2.1/inc/language/de.php @@ -1128,6 +1128,7 @@ define('UNKNOWN_LOGFILE_FORMAT_1', "Das Logbuch "); define('UNKNOWN_LOGFILE_FORMAT_2', " hat ein ungültiges oder nicht unterstütztes Format."); define('MESSAGE_HEADER', "Hinweis"); define('ADMIN_ALPHA_SELCTION', "Alphabetische Suche:"); +define('CATEGORY_NOT_SAVED', "Kategorie %d nicht gespeichert."); // ?> diff --git a/0.2.1/inc/modules/admin/what-config_cats.php b/0.2.1/inc/modules/admin/what-config_cats.php index 13480ff728..01108f7b22 100644 --- a/0.2.1/inc/modules/admin/what-config_cats.php +++ b/0.2.1/inc/modules/admin/what-config_cats.php @@ -33,67 +33,69 @@ ************************************************************************/ // Some security stuff... -if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) -{ +if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; require($INC); -} +} + // Add description as navigation point ADD_DESCR("admin", basename(__FILE__)); + +// Init variable to avoid a notice +$CATS = ""; OPEN_TABLE("100%", "admin_content admin_content_align", ""); -if (isset($_POST['add'])) -{ +if (isset($_POST['add'])) { // Add a new category $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_cats WHERE cat='%s' LIMIT 1", array(addslashes($_POST['catname'])), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 0) - { + if (SQL_NUMROWS($result) == 0) { // Category does not exists, we simply add it... $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_cats (cat, visible, sort) VALUES ('%s', '%s', '%s')", array(addslashes($_POST['catname']), $_POST['visible'], bigintval($_POST['parent'] + 1)), __FILE__, __LINE__); $content = "".CATEGORY_ADDED.""; - } - else - { - // Free memory - SQL_FREERESULT($result); - + } else { // Category does already exists $content = "".CATEGORY_ALREADY_EXISTS.""; } + + // Free memory + SQL_FREERESULT($result); // Display message LOAD_TEMPLATE("admin_settings_saved", false, $content); -} - elseif (isset($_POST['ok'])) -{ +} elseif ((isset($_POST['ok'])) && (isset($_POST['id'])) && (is_array($_POST['id']))) { // Change or delete categories... - $TEXT = ""; - foreach ($_POST['cat'] as $id=>$cat) - { + $TEXT = ""; + foreach ($_POST['id'] as $id=>$cat) { // Secure ID $id = bigintval($id); - - switch ($_GET['do']) - { - case "edit": // Change categories - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_cats SET cat='%s', visible='%s', sort='%s' WHERE id=%d LIMIT 1", - array($cat, $_POST['vis'][$id], $_POST['sort'][$id], $id), __FILE__, __LINE__); - $TEXT = CATEGORIES_SAVED; - break; - - case "del": // Delete categories - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_cats WHERE id=%d LIMIT 1", - array($id), __FILE__, __LINE__); - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_cats WHERE cat_id=%d", - array($id), __FILE__, __LINE__); - $TEXT = CATEGORIES_DELETED; - break; + + // Is the entry set? + if (!empty($cat)) { + switch ($_GET['do']) + { + case "edit": // Change categories + $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_cats SET cat='%s', visible='%s', sort=%d WHERE id=%d LIMIT 1", + array($cat, $_POST['vis'][$id], $_POST['sort'][$id], $id), __FILE__, __LINE__); + $TEXT = CATEGORIES_SAVED; + break; + + case "del": // Delete categories + $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_cats WHERE id=%d LIMIT 1", + array($id), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_cats WHERE cat_id=%d", + array($id), __FILE__, __LINE__); + $TEXT = CATEGORIES_DELETED; + break; + } + } else { + // Entry not saved + $TEXT .= sprintf(CATEGORY_NOT_SAVED, $id); } } - if (isset($TEXT)) - { + + if (isset($TEXT)) { // Display message LOAD_TEMPLATE("admin_settings_saved", false, $TEXT); } @@ -125,9 +127,7 @@ if (isset($_POST['add'])) // Load main template LOAD_TEMPLATE("admin_del_cats"); -} - elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0])))) -{ +} elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0])))) { // Edit categories $SW = 2; $OUT = ""; foreach ($_POST['sel'] as $id=>$value) diff --git a/0.2.1/templates/de/html/admin/admin_edit_cats.tpl b/0.2.1/templates/de/html/admin/admin_edit_cats.tpl index 2049f00678..b9cf05ef14 100644 --- a/0.2.1/templates/de/html/admin/admin_edit_cats.tpl +++ b/0.2.1/templates/de/html/admin/admin_edit_cats.tpl @@ -3,7 +3,7 @@ {--EDIT_CATEGORIES--}: -{--__CAT_ROWS--} +{!__CAT_ROWS!}  * diff --git a/0.2.1/templates/de/html/admin/admin_edit_cats_row.tpl b/0.2.1/templates/de/html/admin/admin_edit_cats_row.tpl index f3774885ad..62e653dac6 100644 --- a/0.2.1/templates/de/html/admin/admin_edit_cats_row.tpl +++ b/0.2.1/templates/de/html/admin/admin_edit_cats_row.tpl @@ -8,7 +8,7 @@ {--CAT_DESCRIPTION--}:    - +   @@ -27,4 +27,4 @@ -  +