2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/12/2003 *
4 * =================== Last change: 12/12/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-config_points.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Setup welcome-points for registration etc. *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Einstellen der Willkommensgutschrift usw. *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2012 by Mailer Developer Team *
20 * For more information visit: http://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__);
49 // Is the 'sub' parameter set?
50 if (isGetRequestElementSet('sub')) {
51 // Yes, then do some sanity-checks
52 switch (getRequestElement('sub')) {
54 if ((!isPostRequestElementSet('points_register')) || (!isPostRequestElementSet('points_ref'))) {
55 unsetPostRequestElement('ok');
61 setGetRequestElement('sub', 'overview');
65 if ((isFormSent('do_delete')) || (isFormSent('do_edit')) || (isFormSent('do_add')) || (isFormSent('save_config'))) {
68 switch (getRequestElement('sub')) {
70 adminSaveSettingsFromPostData();
74 $REF = bigintval(postRequestElement('ref_payout'));
76 array('allow_direct_pay', 'ref_payout'),
77 array(postRequestElement('allow_direct_pay'), $REF)
79 if ((getRefPayout() == '0') && (postRequestElement('ref_payout') > 0)) {
80 // Update account's ref_payout for "must-confirm"
81 addSql(sprintf("UPDATE
82 `{?_MYSQL_PREFIX?}_user_data`
84 `ref_payout`=(%s - `mails_confirmed`)
86 `mails_confirmed` < %s", $REF, $REF));
87 } elseif ((getRefPayout() > 0) && (postRequestElement('ref_payout') == '0')) {
88 // Update account's ref_payout for "not-must-confirm"
89 addSql("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_payout`=0 WHERE `ref_payout` > 0");
90 // @TODO Rewrite these two lines for new user_points columns (e.g. locked_order_points) with a filter
91 addSql("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `points`=`points`+`locked_points` WHERE `locked_points` > 0");
92 addSql("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `locked_points`=0 WHERE `locked_points` > 0");
98 if ((getRequestElement('sub') != 'points') && (isSqlsValid())) {
99 // Default is failed-message
100 $message = '<span class="bad">{--SETTINGS_NOT_SAVED--}</span>';
102 if (countSqls() > 0) {
103 // Run all SQL commands
104 runFilterChain('run_sqls');
107 $message = '{--SETTINGS_SAVED--}';
109 // Destroy config cache file here...
110 rebuildCache('config', 'config');
113 // Remove SQL queries
117 // Shall we display a message?
118 if (!empty($message)) {
120 displayMessage($message);
122 } elseif (getRequestElement('sub') == 'settings') {
123 // Setup some settings like direct pay and so on
124 // Including new add-mode for one-time referral bonus
125 foreach (array('allow_direct_pay') as $entry) {
126 $content[$entry . '_y'] = '';
127 $content[$entry . '_n'] = '';
128 $content[$entry . '_' . strtolower(getConfig($entry))] = ' checked="checked"';
132 loadTemplate('admin_config_point_settings', FALSE, $content);
133 } elseif (getRequestElement('sub') == 'points') {
135 loadTemplate('admin_config_sub_points');
137 // Display selection box
138 loadTemplate('admin_config_points');