]> git.mxchange.org Git - mailer.git/blobdiff - 0.2.1/inc/modules/admin/what-config_cats.php
win32 to unix line delimiters changed
[mailer.git] / 0.2.1 / inc / modules / admin / what-config_cats.php
index 01108f7b2222f768b0052d139daab0f8553e4c66..500c095295c1bf2df9875e229afcc1d0d4388d1c 100644 (file)
-<?php\r
-/************************************************************************\r
- * MXChange v0.2.1                                    Start: 10/10/2003 *\r
- * ===============                              Last change: 07/04/2004 *\r
- *                                                                      *\r
- * -------------------------------------------------------------------- *\r
- * File              : what-config_cats.php                             *\r
- * -------------------------------------------------------------------- *\r
- * Short description : Add new categories and edit / delete existing    *\r
- * -------------------------------------------------------------------- *\r
- * Kurzbeschreibung  : Neue Kategorien hinzuf�gen und bestehende        *\r
- *                     editieren / l�schen                              *\r
- * -------------------------------------------------------------------- *\r
- *                                                                      *\r
- * -------------------------------------------------------------------- *\r
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *\r
- * For more information visit: http://www.mxchange.org                  *\r
- *                                                                      *\r
- * This program is free software; you can redistribute it and/or modify *\r
- * it under the terms of the GNU General Public License as published by *\r
- * the Free Software Foundation; either version 2 of the License, or    *\r
- * (at your option) any later version.                                  *\r
- *                                                                      *\r
- * This program is distributed in the hope that it will be useful,      *\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
- * GNU General Public License for more details.                         *\r
- *                                                                      *\r
- * You should have received a copy of the GNU General Public License    *\r
- * along with this program; if not, write to the Free Software          *\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
- * MA  02110-1301  USA                                                  *\r
- ************************************************************************/\r
-\r
-// Some security stuff...\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
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 10/10/2003 *
+ * ===============                              Last change: 07/04/2004 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : what-config_cats.php                             *
+ * -------------------------------------------------------------------- *
+ * Short description : Add new categories and edit / delete existing    *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Neue Kategorien hinzuf�gen und bestehende        *
+ *                     editieren / l�schen                              *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * For more information visit: http://www.mxchange.org                  *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
 }
 }
-\r
-// Add description as navigation point\r
-ADD_DESCR("admin", basename(__FILE__));\r
+
+// Add description as navigation point
+ADD_DESCR("admin", basename(__FILE__));
 
 // Init variable to avoid a notice
 $CATS = "";
 
 // Init variable to avoid a notice
 $CATS = "";
-\r
-OPEN_TABLE("100%", "admin_content admin_content_align", "");\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
-               // 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
-       } else {\r
-               // Category does already exists\r
-               $content = "<SPAN class=\"admin_failed\">".CATEGORY_ALREADY_EXISTS."</SPAN>";\r
-       }\r
+
+OPEN_TABLE("100%", "admin_content admin_content_align", "");
+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) {
+               // 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 = "<SPAN class=\"admin_done\">".CATEGORY_ADDED."</SPAN>";
+       } else {
+               // Category does already exists
+               $content = "<SPAN class=\"admin_failed\">".CATEGORY_ALREADY_EXISTS."</SPAN>";
+       }
 
        // Free memory
        SQL_FREERESULT($result);
 
        // Free memory
        SQL_FREERESULT($result);
