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']))) {
49 if (!isset($_POST['ok'])) {
51 $menus = array(); $titles = array(); $below = array();
53 // Get all available main menus
54 $result = SQL_QUERY("SELECT action, title, sort FROM `{!_MYSQL_PREFIX!}_member_menu` WHERE (what='' OR `what` IS NULL) ORDER BY `sort`", __FILE__, __LINE__);
55 if (SQL_NUMROWS($result) > 0) {
56 // Read menu structure
57 while (list($act, $title, $sort) = SQL_FETCHROW($result)) {
64 // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
69 SQL_FREERESULT($result);
71 // Remove double eintries
72 $prev = ""; $dmy = $menus; $dmy2 = $titles; $dmy3 = $below;
73 foreach ($menus as $key => $value) {
74 if ($value == $prev) {
85 $menus = $dmy; $titles = $dmy2; $below = $dmy3;
88 foreach ($menus as $key_main => $value_main) {
89 $result = SQL_QUERY_ESC("SELECT what, title, sort FROM `{!_MYSQL_PREFIX!}_member_menu` WHERE `action`='%s' AND `what` != '' ORDER BY `sort`",
90 array($value_main), __FILE__, __LINE__);
91 if (SQL_NUMROWS($result) > 0) {
93 $menus[$value_main] = array();
94 $titles[$value_main] = array();
95 $below[$value_main] = array();
97 // Read menu structure
98 while (list($act, $title, $sort) = SQL_FETCHROW($result)) {
100 $menus[$value_main][] = $act;
103 $titles[$value_main][] = $title;
105 // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
106 $below[$value_main][] = $sort + 1;
110 SQL_FREERESULT($result);
112 // Remove double eintries
113 $prev = ""; $dmy = $menus[$value_main]; $dmy2 = $titles[$value_main]; $dmy3 = $below[$value_main];
114 foreach ($menus[$value_main] as $key => $value) {
115 if ($value == $prev) {
123 $menus[$value_main] = $dmy; $titles[$value_main] = $dmy2; $below[$value_main] = $dmy3;
128 $OUT = "<select class=\"admin_select\" name=\"sort\" size=\"1\">
129 <option value=\"\">".IS_FIRST_MENU."</option>";
130 foreach ($below as $key => $m) {
132 foreach ($m as $key2 => $m2) {
133 $OUT .= " <option value=\"".$m2."\">".$titles[$key][$key2];
134 foreach ($menus as $k => $v) {
135 if (($v == $key) && (!is_array($v))) {
136 $OUT .= " (".$titles[$k].")";
139 $OUT .= "</option>\n";
142 $OUT .= " <option value=\"".$m."\">".$titles[$key]."</option>\n";
147 define('__BELOW_SELECTION' , $OUT);
148 define('__WHAT_SELECTION' , ADMIN_MAKE_MENU_SELECTION("member", "what", "name"));
149 define('__ACTION_SELECTION', ADMIN_MAKE_MENU_SELECTION("member", "action", "menu"));
152 LOAD_TEMPLATE("admin_member_add");
153 } elseif (!IS_DEMO()) {
154 // Insert new menu entry
155 if (!empty($_POST['menu']))
157 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s','%s')",
164 bigintval($_POST['sort']),
165 ), __FILE__, __LINE__);
167 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s')",
173 bigintval($_POST['sort']),
174 ), __FILE__, __LINE__);
176 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('SETTINGS_SAVED'));
179 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('SETTINGS_NOT_SAVED'));