]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-adminedit.php
- Rewrites to use more the userid than the actual email address when sending
[mailer.git] / inc / modules / admin / what-adminedit.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 09/05/2003 *
4  * ===================                          Last change: 12/13/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-adminedit.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Edit the admin menu                              *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Das Admin-Menue 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 - 2011 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 } // END - if
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)"; $SUB = '';
48 if (isGetRequestParameterSet('sub')) {
49         $AND = sprintf("`action`='%s' AND `what` != '' AND `what` IS NOT NULL", getRequestParameter('sub'));
50         $SUB = getRequestParameter('sub');
51 } // END - if
52
53 // List all menu points and make them editable
54 if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
55         // Edit menu entries
56         // @TODO Kill all constants in this file
57         $content['sub'] = $SUB;
58         $content['chk'] = countPostSelection();
59         $count = '0'; $OUT = '';
60         foreach (postRequestParameter('sel') as $sel => $confirm) {
61                 if ($confirm == 1) {
62                         $count++;
63                         $result = SQL_QUERY_ESC("SELECT `title`, `action`, `what`, `descr` FROM `{?_MYSQL_PREFIX?}_admin_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                                 $data = SQL_FETCHARRAY($result);
68
69                                 // Prepare data for the row template
70                                 $data = array(
71                                         'action' => adminAddMenuSelectionBox('admin', 'action', 'sel_action[' . $sel . ']', $data['action']),
72                                         'what'   => adminAddMenuSelectionBox('admin', 'what'  , 'sel_what['   . $sel . ']', $data['what']),
73                                         'sel'    => $sel,
74                                         'menu'   => $data['title'],
75                                         'descr'  => $data['descr'],
76                                         'cnt'    => $count,
77                                 );
78
79                                 // Load row template
80                                 $OUT .= loadTemplate('admin_edit_admin_menu_row', true, $data);
81                         } else {
82                                 // Entry not found?
83                                 $data = array(
84                                         'sel' => $sel
85                                 );
86
87                                 // Load row template
88                                 $OUT .= loadTemplate('admin_menu_404_row', true, $data);
89                         }
90
91                         // Free result and switch color
92                         SQL_FREERESULT($result);
93                 } // END - if
94         } // END - foreach
95
96         $content['rows'] = $OUT;
97         $content['cnt'] = $count;
98
99         // Load template
100         loadTemplate('admin_edit_admin_menu_form', false, $content);
101 } elseif ((isFormSent('delete')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
102         // Prepare misc content
103         $content['sub'] = $SUB;
104         $content['chk'] = countPostSelection();
105
106         // Del menu entries with or without confirmation
107         $count = '0'; $OUT = '';
108         foreach (postRequestParameter('sel') as $sel => $confirm) {
109                 if ($confirm == 1) {
110                         $count++;
111                         $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
112                                 array(bigintval($sel)), __FILE__, __LINE__);
113                         if (SQL_NUMROWS($result) == 1) {
114                                 // Entry found so we load the stuff...
115                                 $data = SQL_FETCHARRAY($result);
116
117                                 // Prepare data for the row template
118                                 $data = array(
119                                         'menu' => $data['title'],
120                                         'cnt'  => $count,
121                                         'sel'  => $sel,
122                                 );
123                                 $OUT .= loadTemplate('admin_delete_admin_menu_row', true, $data);
124                         } else {
125                                 // Entry not found?
126                                 $data = array(
127                                         'sel' => $sel
128                                 );
129                                 $OUT .= loadTemplate('admin_menu_404_row', true, $data);
130                         }
131                         SQL_FREERESULT($result);
132                 } // END - if
133         } // END - switch
134         $content['rows'] = $OUT;
135         $content['cnt'] = $count;
136
137         // Load template
138         loadTemplate('admin_delete_admin_menu', false, $content);
139 } elseif ((isFormSent()) && (!isDemoModeActive())) {
140         // An action is done...
141         switch (postRequestParameter('ok')) {
142                 case 'edit': // Edit menu
143                         foreach (postRequestParameter('sel') as $sel => $menu) {
144                                 // Secure id
145                                 $sel = bigintval($sel);
146
147                                 // Update entry
148                                 SQL_QUERY_ESC("UPDATE
149         `{?_MYSQL_PREFIX?}_admin_menu`
150 SET
151         `title`='%s',
152         `action`='%s',
153         `what`='%s',
154         `descr`='%s'
155 WHERE
156         ".$AND." AND
157         `id`=%s
158 LIMIT 1",
159                                 array(
160                                         $menu,
161                                         postRequestParameter('sel_action', $sel),
162                                         postRequestParameter('sel_what', $sel),
163                                         postRequestParameter('sel_desc', $sel),
164                                         $sel,
165                                 ), __FILE__, __LINE__);
166                         }
167
168                         // Load template
169                         displayMessage('{--SETTINGS_SAVED--}');
170                         break;
171
172                 case 'delete': // Delete menu
173                         foreach (postRequestParameter('sel') as $sel => $menu) {
174                                 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
175                                         array(bigintval($sel)), __FILE__, __LINE__);
176                         } // END - foreach
177
178                         // Load template
179                         displayMessage('{--SETTINGS_SAVED--}');
180                         break;
181
182                 default: // Unexpected action
183                         logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestParameter('ok')));
184                         displayMessage('{%message,ADMIN_UNKNOWN_OKAY=' . postRequestParameter('ok') . '%}');
185                         break;
186         } // END - switch
187 } else {
188         // Handle weightning
189         doAdminProcessMenuWeightning('admin', $AND);
190
191         // Run SQL
192         $result = SQL_QUERY("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." ORDER BY `sort` ASC", __FILE__, __LINE__);
193
194         // Do we have entries?
195         if (!SQL_HASZERONUMS($result)) {
196                 // Remember sub value
197                 $content['sub'] = $SUB;
198
199                 // Init variables
200                 $OUT = '';
201                 $count = '0';
202
203                 // Process all entries
204                 while ($data = SQL_FETCHARRAY($result)) {
205                         // Count this entry
206                         $count++;
207
208                         // Init navigation variable
209                         $data['navi'] = '';
210                         if (($data['sort'] == '0') || (($data['sort'] == 1) && (!empty($SUB)))) {
211                                 // Is highest position
212                                 $data['navi'] = '<a href="{%url=modules.php?module=admin&amp;what=adminedit&amp;sub=' . $content['sub'] . '&amp;act=' . $data['action'] . '&amp;w=' . $data['what'] . '&amp;tid=' . ($data['sort']+1) . '&amp;fid=' . $data['sort'] . '%}">{--LOWER--}</a>';
213                         } elseif ($count == SQL_NUMROWS($result)) {
214                                 // Is lowest position
215                                 $data['navi'] = '<a href="{%url=modules.php?module=admin&amp;what=adminedit&amp;sub=' . $content['sub'] . '&amp;act=' . $data['action'] . '&amp;w=' . $data['what'] . '&amp;tid=' . ($data['sort']-1) . '&amp;fid=' . $data['sort'] . '%}">{--HIGHER--}</a>';
216                         } elseif ($data['sort'] > 0) {
217                                 // Anything else between highest and lowest
218                                 $data['navi'] = '<a href="{%url=modules.php?module=admin&amp;what=adminedit&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=adminedit&amp;sub=' . $content['sub'] . '&amp;act=' . $data['action'] . '&amp;w=' . $data['what'] . '&amp;tid=' . ($data['sort']+1) . '&amp;fid=' . $data['sort'] . '%}">{--LOWER--}</a>';
219                         }
220
221                         // Add more data to $data
222                         $data['mode'] = 'admin';
223
224                         // Load row template and switch colors
225                         $OUT .= loadTemplate('admin_menu_overview_row', true, $data);
226                 } // END - switch
227
228                 // Remember all rows
229                 $content['rows'] = $OUT;
230
231                 // Free memory
232                 SQL_FREERESULT($result);
233
234                 // Load template
235                 loadTemplate('admin_edit_admin_menu', false, $content);
236         } else {
237                 // Menu entries are missing... (???)
238                 displayMessage('{--ADMIN_NO_MENUS_FOUND--}');
239         }
240 }
241
242 //
243 ?>