8d45685920d25a00026d85a9d7878b632a7a0196
[mailer.git] / inc / modules / admin / what-config_email.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/11/2003 *
4  * ===================                          Last change: 07/04/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-config_emails.php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : Edit all things around email and sending         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Aendern aller Email-Einstellungen                *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 }
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 // Remove empty array index
49 if (!isPostRequestParameterSet(('max'))) unsetPostRequestParameter(('add_max'));
50
51 if (isPostRequestParameterSet(('add_max'))) {
52         // Save all settings
53         $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE value='%s' LIMIT 1",
54         array(bigintval(postRequestParameter('max'))), __FILE__, __LINE__);
55         if (SQL_HASZERONUMS($result)) {
56                 // Add this value (including comment)
57                 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_max_receive` (value, comment) VALUES ('%s','%s')",
58                 array(bigintval(postRequestParameter('max')), postRequestParameter('comment')),__FILE__, __LINE__);
59                 $content = getMessage('MAX_VALUE_SAVED');
60         } else {
61                 // Value does alread exists!
62                 $content = '<span class="admin_failed">{--MAX_VALUE_ALREADY--}</span>';
63         }
64
65         // Free memory
66         SQL_FREERESULT($result);
67
68         // Display message
69         loadTemplate('admin_settings_saved', false, $content);
70 } elseif ((isFormSent()) && (isGetRequestParameterSet('do'))) {
71         // Change or delete entries...
72         $TEXT = '';
73         foreach (postRequestParameter('id') as $id => $value) {
74                 // Secure id
75                 $id = bigintval($id);
76
77                 switch (getRequestParameter('do'))
78                 {
79                         case 'edit': // Change entries
80                                 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_max_receive` SET value='%s', comment='%s' WHERE `id`=%s LIMIT 1",
81                                 array(
82                                         bigintval(postRequestParameter('val', $id)),
83                                         postRequestParameter('comm', $id),
84                                         $id
85                                 ),__FILE__, __LINE__);
86                                 $TEXT = getMessage('MRECEIVE_SAVED');
87                                 break;
88
89                         case 'del':
90                                 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
91                                         array($id), __FILE__, __LINE__);
92                                 $TEXT = getMessage('MRECEIVE_DELETED');
93                                 break;
94                 }
95         }
96
97         if (isset($TEXT)) {
98                 // Display message
99                 loadTemplate('admin_settings_saved', false, $TEXT);
100         } // END - if
101 } elseif ((isPostRequestParameterSet('del')) && (countPostSelection() > 0)) {
102         // Delete entries
103         $OUT = ''; $SW = 2;
104         foreach (postRequestParameter('sel') as $id => $value) {
105                 // Load data
106                 $result = SQL_QUERY_ESC("SELECT value, comment FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
107                 array(bigintval($id)), __FILE__, __LINE__);
108                 list($value, $comment) = SQL_FETCHROW($result);
109                 SQL_FREERESULT($result);
110
111                 // Prepare data for the row template
112                 $content = array(
113                         'sw'      => $SW,
114                         'id'      => $id,
115                         'value'   => $value,
116                         'comment' => $comment,
117                 );
118
119                 // Load row template and switch color
120                 $OUT .= loadTemplate('admin_config_email_del_row', true, $content);
121                 $SW = 3 - $SW;
122         }
123         $content['rows'] = $OUT;
124
125         // Load main template
126         loadTemplate('admin_config_email_del', false, $content);
127 } elseif ((isPostRequestParameterSet('edit')) && (countPostSelection() > 0)) {
128         // Edit entries
129         $OUT = ''; $SW = 2;
130         foreach (postRequestParameter('sel') as $id => $value) {
131                 // Load data
132                 $result = SQL_QUERY_ESC("SELECT value, comment FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
133                 array(bigintval($id)), __FILE__, __LINE__);
134                 list($value, $comment) = SQL_FETCHROW($result);
135                 SQL_FREERESULT($result);
136
137                 // Prepare data for the row template
138                 $content = array(
139                         'sw'      => $SW,
140                         'id'      => $id,
141                         'value'   => $value,
142                         'comment' => $comment,
143                 );
144
145                 // Load row template and switch color
146                 $OUT .= loadTemplate('admin_config_email_edit_row', true, $content);
147                 $SW = 3 - $SW;
148         }
149         $content['rows'] = $OUT;
150
151         // Load main template
152         loadTemplate('admin_config_email_edit', false, $content);
153 } else {
154         $result = SQL_QUERY("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC",
155         __FILE__, __LINE__);
156         if (SQL_NUMROWS($result) > 0) {
157                 // List already existing entries for editing
158                 $OUT = ''; $SW = 2;
159                 while ($content = SQL_FETCHARRAY($result)) {
160                         // Prepare data for the row template
161                         $content['sw'] = $SW;
162
163                         // Load row template and switch color
164                         $OUT .= loadTemplate('admin_config_email_row', true, $content);
165                         $SW = 3 - $SW;
166                 } // END - while
167
168                 // Free memory
169                 SQL_FREERESULT($result);
170                 $content['rows'] = $OUT;
171
172                 // Load main template
173                 loadTemplate('admin_config_email', false, $content);
174         } // END - if
175
176         // Display form
177         loadTemplate('admin_add_max');
178 }
179
180 // [EOF]
181 ?>