2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 09/28/2003 *
4 * =================== Last change: 12/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-guestedit.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Edit guest's menu *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Menue fuer die Gaeste editieren *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2012 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();
60 $count = '0'; $OUT = '';
61 foreach (postRequestElement('sel') as $sel => $confirm) {
64 $result = SQL_QUERY_ESC("SELECT `title`,`action`,`what` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
65 array(bigintval($sel)), __FILE__, __LINE__);
66 if (SQL_NUMROWS($result) == 1) {
67 // Entry found so we load the stuff...
68 $content = SQL_FETCHARRAY($result);
74 'action' => adminAddMenuSelectionBox('guest', 'action', 'sel_action[' . $sel . ']', $content['action']),
75 'what' => adminAddMenuSelectionBox('guest', 'what' , 'sel_what[' . $sel . ']', $content['what']),
76 'menu' => $content['title'],
81 $OUT .= loadTemplate('admin_edit_guest_menu_row', true, $content);
87 $OUT .= loadTemplate('admin_menu_404_row', true, $content);
90 // Free result and switch color
91 SQL_FREERESULT($result);
95 $content['rows'] = $OUT;
96 $content['chk'] = countPostSelection();
97 $content['sub'] = $subMenu;
98 $content['count'] = $count;
101 loadTemplate('admin_edit_guest_menu_form', false, $content);
102 } elseif ((isFormSent('delete')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
103 // Del menu entries with or without confirmation
104 $content['sub'] = $subMenu;
105 $content['chk'] = countPostSelection();
110 foreach (postRequestElement('sel') as $sel => $confirm) {
113 $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
114 array(bigintval($sel)), __FILE__, __LINE__);
115 if (SQL_NUMROWS($result) == 1) {
116 // Entry found so we load the stuff...
117 $content = SQL_FETCHARRAY($result);
120 'menu' => $content['title'],
123 $OUT .= loadTemplate('admin_delete_guest_menu_row', true, $content);
129 $OUT .= loadTemplate('admin_menu_404_row', true, $content);
131 SQL_FREERESULT($result);
135 $content['rows'] = $OUT;
136 $content['chk'] = countPostSelection();
137 $content['sub'] = $subMenu;
138 $content['count'] = $count;
141 loadTemplate('admin_delete_guest_menu', false, $content);
142 } elseif ((isPostRequestElementSet('status')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
143 // Change status (visible / locked)
144 $content['sub'] = $subMenu;
145 $content['chk'] = countPostSelection();
148 $count = '0'; $OUT = '';
149 foreach (postRequestElement('sel') as $sel => $confirm) {
152 $result = SQL_QUERY_ESC("SELECT `title`,`visible`,`locked` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
153 array(bigintval($sel)), __FILE__, __LINE__);
154 if (SQL_NUMROWS($result) == 1) {
155 // Entry found so we load the stuff...
156 $content = SQL_FETCHARRAY($result);
159 'menu' => $content['title'],
161 'visible' => addSelectionBox('yn', $content['visible'], 'visible', $sel),
162 'locked' => addSelectionBox('yn', $content['locked'] , 'locked' , $sel),
166 $OUT .= loadTemplate('admin_menu_status_row', true, $content);
172 $OUT .= loadTemplate('admin_menu_404_row', true, $content);
175 SQL_FREERESULT($result);
179 $content['rows'] = $OUT;
180 $content['chk'] = countPostSelection();
181 $content['sub'] = $subMenu;
182 $content['count'] = $count;
185 loadTemplate('admin_guest_menu_status', false, $content);
186 } elseif ((isFormSent()) && (!isDemoModeActive())) {
187 // An action is done...
188 adminProcessMenuEditForm('guest', $subMenu);
191 doAdminProcessMenuWeightning('guest', $AND);
193 // By default list menus
194 if (empty($subMenu)) {
195 // List only main menus
196 $result = SQL_QUERY("SELECT `id`,`action`,`what`,`title`,`sort` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
199 $result = SQL_QUERY_ESC("SELECT `id`,`action`,`what`,`title`,`sort` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
200 array($subMenu), __FILE__, __LINE__);
203 // Do we have entries?
204 if (!SQL_HASZERONUMS($result)) {
209 // Process all menu entries
210 while ($content = SQL_FETCHARRAY($result)) {
212 $content['sub'] = $subMenu;
215 if (($content['sort'] == '0') || (($content['sort'] == 1) && (!empty($subMenu)))) {
216 // Is highest position
217 $NAVI = '<a href="{%url=modules.php?module=admin&what=guestedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']+1) . '&fid=' . $content['sort'] . '%}">{--LOWER--}</a>';
218 } elseif (SQL_NUMROWS($result) == $count) {
219 // Is lowest position
220 $NAVI = '<a href="{%url=modules.php?module=admin&what=guestedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']-1) . '&fid=' . $content['sort'] . '%}">{--HIGHER--}</a>';
221 } elseif ($content['sort'] > 0) {
222 // Anything else between highest and lowest
223 $NAVI = '<a href="{%url=modules.php?module=admin&what=guestedit&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=guestedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']+1) . '&fid=' . $content['sort'] . '%}">{--LOWER--}</a>';
228 'id' => $content['id'],
229 'action' => $content['action'],
230 'what' => $content['what'],
231 'title' => $content['title'],
237 $OUT .= loadTemplate('admin_menu_overview_row', true, $content);
241 $content['rows'] = $OUT;
242 $content['sub'] = $subMenu;
245 SQL_FREERESULT($result);
248 loadTemplate('admin_edit_guest_menu', false, $content);
250 // Menu entries are missing... (???)
251 displayMessage('{--ADMIN_NO_MENUS_FOUND--}');