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 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
46 // Do we edit/delete/change main menus or sub menus?
47 $AND = "(`what` = '' OR `what` IS NULL)"; $subMenu = '';
49 if (isGetRequestElementSet('sub')) {
50 $AND = sprintf("`action`='%s' AND `what` IS NOT NULL", getRequestElement('sub'));
51 $subMenu = getRequestElement('sub');
54 // List all menu points and make them editable
55 if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
57 $content['sub'] = $subMenu;
58 $content['chk'] = countPostSelection();
59 $count = '0'; $OUT = '';
60 foreach (postRequestElement('sel') as $sel => $confirm) {
63 $result = SQL_QUERY_ESC("SELECT `title`,`action`,`what` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
64 array(bigintval($sel)), __FILE__, __LINE__);
65 if (SQL_NUMROWS($result) == 1) {
66 // Entry found so we load the stuff...
67 $content = SQL_FETCHARRAY($result);
71 'menu' => $content['title'],
72 'action' => adminAddMenuSelectionBox('member', 'action', 'sel_action[' . $sel . ']', $content['action']),
73 'what' => adminAddMenuSelectionBox('member', 'what' , 'sel_what[' . $sel . ']', $content['what']),
77 $OUT .= loadTemplate('admin_edit_member_menu_row', true, $content);
85 $OUT .= loadTemplate('admin_menu_404_row', true, $content);
87 SQL_FREERESULT($result);
91 // Add row content and current counter
92 $content['rows'] = $OUT;
93 $content['chk'] = countPostSelection();
94 $content['sub'] = $subMenu;
95 $content['count'] = $count;
98 loadTemplate('admin_edit_member_menu', false, $content);
99 } elseif ((isFormSent('delete')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
100 // Del menu entries with or without confirmation
101 $content['sub'] = $subMenu;
102 $content['chk'] = countPostSelection();
103 $count = '0'; $OUT = '';
104 foreach (postRequestElement('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_delete_member_menu_row', true, $content);
127 $OUT .= loadTemplate('admin_menu_404_row', true, $content);
129 SQL_FREERESULT($result);
133 $content['rows'] = $OUT;
134 $content['chk'] = countPostSelection();
135 $content['sub'] = $subMenu;
136 $content['count'] = $count;
139 loadTemplate('admin_delete_member_menu', false, $content);
140 } elseif ((isPostRequestElementSet('status')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
141 // Change status (visible / locked)
142 $content['sub'] = $subMenu;
143 $content['chk'] = countPostSelection();
144 $count = '0'; $OUT = '';
145 foreach (postRequestElement('sel') as $sel => $confirm) {
148 $result = SQL_QUERY_ESC("SELECT `title`,`visible`,`locked` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
149 array(bigintval($sel)), __FILE__, __LINE__);
150 if (SQL_NUMROWS($result) == 1) {
151 // Entry found so we load the stuff...
152 $content = SQL_FETCHARRAY($result);
155 'menu' => $content['title'],
157 'visible' => addSelectionBox('yn', $content['visible'], 'visible', $sel),
158 'locked' => addSelectionBox('yn', $content['locked'] , 'locked' , $sel),
162 $OUT .= loadTemplate('admin_menu_status_row', true, $content);
170 $OUT .= loadTemplate('admin_menu_404_row', true, $content);
172 SQL_FREERESULT($result);
176 $content['rows'] = $OUT;
177 $content['chk'] = countPostSelection();
178 $content['sub'] = $subMenu;
179 $content['count'] = $count;
182 loadTemplate('admin_member_menu_status', false, $content);
183 } elseif ((isFormSent()) && (!isDemoModeActive())) {
184 // Process menu editing form
185 adminProcessMenuEditForm('member', $subMenu);
188 doAdminProcessMenuWeightning('member', $AND);
190 if (!empty($subMenu)) {
192 $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__);
195 $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__);
199 if (!SQL_HASZERONUMS($result)) {
200 $count = '0'; $OUT = '';
201 while ($content = SQL_FETCHARRAY($result)) {
203 $content['sub'] = $subMenu;
206 $content['navi'] = '';
208 if (($content['sort'] == '0') || (($content['sort'] == 1) && (!empty($subMenu)))) {
209 // Is highest position
210 $content['navi'] = '<a href="{%url=modules.php?module=admin&what=memedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']+1) . '&fid=' . $content['sort'] . '%}">{--LOWER--}</a>';
211 } elseif ($count == SQL_NUMROWS($result)) {
212 // Is lowest position
213 $content['navi'] = '<a href="{%url=modules.php?module=admin&what=memedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']-1) . '&fid=' . $content['sort'] . '%}">{--HIGHER--}</a>';
214 } elseif ($content['sort'] > 0) {
215 // Anything else between highest and lowest
216 $content['navi'] = '<a href="{%url=modules.php?module=admin&what=memedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']-1) . '&fid=' . $content['sort'] . '%}">{--HIGHER--}</a>|<a href="{%url=modules.php?module=admin&what=memedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']+1) . '&fid=' . $content['sort'] . '%}">{--LOWER--}</a>';
220 $content['mode'] = 'mem';
222 // Load row template and switch color
223 $OUT .= loadTemplate('admin_menu_overview_row', true, $content);
227 SQL_FREERESULT($result);
229 // Remember rows/sub in array
230 $content['rows'] = $OUT;
231 $content['sub'] = $subMenu;
233 // Load main template
234 loadTemplate('admin_member_menu_overview', false, $content);
236 // Menu entries are missing... (???)
237 displayMessage('{--ADMIN_NO_MENUS_FOUND--}');