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 ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
38 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
41 // Add desciption as navigation point
42 ADD_DESCR("admin", basename(__FILE__));
43 OUTPUT_HTML("</FONT><br />");
45 OPEN_TABLE("100%", "admin_content admin_content_align", "");
47 // Check if the admin has entered title and what-php file name...
48 if ((empty($_POST['title'])) && (isset($_POST['ok'])))
53 if (!isset($_POST['ok']))
56 $menus = array(); $titles = array(); $below = array();
58 // Get all available main menus
59 $result = SQL_QUERY("SELECT action, title, sort FROM "._MYSQL_PREFIX."_member_menu WHERE (what='' OR what IS NULL) ORDER BY sort", __FILE__, __LINE__);
60 if (SQL_NUMROWS($result) > 0)
62 // Read menu structure
63 while (list($act, $title, $sort) = SQL_FETCHROW($result))
71 // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
76 SQL_FREERESULT($result);
78 // Remove double eintries
79 $prev = ""; $dmy = $menus; $dmy2 = $titles; $dmy3 = $below;
80 foreach ($menus as $key=>$value)
94 $menus = $dmy; $titles = $dmy2; $below = $dmy3;
96 foreach ($menus as $key_main=>$value_main)
98 $result = SQL_QUERY_ESC("SELECT what, title, sort FROM "._MYSQL_PREFIX."_member_menu WHERE action='%s' AND what != '' ORDER BY sort",
99 array($value_main), __FILE__, __LINE__);
100 if (SQL_NUMROWS($result) > 0)
103 $menus[$value_main] = array();
104 $titles[$value_main] = array();
105 $below[$value_main] = array();
107 // Read menu structure
108 while (list($act, $title, $sort) = SQL_FETCHROW($result))
111 $menus[$value_main][] = $act;
114 $titles[$value_main][] = $title;
116 // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
117 $below[$value_main][] = $sort + 1;
121 SQL_FREERESULT($result);
123 // Remove double eintries
124 $prev = ""; $dmy = $menus[$value_main]; $dmy2 = $titles[$value_main]; $dmy3 = $below[$value_main];
125 foreach ($menus[$value_main] as $key=>$value)
138 $menus[$value_main] = $dmy; $titles[$value_main] = $dmy2; $below[$value_main] = $dmy3;
143 $OUT = "<SELECT class=\"admin_select\" name=\"sort\" size=\"1\">
144 <OPTION value=\"\">".IS_FIRST_MENU."</OPTION>";
145 foreach ($below as $key=>$m)
149 foreach ($m as $key2=>$m2)
151 $OUT .= " <OPTION value=\"".$m2."\">".$titles[$key][$key2];
152 foreach ($menus as $k=>$v)
154 if (($v == $key) && (!is_array($v)))
156 $OUT .= " (".$titles[$k].")";
159 $OUT .= "</OPTION>\n";
164 $OUT .= " <OPTION value=\"".$m."\">".$titles[$key]."</OPTION>\n";
169 define('__BELOW_SELECTION' , $OUT);
170 define('__WHAT_SELECTION' , ADMIN_MAKE_MENU_SELECTION("member", "what", "name"));
171 define('__ACTION_SELECTION', ADMIN_MAKE_MENU_SELECTION("member", "action", "menu"));
174 LOAD_TEMPLATE("admin_member_add");
178 // Insert new menu entry
179 if (!empty($_POST['menu']))
181 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_member_menu
182 (action, what, title, visible, locked, sort)
183 VALUES('%s', '%s', '%s', '%s', '%s', '%s')",
190 bigintval($_POST['sort']),
191 ), __FILE__, __LINE__);
195 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_member_menu
196 (action, title, visible, locked, sort)
197 VALUES('%s', '%s', '%s', '%s', '%s')",
203 bigintval($_POST['sort']),
204 ), __FILE__, __LINE__);
206 LOAD_TEMPLATE("admin_settings_saved", false, SAVING_DONE);
211 LOAD_TEMPLATE("admin_settings_saved", false, SETTINGS_NOT_SAVED);