2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 * -------------------------------------------------------------------- *
16 * $Tag:: 0.2.1-FINAL $ *
18 * -------------------------------------------------------------------- *
19 * Copyright (c) 2003 - 2009 by Roland Haeder *
20 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
44 // Add desciption as navigation point
45 addYouAreHereLink('admin', __FILE__);
47 // Check if the admin has entered title and what-php file name...
48 if ((!isPostRequestParameterSet('title')) && (isFormSent())) {
49 unsetPostRequestParameter('ok');
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` ASC",
61 if (!SQL_HASZERONUMS($result)) {
62 // Read menu structure
63 // @TODO Cant this be rewritten?
64 while ($content = SQL_FETCHARRAY($result)) {
66 $menus[] = $content['action'];
69 $titles[] = $content['title'];
71 // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
72 $below[] = $content['sort'] + 1;
76 SQL_FREERESULT($result);
78 // Remove double eintries
79 // @TODO This can be somehow rewritten to a function
84 foreach ($menus as $key => $value) {
85 if ($value == $prev) {
96 $menus = $dmy; $titles = $dmy2; $below = $dmy3;
99 foreach ($menus as $key_main => $value_main) {
100 $result = SQL_QUERY_ESC("SELECT `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' ORDER BY `sort` ASC",
101 array($value_main), __FILE__, __LINE__);
102 if (!SQL_HASZERONUMS($result)) {
104 $menus[$value_main] = array();
105 $titles[$value_main] = array();
106 $below[$value_main] = array();
108 // Read menu structure
109 while ($content = SQL_FETCHARRAY($result)) {
111 $menus[$value_main][] = $content['what'];
114 $titles[$value_main][] = $content['title'];
116 // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
117 $below[$value_main][] = $content['sort'] + 1;
121 SQL_FREERESULT($result);
123 // Remove double eintries
124 // @TODO This can be somehow rewritten to a function
125 $prev = ''; $dmy = $menus[$value_main]; $dmy2 = $titles[$value_main]; $dmy3 = $below[$value_main];
126 foreach ($menus[$value_main] as $key => $value) {
127 if ($value == $prev) {
136 // Transfer variables into array
137 $menus[$value_main] = $dmy;
138 $titles[$value_main] = $dmy2;
139 $below[$value_main] = $dmy3;
144 $OUT = '<select class="form_select" name="sort" size="1">
145 <option value="">{--ADMIN_IS_FIRST_MENU--}</option>';
146 foreach ($below as $key => $m) {
148 foreach ($m as $key2 => $m2) {
149 $OUT .= '<option value="' . $m2 . '">' . $titles[$key][$key2];
150 foreach ($menus as $k => $v) {
151 if (($v == $key) && (!is_array($v))) {
152 $OUT .= ' (' . $titles[$k] . ')';
158 $OUT .= '<option value="' . $m . '">' . $titles[$key] . '</option>';
163 // Prepare selection boxes for template
164 $content['below_selection'] = $OUT;
165 $content['what_selection'] = adminAddMenuSelectionBox('member', 'what' , 'name');
166 $content['action_selection'] = adminAddMenuSelectionBox('member', 'action', 'menu');
169 loadTemplate('admin_add_member_menu', false, $content);
170 } elseif (!isDemoModeActive()) {
171 // Insert new menu entry
172 if (isPostRequestParameterSet('menu')) {
173 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s','%s')",
175 postRequestParameter('menu'),
176 postRequestParameter('name'),
177 postRequestParameter('title'),
178 postRequestParameter('visible'),
179 postRequestParameter('active'),
180 bigintval(postRequestParameter('sort')),
181 ), __FILE__, __LINE__);
183 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s')",
185 postRequestParameter('name'),
186 postRequestParameter('title'),
187 postRequestParameter('visible'),
188 postRequestParameter('active'),
189 bigintval(postRequestParameter('sort')),
190 ), __FILE__, __LINE__);
192 displayMessage('{--SETTINGS_SAVED');
195 displayMessage('{--SETTINGS_NOT_SAVED--}');