]> git.mxchange.org Git - mailer.git/commitdiff
Category edit/delete fixed
authorRoland Häder <roland@mxchange.org>
Mon, 28 Jan 2008 20:27:32 +0000 (20:27 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 28 Jan 2008 20:27:32 +0000 (20:27 +0000)
0.2.1/inc/language/de.php
0.2.1/inc/modules/admin/what-config_cats.php
0.2.1/templates/de/html/admin/admin_edit_cats.tpl
0.2.1/templates/de/html/admin/admin_edit_cats_row.tpl

index 5e2207bd3389a817286b0c66b92ed771c7472336..cd608fc704839f66a70a39c04060a7c083a00d37 100644 (file)
@@ -1128,6 +1128,7 @@ define('UNKNOWN_LOGFILE_FORMAT_1', "Das Logbuch <u>");
 define('UNKNOWN_LOGFILE_FORMAT_2', "</u> hat ein ung&uuml;ltiges oder nicht unterst&uuml;tztes Format.");\r
 define('MESSAGE_HEADER', "Hinweis");\r
 define('ADMIN_ALPHA_SELCTION', "Alphabetische Suche:");\r
+define('CATEGORY_NOT_SAVED', "Kategorie <u>%d</u> nicht gespeichert.");
 \r
 //\r
 ?>\r
index 13480ff728f2aa5c9402adf96a793acb40bea68d..01108f7b2222f768b0052d139daab0f8553e4c66 100644 (file)
  ************************************************************************/\r
 \r
 // Some security stuff...\r
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))\r
-{\r
+if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) {\r
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";\r
        require($INC);\r
-}\r
+}
+\r
 // Add description as navigation point\r
 ADD_DESCR("admin", basename(__FILE__));\r
+
+// Init variable to avoid a notice
+$CATS = "";
 \r
 OPEN_TABLE("100%", "admin_content admin_content_align", "");\r
-if (isset($_POST['add']))\r
-{\r
+if (isset($_POST['add'])) {\r
        // Add a new category\r
        $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_cats WHERE cat='%s' LIMIT 1",\r
         array(addslashes($_POST['catname'])), __FILE__, __LINE__);\r
-       if (SQL_NUMROWS($result) == 0)\r
-       {\r
+       if (SQL_NUMROWS($result) == 0) {\r
                // Category does not exists, we simply add it...\r
                $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_cats (cat, visible, sort) VALUES ('%s', '%s', '%s')",\r
                 array(addslashes($_POST['catname']), $_POST['visible'], bigintval($_POST['parent'] + 1)), __FILE__, __LINE__);\r
                $content = "<SPAN class=\"admin_done\">".CATEGORY_ADDED."</SPAN>";\r
-       }\r
-        else\r
-       {\r
-               // Free memory\r
-               SQL_FREERESULT($result);\r
-\r
+       } else {\r
                // Category does already exists\r
                $content = "<SPAN class=\"admin_failed\">".CATEGORY_ALREADY_EXISTS."</SPAN>";\r
        }\r
+
+       // Free memory
+       SQL_FREERESULT($result);
 \r
        // Display message\r
        LOAD_TEMPLATE("admin_settings_saved", false, $content);\r
-}\r
- elseif (isset($_POST['ok']))\r
-{\r
+} elseif ((isset($_POST['ok'])) && (isset($_POST['id'])) && (is_array($_POST['id']))) {\r
        // Change or delete categories...\r
-       $TEXT = "";\r
-       foreach ($_POST['cat'] as $id=>$cat)\r
-       {\r
+       $TEXT = "";
+       foreach ($_POST['id'] as $id=>$cat) {\r
                // Secure ID\r
                $id = bigintval($id);\r
-\r
-               switch ($_GET['do'])\r
-               {\r
-               case "edit": // Change categories\r
-                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_cats SET cat='%s', visible='%s', sort='%s' WHERE id=%d LIMIT 1",\r
-                        array($cat, $_POST['vis'][$id], $_POST['sort'][$id], $id), __FILE__, __LINE__);\r
-                       $TEXT = CATEGORIES_SAVED;\r
-                       break;\r
-\r
-               case "del": // Delete categories\r
-                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_cats WHERE id=%d LIMIT 1",\r
-                        array($id), __FILE__, __LINE__);\r
-                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_cats WHERE cat_id=%d",\r
-                        array($id), __FILE__, __LINE__);\r
-                       $TEXT = CATEGORIES_DELETED;\r
-                       break;\r
+
+               // Is the entry set?
+               if (!empty($cat)) {\r
+                       switch ($_GET['do'])\r
+                       {\r
+                       case "edit": // Change categories\r
+                               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_cats SET cat='%s', visible='%s', sort=%d WHERE id=%d LIMIT 1",\r
+                                array($cat, $_POST['vis'][$id], $_POST['sort'][$id], $id), __FILE__, __LINE__);\r
+                               $TEXT = CATEGORIES_SAVED;\r
+                               break;\r
+\r
+                       case "del": // Delete categories\r
+                               $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_cats WHERE id=%d LIMIT 1",\r
+                                array($id), __FILE__, __LINE__);\r
+                               $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_cats WHERE cat_id=%d",\r
+                                array($id), __FILE__, __LINE__);\r
+                               $TEXT = CATEGORIES_DELETED;\r
+                               break;\r
+                       }
+               } else {
+                       // Entry not saved
+                       $TEXT .= sprintf(CATEGORY_NOT_SAVED, $id);
                }\r
        }\r
