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, 2010 by Mailer Developer Team *
20 * For more information visit: http://www.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 (isGetRequestParameterSet('sub')) {
50 $AND = sprintf("`action`='%s' AND `what` IS NOT NULL", getRequestParameter('sub'));
51 $subMenu = getRequestParameter('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 (postRequestParameter('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 $DATA = SQL_FETCHARRAY($result);
74 'action' => adminAddMenuSelectionBox('guest', 'action', 'sel_action[' . $sel . ']', $DATA['action']),
75 'what' => adminAddMenuSelectionBox('guest', 'what' , 'sel_what[' . $sel . ']', $DATA['what']),
76 'menu' => $DATA['title'],
80 $OUT .= loadTemplate('admin_edit_guest_menu_row', true, $DATA);
86 $OUT .= loadTemplate('admin_menu_404_row', true, $DATA);
89 // Free result and switch color
90 SQL_FREERESULT($result);
94 $content['rows'] = $OUT;
95 $content['cnt'] = $count;
98 loadTemplate('admin_edit_guest_menu_form', false, $content);
99 } elseif ((isFormSent('delete')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
100 // Del menu entries with or without confirmation
101 $content['sub'] = $subMenu;
102 $content['chk'] = countPostSelection();
107 foreach (postRequestParameter('sel') as $sel => $confirm) {
110 $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
111 array(bigintval($sel)), __FILE__, __LINE__);
112 if (SQL_NUMROWS($result) == 1) {
113 // Entry found so we load the stuff...
114 $DATA = SQL_FETCHARRAY($result);
117 'menu' => $DATA['title'],
120 $OUT .= loadTemplate('admin_delete_guest_menu_row', true, $DATA);
126 $OUT .= loadTemplate('admin_menu_404_row', true, $DATA);
128 SQL_FREERESULT($result);
131 $content['rows'] = $OUT;
132 $content['cnt'] = $count;
135 loadTemplate('admin_delete_guest_menu', false, $content);
136 } elseif ((isPostRequestParameterSet('status')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
137 // Change status (visible / locked)
138 $content['sub'] = $subMenu;
139 $content['chk'] = countPostSelection();
142 $count = '0'; $OUT = '';
143 foreach (postRequestParameter('sel') as $sel => $confirm) {
146 $result = SQL_QUERY_ESC("SELECT `title`, `visible`, `locked` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
147 array(bigintval($sel)), __FILE__, __LINE__);
148 if (SQL_NUMROWS($result) == 1) {
149 // Entry found so we load the stuff...
150 $data = SQL_FETCHARRAY($result);
153 'menu' => $data['title'],
155 'visible' => addSelectionBox('yn', $data['visible'], 'visible', $sel),
156 'locked' => addSelectionBox('yn', $data['locked'] , 'locked' , $sel),
160 $OUT .= loadTemplate('admin_menu_status_row', true, $data);
166 $OUT .= loadTemplate('admin_menu_404_row', true, $data);
169 SQL_FREERESULT($result);
172 $content['cnt'] = $count;
173 $content['rows'] = $OUT;
176 loadTemplate('admin_guest_menu_status', false, $content);
177 } elseif ((isFormSent()) && (!isDemoModeActive())) {
178 // An action is done...
179 adminProcessMenuEditForm('guest', $subMenu);
182 doAdminProcessMenuWeightning('guest');
184 // By default list menus
185 if (empty($subMenu)) {
186 // List only main menus
187 $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__);
190 $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",
191 array($subMenu), __FILE__, __LINE__);
194 // Do we have entries?
195 if (!SQL_HASZERONUMS($result)) {
197 $content['sub'] = $subMenu;
203 // Process all menu entries
204 while ($data = SQL_FETCHARRAY($result)) {
206 if (($data['sort'] == '0') || (($data['sort'] == 1) && (!empty($subMenu)))) {
207 // Is highest position
208 $NAVI = '<a href="{%url=modules.php?module=admin&what=guestedit&sub=' . $content['sub'] . '&act=' . $data['action'] . '&w=' . $data['what'] . '&tid=' . ($data['sort']+1) . '&fid=' . $data['sort'] . '%}">{--LOWER--}</a>';
209 } elseif ($count == SQL_NUMROWS($result)) {
210 // Is lowest position
211 $NAVI = '<a href="{%url=modules.php?module=admin&what=guestedit&sub=' . $content['sub'] . '&act=' . $data['action'] . '&w=' . $data['what'] . '&tid=' . ($data['sort']-1) . '&fid=' . $data['sort'] . '%}">{--HIGHER--}</a>';
212 } elseif ($data['sort'] > 0) {
213 // Anything else between highest and lowest
214 $NAVI = '<a href="{%url=modules.php?module=admin&what=guestedit&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=guestedit&sub=' . $content['sub'] . '&act=' . $data['action'] . '&w=' . $data['what'] . '&tid=' . ($data['sort']+1) . '&fid=' . $data['sort'] . '%}">{--LOWER--}</a>';
217 if (empty($data['action'])) $data['action'] = ' ';
218 if (empty($data['what'])) $data['what'] = ' ';
219 if (empty($data['title'])) $data['title'] = ' ';
224 'action' => $data['action'],
225 'what' => $data['what'],
226 'title' => $data['title'],
232 $OUT .= loadTemplate('admin_menu_overview_row', true, $row);
236 $content['rows'] = $OUT;
239 SQL_FREERESULT($result);
242 loadTemplate('admin_edit_guest_menu', false, $content);
244 // Menu entries are missing... (???)
245 loadTemplate('admin_settings_saved', false, '{--ADMIN_NO_MENUS_FOUND--}');