Updated copyright notice as there are changes in this year
[mailer.git] / inc / modules / admin / what-list_email_max_rec.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/30/2011 *
4  * ===================                          Last change: 06/30/2011 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_email_max_rec.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 - 2013 by Mailer Developer Team                   *
20  * For more information visit: http://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 // Remove empty array index
47 if (!isPostRequestElementSet('max')) {
48         unsetPostRequestElement('add_max');
49 } // END - if
50
51 if (isPostRequestElementSet('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(postRequestElement('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(postRequestElement('max')), postRequestElement('comment')),__FILE__, __LINE__);
59                 $content = '{--ADMIN_MAX_VALUE_SAVED--}';
60         } else {
61                 // Value does alread exists!
62                 $content = '<span class="bad">{--ADMIN_MAX_VALUE_ALREADY--}</span>';
63         }
64
65         // Free memory
66         SQL_FREERESULT($result);
67
68         // Display message
69         displayMessage($content);
70 } elseif ((isFormSent()) && (isGetRequestElementSet('do'))) {
71         // Change or delete entries...
72         $TEXT = '';
73         foreach (postRequestElement('id') as $id => $value) {
74                 // Secure id
75                 $id = bigintval($id);
76
77                 switch (getRequestElement('do')) {
78                         case 'edit': // Change entries
79                                 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_max_receive` SET value='%s', comment='%s' WHERE `id`=%s LIMIT 1",
80                                 array(
81                                         bigintval(postRequestElement('val', $id)),
82                                         postRequestElement('comm', $id),
83                                         $id
84                                 ),__FILE__, __LINE__);
85                                 $TEXT = '{--ADMIN_MAX_RECEIVE_SAVED--}';
86                                 break;
87
88                         case 'delete':
89                                 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
90                                         array($id), __FILE__, __LINE__);
91                                 $TEXT = '{--ADMIN_MAX_RECEIVE_DELETED--}';
92                                 break;
93                 } // END - switch
94         } /// END - foreach
95
96         if (isset($TEXT)) {
97                 // Display message
98                 displayMessage($TEXT);
99         } // END - if
100 } elseif ((isFormSent('delete')) && (ifPostContainsSelections())) {
101         // Delete entries
102         $OUT = '';
103         foreach (postRequestElement('sel') as $id => $value) {
104                 // Load data
105                 $result = SQL_QUERY_ESC("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
106                         array(bigintval($id)), __FILE__, __LINE__);
107                 $content = SQL_FETCHARRAY($result);
108                 SQL_FREERESULT($result);
109
110                 // Load row template and switch color
111                 $OUT .= loadTemplate('admin_delete_email_max_rec_row', TRUE, $content);
112         } // END - foreach
113         $content['rows'] = $OUT;
114
115         // Load main template
116         loadTemplate('admin_delete_email_max_rec', FALSE, $content);
117 } elseif ((isFormSent('edit')) && (ifPostContainsSelections())) {
118         // Edit entries
119         $OUT = '';
120         foreach (postRequestElement('sel') as $id => $value) {
121                 // Load data
122                 $result = SQL_QUERY_ESC("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
123                         array(bigintval($id)), __FILE__, __LINE__);
124                 $content = SQL_FETCHARRAY($result);
125                 SQL_FREERESULT($result);
126
127                 // Load row template and switch color
128                 $OUT .= loadTemplate('admin_edit_email_max_rec_row', TRUE, $content);
129         } // END - foreach
130         $content['rows'] = $OUT;
131
132         // Load main template
133         loadTemplate('admin_edit_email_max_rec', FALSE, $content);
134 } else {
135         $result = SQL_QUERY("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC",
136         __FILE__, __LINE__);
137         if (!SQL_HASZERONUMS($result)) {
138                 // List already existing entries for editing
139                 $OUT = '';
140                 while ($content = SQL_FETCHARRAY($result)) {
141                         // Load row template and switch color
142                         $OUT .= loadTemplate('admin_list_email_max_rec_row', TRUE, $content);
143                 } // END - while
144
145                 // Free memory
146                 SQL_FREERESULT($result);
147                 $content['rows'] = $OUT;
148
149                 // Load main template
150                 loadTemplate('admin_list_email_max_rec', FALSE, $content);
151         } // END - if
152
153         // Display form
154         loadTemplate('admin_add_max');
155 }
156
157 // [EOF]
158 ?>