2 /************************************************************************
3 * MXChange v0.2.1 Start: 09/28/2003 *
4 * =============== Last change: 12/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-mem_add.php *
8 * -------------------------------------------------------------------- *
9 * Short desciption : Add new menu for your members *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Fuegen Sie einen weiteren Menuepunkt zum Mit- *
12 * Mitgliedsmenue hinzu *
13 * -------------------------------------------------------------------- *
15 * -------------------------------------------------------------------- *
16 * Copyright (c) 2003 - 2008 by Roland Haeder *
17 * For more information visit: http://www.mxchange.org *
19 * This program is free software; you can redistribute it and/or modify *
20 * it under the terms of the GNU General Public License as published by *
21 * the Free Software Foundation; either version 2 of the License, or *
22 * (at your option) any later version. *
24 * This program is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU General Public License for more details. *
29 * You should have received a copy of the GNU General Public License *
30 * along with this program; if not, write to the Free Software *
31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
33 ************************************************************************/
35 // Some security stuff...
36 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
41 // Add desciption as navigation point
42 ADD_DESCR("admin", __FILE__);
44 // Check if the admin has entered title and what-php file name...
45 if ((empty($_POST['title'])) && (isset($_POST['ok'])))
50 if (!isset($_POST['ok']))
53 $menus = array(); $titles = array(); $below = array();
55 // Get all available main menus
56 $result = SQL_QUERY("SELECT action, title, sort FROM "._MYSQL_PREFIX."_member_menu WHERE (what='' OR what IS NULL) ORDER BY sort", __FILE__, __LINE__);
57 if (SQL_NUMROWS($result) > 0)
59 // Read menu structure
60 while (list($act, $title, $sort) = SQL_FETCHROW($result))
68 // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
73 SQL_FREERESULT($result);
75 // Remove double eintries
76 $prev = ""; $dmy = $menus; $dmy2 = $titles; $dmy3 = $below;
77 foreach ($menus as $key => $value)
91 $menus = $dmy; $titles = $dmy2; $below = $dmy3;
93 foreach ($menus as $key_main => $value_main)
95 $result = SQL_QUERY_ESC("SELECT what, title, sort FROM "._MYSQL_PREFIX."_member_menu WHERE action='%s' AND what != '' ORDER BY sort",
96 array($value_main), __FILE__, __LINE__);
97 if (SQL_NUMROWS($result) > 0)
100 $menus[$value_main] = array();
101 $titles[$value_main] = array();
102 $below[$value_main] = array();
104 // Read menu structure
105 while (list($act, $title, $sort) = SQL_FETCHROW($result))
108 $menus[$value_main][] = $act;
111 $titles[$value_main][] = $title;
113 // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
114 $below[$value_main][] = $sort + 1;
118 SQL_FREERESULT($result);
120 // Remove double eintries
121 $prev = ""; $dmy = $menus[$value_main]; $dmy2 = $titles[$value_main]; $dmy3 = $below[$value_main];
122 foreach ($menus[$value_main] as $key => $value)
135 $menus[$value_main] = $dmy; $titles[$value_main] = $dmy2; $below[$value_main] = $dmy3;
140 $OUT = "<SELECT class=\"admin_select\" name=\"sort\" size=\"1\">
141 <OPTION value=\"\">".IS_FIRST_MENU."</OPTION>";
142 foreach ($below as $key => $m)
146 foreach ($m as $key2 => $m2)
148 $OUT .= " <OPTION value=\"".$m2."\">".$titles[$key][$key2];
149 foreach ($menus as $k => $v)
151 if (($v == $key) && (!is_array($v)))
153 $OUT .= " (".$titles[$k].")";
156 $OUT .= "</OPTION>\n";
161 $OUT .= " <OPTION value=\"".$m."\">".$titles[$key]."</OPTION>\n";
166 define('__BELOW_SELECTION' , $OUT);
167 define('__WHAT_SELECTION' , ADMIN_MAKE_MENU_SELECTION("member", "what", "name"));
168 define('__ACTION_SELECTION', ADMIN_MAKE_MENU_SELECTION("member", "action", "menu"));
171 LOAD_TEMPLATE("admin_member_add");
175 // Insert new menu entry
176 if (!empty($_POST['menu']))
178 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_member_menu (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s','%s')",
185 bigintval($_POST['sort']),
186 ), __FILE__, __LINE__);
190 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_member_menu (`action`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s')",
196 bigintval($_POST['sort']),
197 ), __FILE__, __LINE__);
199 LOAD_TEMPLATE("admin_settings_saved", false, SAVING_DONE);
204 LOAD_TEMPLATE("admin_settings_saved", false, SETTINGS_NOT_SAVED);