]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-config_payouts.php
- Rewrites to use more the userid than the actual email address when sending
[mailer.git] / inc / modules / admin / what-config_payouts.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 04/11/2004 *
4  * ===================                          Last change: 08/12/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-config_payouts.php                          *
8  * -------------------------------------------------------------------- *
9  * Short description : Configure payout types                           *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Auszahlungensarten editieren                     *
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 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.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 // Convert 'rate' if set
47 if (isPostRequestParameterSet('rate')) {
48         convertCommaToDotInPostData('rate');
49 } // END - if
50
51 if ((isFormSent('add')) && (isPostRequestParameterSet('title')) && (postRequestParameter('rate') > 0)) {
52         // Add new payout type
53         $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE type='%s' LIMIT 1",
54                 array(postRequestParameter('title')), __FILE__, __LINE__);
55         if (SQL_HASZERONUMS($result)) {
56                 // Add now
57                 SQL_QUERY_ESC("INSERT INTO
58         `{?_MYSQL_PREFIX?}_payout_types`
59 (
60         `type`, `rate`, `min_points`, `from_account`, `from_pass`, `engine_url`, `engine_ret_ok`, `engine_ret_failed`, `pass_enc`, `allow_url`
61 ) VALUES (
62         '%s', %s, %s,'%s','%s','%s','%s','%s','%s','%s'
63 )",
64                 array(
65                         postRequestParameter('title'),
66                         bigintval(postRequestParameter('rate')),
67                         bigintval(postRequestParameter('min_points')),
68                         postRequestParameter('yacc'),
69                         postRequestParameter('ypass'),
70                         postRequestParameter('yurl'),
71                         postRequestParameter('yrdone'),
72                         postRequestParameter('yrfailed'),
73                         postRequestParameter('ytrans'),
74                         postRequestParameter('allow_url'),
75                 ), __FILE__, __LINE__);
76
77                 // Get message
78                 $message = '{--ADMIN_PAYOUT_TYPE_ADDED--}';
79         } else {
80                 // Free memory
81                 SQL_FREERESULT($result);
82
83                 // Does already exist
84                 $message = '<div class="notice">{--ADMIN_PAYOUT_TYPE_ALREADY--}</div>';
85         }
86 }
87
88 // Payout requests by your members
89 $result_mem = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `status`='NEW' ORDER BY payout_timestamp DESC", __FILE__, __LINE__);
90
91 $display = true;
92 if ((isFormSent('edit')) && (ifPostContainsSelections())) {
93         // Make payouts configurable
94         $display = false; //Suppress any other outputs
95         $OUT = '';
96         foreach (postRequestParameter('sel') as $id => $sel) {
97                 // Load data
98                 $result = SQL_QUERY_ESC("SELECT `id`, `type`, `rate`, `min_points`, `allow_url` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
99                         array(bigintval($id)), __FILE__, __LINE__);
100                 $content = SQL_FETCHARRAY($result);
101                 SQL_FREERESULT($result);
102
103                 // Prepare data for the row template
104                 $content['allow_url'] = addSelectionBox('yn', $content['allow_url'], 'allow_url[' . $content['id'] . ']');
105
106                 // Load row template and switch color
107                 $OUT .= loadTemplate('admin_edit_payouts_row', true, $content);
108         } // END - foreach
109
110         // Load main template
111         loadTemplate('admin_edit_payouts', false, $OUT);
112 } elseif ((isFormSent('do_edit')) && (ifPostContainsSelections())) {
113         // Change them now
114         // Init SQLs
115         initSqls();
116
117         // Edit entries
118         foreach (postRequestParameter('sel') as $id => $sel) {
119                 // Secure id
120                 $id = bigintval($id);
121
122                 // Edit only if something is entered
123                 if ((isPostRequestParameterSet('title', $id)) && (postRequestParameter('rate', $id) > 0)) {
124                         // Update entry
125                         addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_payout_types` SET
126         `type`='%s',
127         `rate`=%s,
128         `min_points`=%s,
129         `allow_url`='%s'
130 WHERE
131         `id`=%s
132 LIMIT 1",
133                         array(
134                                 postRequestParameter('type', $id),
135                                 convertCommaToDot(postRequestParameter('rate', $id)),
136                                 convertCommaToDot(postRequestParameter('min_points' , $id)),
137                                 postRequestParameter('allow_url', $id),
138                                 bigintval($id)
139                         ),__FILE__, __LINE__, false));
140                 }
141         }
142
143         // Run all SQLs
144         runFilterChain('run_sqls');
145
146         // Get message
147         $message = '{--ADMIN_PAYOUT_ENTRIES_CHANGED--}';
148 } elseif ((isFormSent('delete')) && (ifPostContainsSelections())) {
149         $display = false; //Suppress any other outputs
150         $OUT = '';
151         foreach (postRequestParameter('sel') as $id => $sel) {
152                 // Secure id number
153                 $id = bigintval($id);
154
155                 // Load data
156                 $result = SQL_QUERY_ESC("SELECT `id`, `type`, `rate`, `min_points` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
157                         array($id), __FILE__, __LINE__);
158                 $content = SQL_FETCHARRAY($result);
159                 SQL_FREERESULT($result);
160
161                 // Load row template and switch color
162                 $OUT .= loadTemplate('admin_delete_payouts_row', true, $content);
163         } // END - foreach
164
165         // Load main template
166         loadTemplate('admin_delete_payouts', false, $OUT);
167 } elseif ((isFormSent('do_delete')) && (ifPostContainsSelections())) {
168         // Init SQLs
169         initSqls();
170
171         // Delete entries
172         foreach (postRequestParameter('sel') as $id => $sel) {
173                 addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
174                         array(bigintval($id)), __FILE__, __LINE__, false));
175         } // END - foreach
176
177         // Run all SQLs
178         runFilterChain('run_sqls');
179
180         // Get message
181         $message = '{--ADMIN_PAYOUT_ENTRIES_DELETED--}';
182 }
183
184 if (!empty($message)) {
185         // Output message
186         displayMessage($message);
187 } // END - if
188
189 // Payout types
190 $result_type = SQL_QUERY("SELECT
191         `id`, `type`, `rate`, `min_points`, `from_account`
192 FROM
193         `{?_MYSQL_PREFIX?}_payout_types`
194 ORDER BY
195         `type` ASC", __FILE__, __LINE__);
196
197 if ((!SQL_HASZERONUMS($result_type)) && ($display)) {
198         // List all payout types
199         $OUT = '';
200         while ($content = SQL_FETCHARRAY($result_type)) {
201                 // Load row template and switch color
202                 $OUT .= loadTemplate('admin_config_payouts_row', true, $content);
203         } // END - while
204
205         // Free memory
206         SQL_FREERESULT($result_type);
207
208         // Load main template
209         loadTemplate('admin_config_payouts', false, $OUT);
210 } // END - if
211
212 // Does your members request payouts?
213 if ((!SQL_HASZERONUMS($result_mem)) && ($display === true)) {
214         // Members has requested payouts
215         displayMessage('<a href="{%url=modules.php?module=admin&amp;what=list_payouts%}">{--ADMIN_PAYOUT_LIST_REQUESTS--}</a>');
216 } elseif ($display === true) {
217         // No member requests so far
218         displayMessage('{--ADMIN_PAYOUT_NO_MEMBER_REQUESTS--}');
219 }
220
221 // Free result
222 SQL_FREERESULT($result_mem);
223
224 // Add new payout type
225 if ($display === true) {
226         loadTemplate('admin_payout_add_new');
227 } // END - if
228
229 // [EOF]
230 ?>