2 /************************************************************************
3 * MXChange v0.2.1 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 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
47 if (((!isPostRequestElementSet(('t_wait'))) || (!isPostRequestElementSet(('payment')))) && (isGetRequestElementSet('do')) && (getRequestElement('do') == 'add')) {
48 unsetPostRequestElement('ok');
52 switch (getRequestElement('do')) {
54 addSql("INSERT INTO `{?_MYSQL_PREFIX?}_payments` (time, payment, mail_title, price) VALUES ('".postRequestElement('t_wait')."','".postRequestElement('payment')."','".postRequestElement('title')."','".postRequestElement('price')."')");
55 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_payments` WHERE time='%s' LIMIT 1",
56 array(postRequestElement('t_wait')), __FILE__, __LINE__);
57 if (SQL_NUMROWS($result) == 1) {
58 // Re-init the array here
62 SQL_FREERESULT($result);
67 foreach (postRequestElement('time') as $id => $value) {
68 addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET time='".$value."', payment='".postRequestElement('pay', $id)."', price='".postRequestElement('price', $id)."', mail_title='".postRequestElement('title', $id)."' WHERE `id`='".$id."' LIMIT 1");
73 foreach (postRequestElement('id') as $id => $value) {
74 addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`='".$id."' LIMIT 1");
80 if (countSqls() > 0) {
82 runFilterChain('run_sqls');
83 $content = "<span class=\"admin_failed\">".SETTINGS_SAVED."</span>";
85 // Nothing has changed!
86 $content = "<span class=\"admin_failed\">{--SETTINGS_NOT_SAVED--}</span>";
90 loadTemplate('admin_settings_saved', false, $content);
91 } elseif ((isPostRequestElementSet('del')) && (countPostSelection() > 0)) {
92 // Delete entries here
94 foreach (postRequestElement('sel') as $id => $value) {
95 $result = SQL_QUERY_ESC("SELECT time, mail_title FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
96 array(bigintval($id)), __FILE__, __LINE__);
97 list($time, $title) = SQL_FETCHROW($result);
98 SQL_FREERESULT($result);
100 // Prepare array for the row template
108 // Load row template and switch colors
109 $OUT .= loadTemplate('admin_del_payments_row', true, $content);
113 // Load main template
114 loadTemplate('admin_del_payments', false, $OUT);
115 } elseif ((isPostRequestElementSet('edit')) && (countPostSelection() > 0)) {
118 foreach (postRequestElement('sel') as $id => $value) {
119 $result = SQL_QUERY_ESC("SELECT time, payment, mail_title, price FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
120 array(bigintval($id)), __FILE__, __LINE__);
121 list($time, $pay, $title, $price) = SQL_FETCHROW($result);
122 SQL_FREERESULT($result);
124 // Prepare array for the row template
134 // Load row template and switch colors
135 $OUT .= loadTemplate('admin_edit_payments_row', true, $content);
139 // Load main template
140 loadTemplate('admin_edit_payments', false, $OUT);
143 $result = SQL_QUERY("SELECT id, time, payment, mail_title, price FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY time", __FILE__, __LINE__);
144 if (SQL_NUMROWS($result) > 0) {
145 // Make referal levels editable and deletable
148 // List already existing categories for editing
149 while ($content = SQL_FETCHARRAY($result)) {
150 // Prepare array for the row template
151 // @TODO Rewritings: title->mail_title, pay->payment in template
154 'id' => $content['id'],
155 'time' => $content['time'],
156 'title' => $content['mail_title'],
157 'pay' => translateComma($content['payment']),
158 'price' => translateComma($content['price'])
161 // Load row template and switch colors
162 $OUT .= loadTemplate('admin_payments_list_row', true, $content);
167 SQL_FREERESULT($result);
169 // Load main template
170 loadTemplate('admin_list_payments', false, $OUT);
173 // Form for adding new referal levels
174 loadTemplate('admin_add_payment');