More XHTML-fied and extended header added to templates
[mailer.git] / inc / modules / admin / what-config_email.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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:: 856                                                    $ *
14  * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. March 2009)             $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author:: stelzi                                                   $ *
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 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
42         require($INC);
43 }
44
45 // Add description as navigation point
46 ADD_DESCR("admin", __FILE__);
47
48 // Remove empty array index
49 if (!REQUEST_ISSET_POST(('max'))) REQUEST_UNSET_POST(('add_max'));
50
51 if (REQUEST_ISSET_POST(('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(REQUEST_POST('max'))), __FILE__, __LINE__);
55         if (SQL_NUMROWS($result) == 0) {
56                 // Add this value (including comment)
57                 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_max_receive` (value, comment) VALUES ('%s','%s')",
58                         array(bigintval(REQUEST_POST('max')), REQUEST_POST('comment')),__FILE__, __LINE__);
59                 $content = 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         LOAD_TEMPLATE("admin_settings_saved", false, $content);
70 } elseif ((IS_FORM_SENT()) && (REQUEST_ISSET_GET(('do')))) {
71         // Change or delete entries...
72         $TEXT = "";
73         foreach (REQUEST_POST('id') as $id => $value) {
74                 // Secure ID
75                 $id = bigintval($id);
76
77                 switch (REQUEST_GET('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(REQUEST_POST('val', $id)),
83                                         REQUEST_POST('comm', $id),
84                                         $id
85                                 ),__FILE__, __LINE__);
86                         $TEXT = 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 = MRECEIVE_DELETED;
93                         break;
94                 }
95         }
96
97         if (isset($TEXT)) {
98                 // Display message
99                 LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);
100         }
101 } elseif ((REQUEST_ISSET_POST('del')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) {
102         // Delete entries
103         $OUT = ""; $SW = 2;
104         foreach (REQUEST_POST('sel') as $id => $value)
105         {
106                 // Load data
107                 $result = SQL_QUERY_ESC("SELECT value, comment FROM `{!_MYSQL_PREFIX!}_max_receive` WHERE id=%s LIMIT 1",
108                  array(bigintval($id)), __FILE__, __LINE__);
109                 list($value, $comment) = SQL_FETCHROW($result);
110                 SQL_FREERESULT($result);
111
112                 // Prepare data for the row template
113                 $content = array(
114                         'sw'      => $SW,
115                         'id'      => $id,
116                         'value'   => $value,
117                         'comment' => $comment,
118                 );
119
120                 // Load row template and switch color
121                 $OUT .= LOAD_TEMPLATE("admin_config_email_del_row", true, $content);
122                 $SW = 3 - $SW;
123         }
124         define('__ROWS', $OUT);
125
126         // Load main template
127         LOAD_TEMPLATE("admin_config_email_del");
128 } elseif ((REQUEST_ISSET_POST('edit')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) {
129         // Edit entries
130         $OUT = ""; $SW = 2;
131         foreach (REQUEST_POST('sel') as $id => $value) {
132                 // Load data
133                 $result = SQL_QUERY_ESC("SELECT value, comment FROM `{!_MYSQL_PREFIX!}_max_receive` WHERE id=%s LIMIT 1",
134                  array(bigintval($id)), __FILE__, __LINE__);
135                 list($value, $comment) = SQL_FETCHROW($result);
136                 SQL_FREERESULT($result);
137
138                 // Prepare data for the row template
139                 $content = array(
140                         'sw'      => $SW,
141                         'id'      => $id,
142                         'value'   => $value,
143                         'comment' => $comment,
144                 );
145
146                 // Load row template and switch color
147                 $OUT .= LOAD_TEMPLATE("admin_config_email_edit_row", true, $content);
148                 $SW = 3 - $SW;
149         }
150         define('__ROWS', $OUT);
151
152         // Load main template
153         LOAD_TEMPLATE("admin_config_email_edit");
154 } else {
155         $result = SQL_QUERY("SELECT id, value, comment FROM `{!_MYSQL_PREFIX!}_max_receive` ORDER BY value",
156                 __FILE__, __LINE__);
157         if (SQL_NUMROWS($result) > 0) {
158                 // List already existing entries for editing
159                 $OUT = ""; $SW = 2;
160                 while ($content = SQL_FETCHARRAY($result)) {
161                         // Prepare data for the row template
162                         $content['sw'] = $SW;
163
164                         // Load row template and switch color
165                         $OUT .= LOAD_TEMPLATE("admin_config_email_row", true, $content);
166                         $SW = 3 - $SW;
167                 } // END - while
168
169                 // Free memory
170                 SQL_FREERESULT($result);
171                 define('__ROWS', $OUT);
172
173                 // Load main template
174                 LOAD_TEMPLATE("admin_config_email");
175         } // END - if
176
177         // Display form
178         LOAD_TEMPLATE("admin_add_max");
179 }
180
181 //
182 ?>