2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 04/11/2004 *
4 * =================== Last change: 08/12/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-config_payouts.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Configure payout types *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Auszahlungensarten editieren *
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('rate')) setPostRequestParameter('rate', convertCommaToDot(postRequestParameter('rate')));
50 if ((isFormSent('add')) && (isPostRequestParameterSet('title')) && (postRequestParameter('rate') > 0)) {
51 // Add new payout type
52 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE type='%s' LIMIT 1",
53 array(postRequestParameter('title')), __FILE__, __LINE__);
54 if (SQL_HASZERONUMS($result)) {
56 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_payout_types`
57 (`type`, `rate`, `min_points`, `from_account`, `from_pass`, `engine_url`, `engine_ret_ok`, `engine_ret_failed`, `pass_enc`, `allow_url`)
58 VALUES ('%s', %s, %s,'%s','%s','%s','%s','%s','%s','%s')",
60 postRequestParameter('title'),
61 bigintval(postRequestParameter('rate')),
62 bigintval(postRequestParameter('min_points')),
63 postRequestParameter('yacc'),
64 postRequestParameter('ypass'),
65 postRequestParameter('yurl'),
66 postRequestParameter('yrdone'),
67 postRequestParameter('yrfailed'),
68 postRequestParameter('ytrans'),
69 postRequestParameter('allow_url'),
70 ), __FILE__, __LINE__);
73 $message = '{--ADMIN_PAYOUT_TYPE_ADDED--}';
76 SQL_FREERESULT($result);
79 $message = '<div class="admin_failed">{--ADMIN_PAYOUT_TYPE_ALREADY--}</div>';
83 // Payout requests by your members
84 $result_mem = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `status`='NEW' ORDER BY payout_timestamp DESC", __FILE__, __LINE__);
87 if ((isFormSent('edit')) && (ifPostContainsSelections())) {
89 if ((isGetRequestParameterSet('ok')) && (getRequestParameter('ok') == 'ok')) {
94 foreach (postRequestParameter('sel') as $id => $sel) {
98 // Edit only if something is entered
99 if ((isPostRequestParameterSet('title', $id)) && (postRequestParameter('rate', $id) > 0)) {
101 addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_payout_types` SET
110 postRequestParameter('type', $id),
111 convertCommaToDot(postRequestParameter('rate', $id)),
112 convertCommaToDot(postRequestParameter('min_points' , $id)),
113 postRequestParameter('allow_url', $id),
115 ),__FILE__, __LINE__, false));
120 runFilterChain('run_sqls');
123 $message = '{--ADMIN_PAYOUT_ENTRIES_CHANGED--}';
125 $display = false; //Suppress any other outputs
127 foreach (postRequestParameter('sel') as $id => $sel) {
129 $result = SQL_QUERY_ESC("SELECT `id`, `type`, `rate`, `min_points`, `allow_url` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
130 array(bigintval($id)), __FILE__, __LINE__);
131 $content = SQL_FETCHARRAY($result);
132 SQL_FREERESULT($result);
134 // Prepare data for the row template
135 $content['allow_url'] = addSelectionBox('yn', $content['allow_url'], 'allow_url[' . $content['id'] . ']');
137 // Load row template and switch color
138 $OUT .= loadTemplate('admin_config_payouts_edit_row', true, $content);
141 // Load main template
142 loadTemplate('admin_config_payouts_edit', false, $OUT);
144 } elseif ((isFormSent('del')) && (ifPostContainsSelections())) {
145 // Delete payout types
146 if ((isGetRequestParameterSet('ok')) && (getRequestParameter('ok') == 'ok')) {
151 foreach (postRequestParameter('sel') as $id => $sel) {
152 addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
153 array(bigintval($id)), __FILE__, __LINE__, false));
157 runFilterChain('run_sqls');
160 $message = '{--ADMIN_PAYOUT_ENTRIES_DELETED--}';
162 $display = false; //Suppress any other outputs
164 foreach (postRequestParameter('sel') as $id => $sel) {
166 $id = bigintval($id);
169 $result = SQL_QUERY_ESC("SELECT `id`, `type`, `rate`, `min_points` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
170 array($id), __FILE__, __LINE__);
171 $content = SQL_FETCHARRAY($result);
172 SQL_FREERESULT($result);
174 // Load row template and switch color
175 $OUT .= loadTemplate('admin_config_payouts_del_row', true, $content);
178 // Load main template
179 loadTemplate('admin_config_payouts_del', false, $OUT);
183 if (!empty($message)) {
185 loadTemplate('admin_settings_saved', false, $message);
189 $result_type = SQL_QUERY("SELECT
190 `id`, `type`, `rate`, `min_points`, `from_account`
192 `{?_MYSQL_PREFIX?}_payout_types`
194 `type` ASC", __FILE__, __LINE__);
196 if ((!SQL_HASZERONUMS($result_type)) && ($display)) {
197 // List all payout types
199 while ($content = SQL_FETCHARRAY($result_type)) {
200 // Load row template and switch color
201 $OUT .= loadTemplate('admin_config_payouts_row', true, $content);
205 SQL_FREERESULT($result_type);
207 // Load main template
208 loadTemplate('admin_config_payouts', false, $OUT);
211 // Does your members request payouts?
212 if ((!SQL_HASZERONUMS($result_mem)) && ($display)) {
213 // Members has requested payouts
214 loadTemplate('admin_settings_saved', false, '<a href="{%url=modules.php?module=admin&what=list_payouts%}">{--ADMIN_PAYOUT_LIST_REQUESTS--}</a>');
215 } elseif ($display) {
216 // No member requests so far
217 loadTemplate('admin_settings_saved', false, '{--ADMIN_PAYOUT_NO_MEMBER_REQUESTS--}');
221 SQL_FREERESULT($result_mem);
223 // Add new payout type
224 if ($display === true) loadTemplate('admin_payout_add_new');