2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 06/30/2011 *
4 * =================== Last change: 06/30/2011 *
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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
46 // Remove empty array index
47 if (!isPostRequestElementSet('max')) {
48 unsetPostRequestElement('add_max');
51 if (isPostRequestElementSet('add_max')) {
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--}';
61 // Value does alread exists!
62 $content = '<span class="notice">{--ADMIN_MAX_VALUE_ALREADY--}</span>';
66 SQL_FREERESULT($result);
69 displayMessage($content);
70 } elseif ((isFormSent()) && (isGetRequestElementSet('do'))) {
71 // Change or delete entries...
73 foreach (postRequestElement('id') as $id => $value) {
77 switch (postRequestElement('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",
81 bigintval(postRequestElement('val', $id)),
82 postRequestElement('comm', $id),
84 ),__FILE__, __LINE__);
85 $TEXT = '{--ADMIN_MAX_RECEIVE_SAVED--}';
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--}';
98 displayMessage($TEXT);
100 } elseif ((isFormSent('delete')) && (ifPostContainsSelections())) {
103 foreach (postRequestElement('sel') as $id => $value) {
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);
110 // Load row template and switch color
111 $OUT .= loadTemplate('admin_delete_email_max_rec_row', true, $content);
113 $content['rows'] = $OUT;
115 // Load main template
116 loadTemplate('admin_delete_email_max_rec', false, $content);
117 } elseif ((isFormSent('edit')) && (ifPostContainsSelections())) {
120 foreach (postRequestElement('sel') as $id => $value) {
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);
127 // Load row template and switch color
128 $OUT .= loadTemplate('admin_edit_email_max_rec_row', true, $content);
130 $content['rows'] = $OUT;
132 // Load main template
133 loadTemplate('admin_edit_email_max_rec', false, $content);
135 $result = SQL_QUERY("SELECT `id`,`value`,`comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC",
137 if (!SQL_HASZERONUMS($result)) {
138 // List already existing entries for editing
140 while ($content = SQL_FETCHARRAY($result)) {
141 // Load row template and switch color
142 $OUT .= loadTemplate('admin_list_email_max_rec_row', true, $content);
146 SQL_FREERESULT($result);
147 $content['rows'] = $OUT;
149 // Load main template
150 loadTemplate('admin_list_email_max_rec', false, $content);
154 loadTemplate('admin_add_max');