18defeac9cbbc7f552b2c6c73e7cc1617aded4f7
[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  * -------------------------------------------------------------------- *
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 } // END - if
42
43 // Add description as navigation point
44 addMenuDescription('admin', __FILE__);
45
46 // Remove empty array index
47 if (!isPostRequestParameterSet('max')) unsetPostRequestParameter('add_max');
48
49 if (isPostRequestParameterSet('add_max')) {
50         // Save all settings
51         $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE value='%s' LIMIT 1",
52         array(bigintval(postRequestParameter('max'))), __FILE__, __LINE__);
53         if (SQL_HASZERONUMS($result)) {
54                 // Add this value (including comment)
55                 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_max_receive` (`value`, `comment`) VALUES ('%s','%s')",
56                 array(bigintval(postRequestParameter('max')), postRequestParameter('comment')),__FILE__, __LINE__);
57                 $content = '{--ADMIN_MAX_VALUE_SAVED--}';
58         } else {
59                 // Value does alread exists!
60                 $content = '<span class="notice">{--ADMIN_MAX_VALUE_ALREADY--}</span>';
61         }
62
63         // Free memory
64         SQL_FREERESULT($result);
65
66         // Display message
67         loadTemplate('admin_settings_saved', false, $content);
68 } elseif ((isFormSent()) && (isGetRequestParameterSet('do'))) {
69         // Change or delete entries...
70         $TEXT = '';
71         foreach (postRequestParameter('id') as $id => $value) {
72                 // Secure id
73                 $id = bigintval($id);
74
75                 switch (getRequestParameter('do'))
76                 {
77                         case 'edit': // Change entries
78                                 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_max_receive` SET value='%s', comment='%s' WHERE `id`=%s LIMIT 1",
79                                 array(
80                                         bigintval(postRequestParameter('val', $id)),
81                                         postRequestParameter('comm', $id),
82                                         $id
83                                 ),__FILE__, __LINE__);
84                                 $TEXT = '{--ADMIN_MAX_RECEIVE_SAVED--}';
85                                 break;
86
87                         case 'delete':
88                                 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
89                                         array($id), __FILE__, __LINE__);
90                                 $TEXT = '{--ADMIN_MAX_RECEIVE_DELETED--}';
91                                 break;
92                 }
93         }
94
95         if (isset($TEXT)) {
96                 // Display message
97                 loadTemplate('admin_settings_saved', false, $TEXT);
98         } // END - if
99 } elseif ((isFormSent('delete')) && (ifPostContainsSelections())) {
100         // Delete entries
101         $OUT = '';
102         foreach (postRequestParameter('sel') as $id => $value) {
103                 // Load data
104                 $result = SQL_QUERY_ESC("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
105                         array(bigintval($id)), __FILE__, __LINE__);
106                 $content = SQL_FETCHARRAY($result);
107                 SQL_FREERESULT($result);
108
109                 // Load row template and switch color
110                 $OUT .= loadTemplate('admin_config_email_del_row', true, $content);
111         } // END - foreach
112         $content['rows'] = $OUT;
113
114         // Load main template
115         loadTemplate('admin_config_email_del', false, $content);
116 } elseif ((isFormSent('edit')) && (ifPostContainsSelections())) {
117         // Edit entries
118         $OUT = '';
119         foreach (postRequestParameter('sel') as $id => $value) {
120                 // Load data
121                 $result = SQL_QUERY_ESC("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
122                         array(bigintval($id)), __FILE__, __LINE__);
123                 $content = SQL_FETCHARRAY($result);
124                 SQL_FREERESULT($result);
125
126                 // Load row template and switch color
127                 $OUT .= loadTemplate('admin_config_email_edit_row', true, $content);
128         } // END - foreach
129         $content['rows'] = $OUT;
130
131         // Load main template
132         loadTemplate('admin_config_email_edit', false, $content);
133 } else {
134         $result = SQL_QUERY("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC",
135         __FILE__, __LINE__);
136         if (!SQL_HASZERONUMS($result)) {
137                 // List already existing entries for editing
138                 $OUT = '';
139                 while ($content = SQL_FETCHARRAY($result)) {
140                         // Load row template and switch color
141                         $OUT .= loadTemplate('admin_config_email_row', true, $content);
142                 } // END - while
143
144                 // Free memory
145                 SQL_FREERESULT($result);
146                 $content['rows'] = $OUT;
147
148                 // Load main template
149                 loadTemplate('admin_config_email', false, $content);
150         } // END - if
151
152         // Display form
153         loadTemplate('admin_add_max');
154 }
155
156 // [EOF]
157 ?>