-       if (isset($TEXT))\r
-       {\r
+
+       if (isset($TEXT)) {\r
                // Display message\r
                LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);\r
        }\r
@@ -125,9 +127,7 @@ if (isset($_POST['add']))
 \r
        // Load main template\r
        LOAD_TEMPLATE("admin_del_cats");\r
-}\r
- elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))\r
-{\r
+} elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0])))) {\r
        // Edit categories\r
        $SW = 2; $OUT = "";\r
        foreach ($_POST['sel'] as $id=>$value)\r
index 2049f0067820cf183fa563e693e1acde439ebe9c..b9cf05ef149604c813c14b8f6e3753ee21eb2105 100644 (file)
@@ -3,7 +3,7 @@
 <TR>\r
   <TD align="center" colspan="3" height="30" class="admin_header bottom2"><STRONG>{--EDIT_CATEGORIES--}:</STRO\r
 </TR>\r
-{--__CAT_ROWS--}\r
+{!__CAT_ROWS!}\r
 <TR>\r
   <TD align="center" colspan="3" class="admin_footer">\r
     <INPUT type="reset" class="admin_reset" value="{--CLEAR_FORM--}">&nbsp;*\r
index f3774885ad03112d250702c6c570cb0e34c55501..62e653dac6ecf38328fed86cdea88ba84e557846 100644 (file)
@@ -8,7 +8,7 @@
   <TD width="49%" align="right" class="switch_sw$content[sw]">{--CAT_DESCRIPTION--}:&nbsp;</TD>\r
   <TD width="2%" class="switch_sw$content[sw] seperator">&nbsp;</TD>\r
   <TD width="49%" class="switch_sw$content[sw]">\r
-    <INPUT type="text" name="cat[$content[id]]" class="admin_normal" value="$content[cat]" size="32" maxlength="255">\r
+    <INPUT type="text" name="id[$content[id]]" class="admin_normal" value="$content[cat]" size="32" maxlength="255">\r
   </TD>\r
 </TR>\r
 <TR><TD colspan="3" height="5" class="switch_sw$content[sw] seperator">&nbsp;</TD></TR>\r
@@ -27,4 +27,4 @@
     <INPUT type="text" name="sort[$content[id]]" class="admin_normal" value="$content[sort]" size="3" maxlength="10">\r
   </TD>\r
 </TR>\r
-<TR><TD colspan="3" height="5" class="bottom2 seperatorclass="switch_sw$content[sw]"">&nbsp;</TD></TR>\r
+<TR><TD colspan="3" height="5" class="bottom2 seperato switch_sw$content[sw]">&nbsp;</TD></TR>\r