]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-guestedit.php
Fix for missing language string and variable renamed to better naming convention
[mailer.git] / inc / modules / admin / what-guestedit.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 09/28/2003 *
4  * ===================                          Last change: 12/13/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-guestedit.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Edit guest's menu                                *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Menue fuer die Gaeste editieren                  *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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                  *
21  *                                                                      *
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.                                  *
26  *                                                                      *
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.                         *
31  *                                                                      *
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,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
40         die();
41 }
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 // Do we edit/delete/change main menus or sub menus?
47 $AND = "(`what` = '' OR `what` IS NULL)"; $subMenu = '';
48
49 if (isGetRequestParameterSet('sub')) {
50         $AND = sprintf("`action`='%s' AND `what` IS NOT NULL", getRequestParameter('sub'));
51         $subMenu = getRequestParameter('sub');
52 } // END - if
53
54 // List all menu points and make them editable
55 if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
56         // Edit menu entries
57         $content['sub'] = $subMenu;
58         $content['chk'] = countPostSelection();
59
60         $count = '0'; $OUT = '';
61         foreach (postRequestParameter('sel') as $sel => $confirm) {
62                 if ($confirm == 1) {
63                         $count++;
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);
69
70                                 // Prepapre content
71                                 $DATA = array(
72                                         'cnt'    => $count,
73                                         'sel'    => $sel,
74                                         'action' => adminAddMenuSelectionBox('guest', 'action', 'sel_action[' . $sel . ']', $DATA['action']),
75                                         'what'   => adminAddMenuSelectionBox('guest', 'what'  , 'sel_what['   . $sel . ']', $DATA['what']),
76                                         'menu'   => $DATA['title'],
77                                 );
78
79                                 // Load row template
80                                 $OUT .= loadTemplate('admin_edit_guest_menu_row', true, $DATA);
81                         } else {
82                                 // Entry not found
83                                 $DATA = array(
84                                         'sel' => $sel
85                                 );
86                                 $OUT .= loadTemplate('admin_menu_404_row', true, $DATA);
87                         }
88
89                         // Free result and switch color
90                         SQL_FREERESULT($result);
91                 } // END - if
92         } // END - foreach
93
94         $content['rows'] = $OUT;
95         $content['cnt']  = $count;
96
97         // Load template
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();
103
104         $count = '0';
105         $OUT = '';
106
107         foreach (postRequestParameter('sel') as $sel => $confirm) {
108                 if ($confirm == 1) {
109                         $count++;
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);
115                                 $DATA = array(
116                                         'cnt'  => $count,
117                                         'menu' => $DATA['title'],
118                                         'sel'  => $sel,
119                                 );
120                                 $OUT .= loadTemplate('admin_delete_guest_menu_row', true, $DATA);
121                         } else {
122                                 // Entry not found?
123                                 $DATA = array(
124                                         'sel' => $sel
125                                 );
126                                 $OUT .= loadTemplate('admin_menu_404_row', true, $DATA);
127                         }
128                         SQL_FREERESULT($result);
129                 } // END - if
130         } // END - foreach
131         $content['rows'] = $OUT;
132         $content['cnt']  = $count;
133
134         // Load template
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();
140
141         // Load template
142         $count = '0'; $OUT = '';
143         foreach (postRequestParameter('sel') as $sel => $confirm) {
144                 if ($confirm == 1) {
145                         $count++;
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);
151                                 $data = array(
152                                         'cnt'     => $count,
153                                         'menu'    => $data['title'],
154                                         'sel'     => $sel,
155                                         'visible' => addSelectionBox('yn', $data['visible'], 'visible', $sel),
156                                         'locked'  => addSelectionBox('yn', $data['locked'] , 'locked' , $sel),
157                                 );
158
159                                 // Load template
160                                 $OUT .= loadTemplate('admin_menu_status_row', true, $data);
161                         } else {
162                                 // Entry not found?
163                                 $data = array(
164                                         'sel' => $sel
165                                 );
166                                 $OUT .= loadTemplate('admin_menu_404_row', true, $data);
167                         }
168
169                         SQL_FREERESULT($result);
170                 } // END - if
171         } // END - foreach
172         $content['cnt']  = $count;
173         $content['rows'] = $OUT;
174
175         // Load template
176         loadTemplate('admin_guest_menu_status', false, $content);
177 } elseif ((isFormSent()) && (!isDemoModeActive())) {
178         // An action is done...
179         adminProcessMenuEditForm('guest', $subMenu);
180 } else {
181         // Handle weightning
182         doAdminProcessMenuWeightning('guest');
183
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__);
188         } else {
189                 // List sub menus
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__);
192         }
193
194         // Do we have entries?
195         if (!SQL_HASZERONUMS($result)) {
196                 // Set sub value
197                 $content['sub'] = $subMenu;
198
199                 // Init variables
200                 $count = '0';
201                 $OUT = '';
202
203                 // Process all menu entries
204                 while ($data = SQL_FETCHARRAY($result)) {
205                         $count++;
206                         if (($data['sort'] == '0') || (($data['sort'] == 1) && (!empty($subMenu)))) {
207                                 // Is highest position
208                                 $NAVI = '<a href="{%url=modules.php?module=admin&amp;what=guestedit&amp;sub=' . $content['sub'] . '&amp;act=' . $data['action'] . '&amp;w=' . $data['what'] . '&amp;tid=' . ($data['sort']+1) . '&amp;fid=' . $data['sort'] . '%}">{--LOWER--}</a>';
209                         } elseif ($count == SQL_NUMROWS($result)) {
210                                 // Is lowest position
211                                 $NAVI = '<a href="{%url=modules.php?module=admin&amp;what=guestedit&amp;sub=' . $content['sub'] . '&amp;act=' . $data['action'] . '&amp;w=' . $data['what'] . '&amp;tid=' . ($data['sort']-1) . '&amp;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&amp;what=guestedit&amp;sub=' . $content['sub'] . '&amp;act=' . $data['action'] . '&amp;w=' . $data['what'] . '&amp;tid=' . ($data['sort']-1) . '&amp;fid=' . $data['sort'] . '%}">{--HIGHER--}</a>/<a href=\"{%url=modules.php?module=admin&amp;what=guestedit&amp;sub=' . $content['sub'] . '&amp;act=' . $data['action'] . '&amp;w=' . $data['what'] . '&amp;tid=' . ($data['sort']+1) . '&amp;fid=' . $data['sort'] . '%}">{--LOWER--}</a>';
215                         }
216
217                         if (empty($data['action'])) $data['action'] = '&nbsp;';
218                         if (empty($data['what']))   $data['what']   = '&nbsp;';
219                         if (empty($data['title']))  $data['title']  = '&nbsp;';
220
221                         // Prepapre content
222                         $row = array(
223                                 'id'     => $data['id'],
224                                 'action' => $data['action'],
225                                 'what'   => $data['what'],
226                                 'title'  => $data['title'],
227                                 'navi'   => $NAVI,
228                                 'mode'   => 'guest'
229                         );
230
231                         // Load row template
232                         $OUT .= loadTemplate('admin_menu_overview_row', true, $row);
233                 } // END - while
234
235                 // Add rows
236                 $content['rows'] = $OUT;
237
238                 // Free memory
239                 SQL_FREERESULT($result);
240
241                 // Load template
242                 loadTemplate('admin_edit_guest_menu', false, $content);
243         } else {
244                 // Menu entries are missing... (???)
245                 loadTemplate('admin_settings_saved', false, '{--ADMIN_NO_MENUS_FOUND--}');
246         }
247 }
248
249 // [EOF]
250 ?>