2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 09/28/2003 *
4 * =================== Last change: 05/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-memedit.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Edit member's menu *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Editieren Sie das Menue fuer Ihre Mitglieder *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
48 // Do we edit/delete/change main menus or sub menus?
49 $AND = "(`what` = '' OR `what` IS NULL)"; $SUB = '';
51 if (isGetRequestParameterSet('sub')) {
52 $AND = sprintf("`action`='%s' AND `what` IS NOT NULL", getRequestParameter('sub'));
53 $SUB = getRequestParameter('sub');
56 // List all menu points and make them editable
57 if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
59 $content['sub'] = $SUB;
60 $content['chk'] = countPostSelection();
61 $cnt = '0'; $OUT = '';
62 foreach (postRequestParameter('sel') as $sel => $confirm) {
65 $result = SQL_QUERY_ESC("SELECT `title`, `action`, `what` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
66 array(bigintval($sel)), __FILE__, __LINE__);
67 if (SQL_NUMROWS($result) == 1) {
68 // Entry found so we load the stuff...
69 $data = SQL_FETCHARRAY($result);
73 'menu' => $data['title'],
74 'act' => adminAddMenuSelectionBox('member', 'act' , 'sel_act[' . $sel . ']', $data['action']),
75 'what' => adminAddMenuSelectionBox('member', 'what', 'sel_what[' . $sel . ']', $data['what']),
79 $OUT .= loadTemplate('form_submit_member_menu_row', true, $data);
87 $OUT .= loadTemplate('admin_menu_404_row', true, $data);
89 SQL_FREERESULT($result);
93 // Add row content and current counter
94 $content['rows'] = $OUT;
95 $content['cnt'] = $cnt;
98 loadTemplate('form_submit_member_menu', false, $content);
99 } elseif ((isFormSent('del')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
100 // Del menu entries with or without confirmation
101 $content['sub'] = $SUB;
102 $content['chk'] = countPostSelection();
103 $cnt = '0'; $OUT = '';
104 foreach (postRequestParameter('sel') as $sel => $confirm) {
107 $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
108 array(bigintval($sel)), __FILE__, __LINE__);
109 if (SQL_NUMROWS($result) == 1) {
110 // Entry found so we load the stuff...
111 list($title) = SQL_FETCHROW($result);
119 $OUT .= loadTemplate('admin_del_member_menu_row', true, $content);
127 $OUT .= loadTemplate('admin_menu_404_row', true, $content);
129 SQL_FREERESULT($result);
132 $content['rows'] = $OUT;
133 $content['cnt'] = $cnt;
136 loadTemplate('admin_del_member_menu', false, $content);
137 } elseif ((isPostRequestParameterSet('status')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
138 // Change status (visible / locked)
139 $content['sub'] = $SUB;
140 $content['chk'] = countPostSelection();
141 $cnt = '0'; $OUT = '';
142 foreach (postRequestParameter('sel') as $sel => $confirm) {
145 $result = SQL_QUERY_ESC("SELECT `title`, `visible`, `locked` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
146 array(bigintval($sel)), __FILE__, __LINE__);
147 if (SQL_NUMROWS($result) == 1) {
148 // Entry found so we load the stuff...
149 $data = SQL_FETCHARRAY($result);
152 'menu' => $data['title'],
154 'visible' => addSelectionBox('yn', $data['visible'], 'visible', $sel),
155 'locked' => addSelectionBox('yn', $data['locked'] , 'locked' , $sel),
159 $OUT .= loadTemplate('admin_menu_status_row', true, $data);
167 $OUT .= loadTemplate('admin_menu_404_row', true, $data);
169 SQL_FREERESULT($result);
172 $content['rows'] = $OUT;
173 $content['cnt'] = $cnt;
176 loadTemplate('admin_member_menu_status', false, $content);
177 } elseif ((isFormSent()) && (!isDemoModeActive())) {
179 foreach (postRequestParameter('sel') as $sel => $menu) {
180 $AND = "(`what` = '' OR `what` IS NULL)";
182 $sel = bigintval($sel);
184 if (!empty($SUB)) $AND = "`action`='" . $SUB . "'";
186 switch (postRequestParameter('ok')) {
187 case 'edit': // Edit menu
188 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `title`='%s', `action`='%s', `what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
189 array($menu, postRequestParameter('sel_act', $sel), postRequestParameter('sel_what', $sel), $sel), __FILE__, __LINE__);
192 case 'del': // Delete menu
193 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
194 array($sel), __FILE__, __LINE__);
197 case 'status': // Change status of menus
198 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='%s', `locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
199 array(postRequestParameter('visible', $sel), postRequestParameter('locked', $sel), $sel), __FILE__, __LINE__);
202 default: // Unexpected action
203 logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestParameter('ok')));
204 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_UNKNOWN_OKAY', postRequestParameter('ok')));
210 loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
212 if ((isGetRequestParameterSet('act')) && (isGetRequestParameterSet('tid')) && (isGetRequestParameterSet('fid'))) {
214 $tid = ''; $fid = '';
217 if (isGetRequestParameterSet('w')) {
218 // Sub menus selected
219 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
220 array(bigintval(getRequestParameter('act')), bigintval(getRequestParameter('tid'))), __FILE__, __LINE__);
221 list($tid) = SQL_FETCHROW($result);
222 SQL_FREERESULT($result);
223 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
224 array(bigintval(getRequestParameter('act')), bigintval(getRequestParameter('fid'))), __FILE__, __LINE__);
225 list($fid) = SQL_FETCHROW($result);
226 SQL_FREERESULT($result);
228 // Main menu selected
229 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
230 array(bigintval(getRequestParameter('tid'))), __FILE__, __LINE__);
231 list($tid) = SQL_FETCHROW($result);
232 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
233 array(bigintval(getRequestParameter('fid'))), __FILE__, __LINE__);
234 list($fid) = SQL_FETCHROW($result);
237 if ((!empty($tid)) && (!empty($fid))) {
239 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
240 array(bigintval(getRequestParameter('tid')), bigintval($fid)), __FILE__, __LINE__);
241 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
242 array(bigintval(getRequestParameter('fid')), bigintval($tid)), __FILE__, __LINE__);
248 $result = SQL_QUERY("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC", __FILE__, __LINE__);
251 $result = SQL_QUERY("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
255 if (SQL_NUMROWS($result) > 0) {
257 $content['sub'] = $SUB;
259 $cnt = '0'; $OUT = '';
260 while ($data = SQL_FETCHARRAY($result)) {
264 if (($data['sort'] == '0') || (($data['sort'] == 1) && (!empty($SUB)))) {
265 // Is highest position
266 $data['navi'] = '<a href="{%url=modules.php?module=admin&what=adminedit&sub=' . $content['sub'] . '&act=' . $data['action'] . '&w=' . $data['what'] . '&tid=' . ($data['sort']+1) . '&fid=' . $data['sort'] . '%}">{--LOWER--}</a>';
267 } elseif ($cnt == SQL_NUMROWS($result)) {
268 // Is lowest position
269 $data['navi'] = '<a href="{%url=modules.php?module=admin&what=adminedit&sub=' . $content['sub'] . '&act=' . $data['action'] . '&w=' . $data['what'] . '&tid=' . ($data['sort']-1) . '&fid=' . $data['sort'] . '%}">{--HIGHER--}</a>';
270 } elseif ($data['sort'] > 0) {
271 // Anything else between highest and lowest
272 $data['navi'] = '<a href="{%url=modules.php?module=admin&what=adminedit&sub=' . $content['sub'] . '&act=' . $data['action'] . '&w=' . $data['what'] . '&tid=' . ($data['sort']-1) . '&fid=' . $data['sort'] . '%}">{--HIGHER--}</a>/<a href="{%url=modules.php?module=admin&what=memedit&sub=' . $content['sub'] . '&act=' . $data['action'] . '&w=' . $data['what'] . '&tid=' . ($data['sort']+1) . '&fid=' . $data['sort'] . '%}">{--LOWER--}</a>';
275 // Fix empty values for Firefox
276 if (empty($data['action'])) $data['action'] = ' ';
277 if (empty($data['what'])) $data['what'] = ' ';
278 if (empty($data['title'])) $data['title'] = ' ';
281 $data['mode'] = 'mem';
283 // Load row template and switch color
284 $OUT .= loadTemplate('admin_menu_overview_row', true, $data);
288 SQL_FREERESULT($result);
290 // Remember rows in array
291 $content['rows'] = $OUT;
293 // Load main template
294 loadTemplate('admin_member_menu_overview', false, $content);
296 // Menu entries are missing... (???)
297 loadTemplate('admin_settings_saved', false, '{--ADMIN_NO_MENUS_FOUND--}');