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 * Needs to be in all Files and every File needs "svn propset *
19 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
20 * -------------------------------------------------------------------- *
21 * Copyright (c) 2003 - 2009 by Roland Haeder *
22 * Copyright (c) 2009, 2010 by Mailer Developer Team *
23 * For more information visit: http://www.mxchange.org *
25 * This program is free software; you can redistribute it and/or modify *
26 * it under the terms of the GNU General Public License as published by *
27 * the Free Software Foundation; either version 2 of the License, or *
28 * (at your option) any later version. *
30 * This program is distributed in the hope that it will be useful, *
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
33 * GNU General Public License for more details. *
35 * You should have received a copy of the GNU General Public License *
36 * along with this program; if not, write to the Free Software *
37 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
39 ************************************************************************/
41 // Some security stuff...
42 if ((!defined('__SECURITY')) || (!isAdmin())) {
46 // Add desciption as navigation point
47 addMenuDescription('admin', __FILE__);
49 // Check if the admin has entered title and what-php file name...
50 if ((!isPostRequestParameterSet('title')) && (isFormSent())) {
51 unsetPostRequestParameter('ok');
60 // Get all available main menus
61 $result = SQL_QUERY("SELECT `action`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC",
63 if (!SQL_HASZERONUMS($result)) {
64 // Read menu structure
65 // @TODO Cant this be rewritten?
66 while ($content = SQL_FETCHARRAY($result)) {
68 $menus[] = $content['action'];
71 $titles[] = $content['title'];
73 // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
74 $below[] = $content['sort'] + 1;
78 SQL_FREERESULT($result);
80 // Remove double eintries
81 // @TODO This can be somehow rewritten to a function
86 foreach ($menus as $key => $value) {
87 if ($value == $prev) {
98 $menus = $dmy; $titles = $dmy2; $below = $dmy3;
101 foreach ($menus as $key_main => $value_main) {
102 $result = SQL_QUERY_ESC("SELECT what, title, sort FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' ORDER BY `sort`",
103 array($value_main), __FILE__, __LINE__);
104 if (!SQL_HASZERONUMS($result)) {
106 $menus[$value_main] = array();
107 $titles[$value_main] = array();
108 $below[$value_main] = array();
110 // Read menu structure
111 while ($content = SQL_FETCHARRAY($result)) {
113 $menus[$value_main][] = $content['what'];
116 $titles[$value_main][] = $content['title'];
118 // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
119 $below[$value_main][] = $content['sort'] + 1;
123 SQL_FREERESULT($result);
125 // Remove double eintries
126 // @TODO This can be somehow rewritten to a function
127 $prev = ''; $dmy = $menus[$value_main]; $dmy2 = $titles[$value_main]; $dmy3 = $below[$value_main];
128 foreach ($menus[$value_main] as $key => $value) {
129 if ($value == $prev) {
138 // Transfer variables into array
139 $menus[$value_main] = $dmy;
140 $titles[$value_main] = $dmy2;
141 $below[$value_main] = $dmy3;
146 $OUT = "<select class=\"admin_select\" name=\"sort\" size=\"1\">
147 <option value=\"\">{--IS_FIRST_MENU--}</option>\n";
148 foreach ($below as $key => $m) {
150 foreach ($m as $key2 => $m2) {
151 $OUT .= " <option value=\"" . $m2 . "\">" . $titles[$key][$key2];
152 foreach ($menus as $k => $v) {
153 if (($v == $key) && (!is_array($v))) {
154 $OUT .= " (" . $titles[$k] . ')';
157 $OUT .= "</option>\n";
160 $OUT .= " <option value=\"" . $m . "\">" . $titles[$key] . "</option>\n";
165 // Prepare selection boxes for template
166 $content['below_selection'] = $OUT;
167 $content['what_selection'] = adminAddMenuSelectionBox('member', 'what' , 'name');
168 $content['action_selection'] = adminAddMenuSelectionBox('member', 'action', 'menu');
171 loadTemplate('admin_member_add', false, $content);
172 } elseif (!isDemoModeActive()) {
173 // Insert new menu entry
174 if (isPostRequestParameterSet('menu')) {
175 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s','%s')",
177 postRequestParameter('menu'),
178 postRequestParameter('name'),
179 postRequestParameter('title'),
180 postRequestParameter('visible'),
181 postRequestParameter('active'),
182 bigintval(postRequestParameter('sort')),
183 ), __FILE__, __LINE__);
185 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s')",
187 postRequestParameter('name'),
188 postRequestParameter('title'),
189 postRequestParameter('visible'),
190 postRequestParameter('active'),
191 bigintval(postRequestParameter('sort')),
192 ), __FILE__, __LINE__);
194 loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED');
197 loadTemplate('admin_settings_saved', false, '{--SETTINGS_NOT_SAVED--}');