-\r
-       // Display message\r
-       LOAD_TEMPLATE("admin_settings_saved", false, $content);\r
-} elseif ((isset($_POST['ok'])) && (isset($_POST['id'])) && (is_array($_POST['id']))) {\r
-       // Change or delete categories...\r
+
+       // Display message
+       LOAD_TEMPLATE("admin_settings_saved", false, $content);
+} elseif ((isset($_POST['ok'])) && (isset($_POST['id'])) && (is_array($_POST['id']))) {
+       // Change or delete categories...
        $TEXT = "";
        $TEXT = "";
-       foreach ($_POST['id'] as $id=>$cat) {\r
-               // Secure ID\r
-               $id = bigintval($id);\r
+       foreach ($_POST['id'] as $id=>$cat) {
+               // Secure ID
+               $id = bigintval($id);
 
                // Is the entry set?
 
                // 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
+               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);
                        }
                } else {
                        // Entry not saved
                        $TEXT .= sprintf(CATEGORY_NOT_SAVED, $id);
-               }\r
-       }\r
-
-       if (isset($TEXT)) {\r
-               // Display message\r
-               LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);\r
-       }\r
-}\r
- elseif ((isset($_POST['del'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))\r
-{\r
-       // Delete categories\r
-       $SW = 2; $OUT = "";\r
-       foreach ($_POST['sel'] as $id=>$value)\r
-       {\r
-               // Load data of category\r
-               $result = SQL_QUERY_ESC("SELECT cat FROM "._MYSQL_PREFIX."_cats WHERE id=%d LIMIT 1",\r
-                array(bigintval($id)), __FILE__, __LINE__);\r
-               list($cat) = SQL_FETCHROW($result);\r
-               SQL_FREERESULT($result);\r
-\r
-               // Prepare data for the row template\r
-               $content = array(\r
-                       'sw'  => $SW,\r
-                       'id'  => $id,\r
-                       'cat' => $cat,\r
-               );\r
-\r
-               // Load row template and switch colors\r
-               $OUT .= LOAD_TEMPLATE("admin_del_cats_row", true, $content);\r
-               $SW = 3 - $SW;\r
-       }\r
-       define('__CAT_ROWS', $OUT);\r
-\r
-       // Load main template\r
-       LOAD_TEMPLATE("admin_del_cats");\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
-       {\r
-               // Load data from the category\r
-               $result = SQL_QUERY_ESC("SELECT cat, visible, sort FROM "._MYSQL_PREFIX."_cats WHERE id=%d LIMIT 1",\r
-                array(bigintval($id)), __FILE__, __LINE__);\r
-               list($cat, $vis, $sort) = SQL_FETCHROW($result);\r
-               SQL_FREERESULT($result);\r
-\r
-               // Prepare data for the row template\r
-               $content = array(\r
-                       'sw'   => $SW,\r
-                       'id'   => $id,\r
-                       'cat'  => $cat,\r
-                       'vis'  => ADD_SELECTION("yn", $vis, "vis", $id),\r
-                       'sort' => $sort,\r
-               );\r
-\r
-               // Load row template and switch colors\r
-               $OUT .= LOAD_TEMPLATE("admin_edit_cats_row", true, $content);\r
-               $SW = 3 - $SW;\r
-       }\r
-       define('__CAT_ROWS', $OUT);\r
-\r
-       // Load main template\r
-       LOAD_TEMPLATE("admin_edit_cats");\r
-}\r
- else\r
-{\r
-       // Load all categories\r
-       $result = SQL_QUERY("SELECT id, cat, visible, sort FROM "._MYSQL_PREFIX."_cats ORDER BY sort", __FILE__, __LINE__);\r
-       if (SQL_NUMROWS($result) > 0)\r
-       {\r
-               // List already existing categories for editing\r
-               $SW = 2; $OUT = ""; $CATS = "";\r
-               while (list($id, $cat, $visible, $sort) = SQL_FETCHROW($result))\r
-               {\r
-                       // Prepare data for the row template\r
-                       $content = array(\r
-                               'sw'   => $SW,\r
-                               'id'   => $id,\r
-                               'cat'  => $cat,\r
-                               'vis'  => TRANSLATE_YESNO($visible),\r
-                               'sort' => $sort,\r
-                       );\r
-\r
-                       // Put cat descriptions into variable for the selection box\r
-                       if (strlen($cat) > 20) $cat = substr($cat, 0, 17)."...";\r
-                       $CATS .= "      <OPTION value=\"".$sort."\">".$cat."</OPTION>\n";\r
-\r
-                       // Load row template and switch color\r
-                       $OUT .= LOAD_TEMPLATE("admin_config_cats_row", true, $content);\r
-                       $SW = 3 - $SW;\r
-               }\r
-\r
-               // Free memory\r
-               SQL_FREERESULT($result);\r
-               define('__CAT_ROWS', $OUT);\r
-\r
-               // Load main template\r
-               LOAD_TEMPLATE("admin_config_cats");\r
-       }\r
-\r
-       define('CATS', $CATS);\r
-\r
-       // Form to add a new category\r
-       LOAD_TEMPLATE("admin_add_cat");\r
-}\r
-CLOSE_TABLE();\r
-//\r
-?>\r
+               }
+       }
+
+       if (isset($TEXT)) {
+               // Display message
+               LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);
+       }
+}
+ elseif ((isset($_POST['del'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))
+{
+       // Delete categories
+       $SW = 2; $OUT = "";
+       foreach ($_POST['sel'] as $id=>$value)
+       {
+               // Load data of category
+               $result = SQL_QUERY_ESC("SELECT cat FROM "._MYSQL_PREFIX."_cats WHERE id=%d LIMIT 1",
+                array(bigintval($id)), __FILE__, __LINE__);
+               list($cat) = SQL_FETCHROW($result);
+               SQL_FREERESULT($result);
+
+               // Prepare data for the row template
+               $content = array(
+                       'sw'  => $SW,
+                       'id'  => $id,
+                       'cat' => $cat,
+               );
+
+               // Load row template and switch colors
+               $OUT .= LOAD_TEMPLATE("admin_del_cats_row", true, $content);
+               $SW = 3 - $SW;
+       }
+       define('__CAT_ROWS', $OUT);
+
+       // Load main template
+       LOAD_TEMPLATE("admin_del_cats");
+} elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0])))) {
+       // Edit categories
+       $SW = 2; $OUT = "";
+       foreach ($_POST['sel'] as $id=>$value)
+       {
+               // Load data from the category
+               $result = SQL_QUERY_ESC("SELECT cat, visible, sort FROM "._MYSQL_PREFIX."_cats WHERE id=%d LIMIT 1",
+                array(bigintval($id)), __FILE__, __LINE__);
+               list($cat, $vis, $sort) = SQL_FETCHROW($result);
+               SQL_FREERESULT($result);
+
+               // Prepare data for the row template
+               $content = array(
+                       'sw'   => $SW,
+                       'id'   => $id,
+                       'cat'  => $cat,
+                       'vis'  => ADD_SELECTION("yn", $vis, "vis", $id),
+                       'sort' => $sort,
+               );
+
+               // Load row template and switch colors
+               $OUT .= LOAD_TEMPLATE("admin_edit_cats_row", true, $content);
+               $SW = 3 - $SW;
+       }
+       define('__CAT_ROWS', $OUT);
+
+       // Load main template
+       LOAD_TEMPLATE("admin_edit_cats");
+}
+ else
+{
+       // Load all categories
+       $result = SQL_QUERY("SELECT id, cat, visible, sort FROM "._MYSQL_PREFIX."_cats ORDER BY sort", __FILE__, __LINE__);
+       if (SQL_NUMROWS($result) > 0)
+       {
+               // List already existing categories for editing
+               $SW = 2; $OUT = ""; $CATS = "";
+               while (list($id, $cat, $visible, $sort) = SQL_FETCHROW($result))
+               {
+                       // Prepare data for the row template
+                       $content = array(
+                               'sw'   => $SW,
+                               'id'   => $id,
+                               'cat'  => $cat,
+                               'vis'  => TRANSLATE_YESNO($visible),
+                               'sort' => $sort,
+                       );
+
+                       // Put cat descriptions into variable for the selection box
+                       if (strlen($cat) > 20) $cat = substr($cat, 0, 17)."...";
+                       $CATS .= "      <OPTION value=\"".$sort."\">".$cat."</OPTION>\n";
+
+                       // Load row template and switch color
+                       $OUT .= LOAD_TEMPLATE("admin_config_cats_row", true, $content);
+                       $SW = 3 - $SW;
+               }
+
+               // Free memory
+               SQL_FREERESULT($result);
+               define('__CAT_ROWS', $OUT);
+
+               // Load main template
+               LOAD_TEMPLATE("admin_config_cats");
+       }
+
+       define('CATS', $CATS);
+
+       // Form to add a new category
+       LOAD_TEMPLATE("admin_add_cat");
+}
+CLOSE_TABLE();
+//
+?>