2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/19/2003 *
4 * =================== Last change: 12/12/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-payments.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Payments (points) for confirmed mails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Verguetungen fuer bestätigte Mails *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
38 ************************************************************************/
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
48 if (((!isPostRequestParameterSet(('t_wait'))) || (!isPostRequestParameterSet(('payment')))) && (isGetRequestParameterSet('do')) && (getRequestParameter('do') == 'add')) {
49 unsetPostRequestParameter('ok');
53 switch (getRequestParameter('do')) {
55 addSql("INSERT INTO `{?_MYSQL_PREFIX?}_payments` (time, payment, mail_title, price) VALUES ('".postRequestParameter('t_wait')."','".postRequestParameter('payment')."','".postRequestParameter('title')."','".postRequestParameter('price')."')");
56 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_payments` WHERE time='%s' LIMIT 1",
57 array(postRequestParameter('t_wait')), __FILE__, __LINE__);
58 if (SQL_NUMROWS($result) == 1) {
59 // Re-init the array here
63 SQL_FREERESULT($result);
68 foreach (postRequestParameter('time') as $id => $value) {
69 addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET `time`='" . $value . "', `payment`='".postRequestParameter('pay', $id)."', price='".postRequestParameter('price', $id)."', mail_title='".postRequestParameter('title', $id)."' WHERE `id`='".$id."' LIMIT 1");
74 foreach (postRequestParameter('id') as $id => $value) {
75 addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=" . bigintval($id) . " LIMIT 1");
81 if (countSqls() > 0) {
83 runFilterChain('run_sqls');
84 $content = '<span class="admin_failed">{--SETTINGS_SAVED--}</span>';
86 // Nothing has changed!
87 $content = '<span class="admin_failed">{--SETTINGS_NOT_SAVED--}</span>';
91 loadTemplate('admin_settings_saved', false, $content);
92 } elseif ((isFormSent('del')) && (countPostSelection() > 0)) {
93 // Delete entries here
95 foreach (postRequestParameter('sel') as $id => $value) {
96 $result = SQL_QUERY_ESC("SELECT time, mail_title FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
97 array(bigintval($id)), __FILE__, __LINE__);
98 list($time, $title) = SQL_FETCHROW($result);
99 SQL_FREERESULT($result);
101 // Prepare array for the row template
109 // Load row template and switch colors
110 $OUT .= loadTemplate('admin_del_payments_row', true, $content);
114 // Load main template
115 loadTemplate('admin_del_payments', false, $OUT);
116 } elseif ((isFormSent('edit')) && (countPostSelection() > 0)) {
119 foreach (postRequestParameter('sel') as $id => $value) {
120 $result = SQL_QUERY_ESC("SELECT time, payment, mail_title, price FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
121 array(bigintval($id)), __FILE__, __LINE__);
122 list($time, $pay, $title, $price) = SQL_FETCHROW($result);
123 SQL_FREERESULT($result);
125 // Prepare array for the row template
135 // Load row template and switch colors
136 $OUT .= loadTemplate('admin_edit_payments_row', true, $content);
140 // Load main template
141 loadTemplate('admin_edit_payments', false, $OUT);
144 $result = SQL_QUERY("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `time` ASC", __FILE__, __LINE__);
145 if (SQL_NUMROWS($result) > 0) {
146 // Make referal levels editable and deletable
149 // List already existing categories for editing
150 while ($content = SQL_FETCHARRAY($result)) {
151 // Prepare array for the row template
152 // @TODO Rewritings: title->mail_title, pay->payment in template
155 'id' => $content['id'],
156 'time' => $content['time'],
157 'title' => $content['mail_title'],
158 'pay' => translateComma($content['payment']),
159 'price' => translateComma($content['price'])
162 // Load row template and switch colors
163 $OUT .= loadTemplate('admin_payments_list_row', true, $content);
168 SQL_FREERESULT($result);
170 // Load main template
171 loadTemplate('admin_list_payments', false, $OUT);
174 // Form for adding new referal levels
175 loadTemplate('admin_add_payment');