2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 02/17/2005 *
4 * =================== Last change: 02/17/2005 *
6 * -------------------------------------------------------------------- *
7 * File : doubler_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Functions for the guest's newsletter *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Funktionen fuer den Newsletter an die Gaeste *
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')) {
44 // Generates a HTML table based on given data
45 // @TODO Lame description
46 function generateDoublerTable ($userid = '0', $done = 'N', $ref = 'N', $sort = 'ASC') {
47 if (empty($cnt)) $cnt = '0';
48 $add = ''; $DT_MODE = '0';
50 // Load entries only from a single user
51 $add = sprintf(" AND `userid`=%s", bigintval($userid));
52 $mode = 'member'; $COLS = 4; $DT_MODE = 2;
53 $message = getMessage('DOUBLER_MEMBER_NO_ENTRIES_FOUND');
56 $mode = 'guest'; $COLS = 3; $DT_MODE = 3;
57 $message = getMessage('DOUBLER_GUEST_NO_ENTRIES_FOUND');
60 if (($done == 'Y') && ($sort == 'ASC')) {
61 // Already payed out points (latest payouts first)
62 $limit = getConfig('doubler_display_old');
63 } elseif ($sort == 'ASC') {
64 // List entries which will receive their payout soon
65 $limit = getConfig('doubler_display_pay');
66 } elseif ($sort == 'DESC') {
68 $limit = getConfig('doubler_display_new');
72 $result = SQL_QUERY("SELECT
73 `userid`, `refid`, `points`, `timemark`
75 `{?_MYSQL_PREFIX?}_doubler`
77 `completed`='".$done."' AND `is_ref`='".$ref."'".$add."
80 LIMIT ".$limit, __FUNCTION__, __LINE__);
82 if (SQL_NUMROWS($result) > 0) {
85 while ($content = SQL_FETCHARRAY($result)) {
86 // Rewrite userid/refid only if admin is in
88 // Set links to admin area
89 if ($content['userid'] > 0) { $content['userid'] = generateUserProfileLink($content['userid']); } else { $content['userid'] = '---'; }
90 if ($content['refid'] > 0) { $content['refid'] = generateUserProfileLink($content['refid']); } else { $content['refid'] = '---'; }
93 // Prepare data for the row template
95 'userid' => $content['userid'],
96 'rid' => $content['refid'],
97 'points' => translateComma($content['points']),
98 'timemark' => generateDateTime($content['timemark'], $DT_MODE),
102 // Load template and switch color
103 $OUT .= loadTemplate($mode . '_doubler_list_rows', true, $content);
108 SQL_FREERESULT($result);
112 <td colspan=\"".$COLS."\" align=\"center\" class=\"doubler_big_row bottom\">
113 ".loadTemplate('admin_settings_saved', true, $message)."
119 return loadTemplate($mode . '_doubler_list', true, $OUT);
123 function DOUBLER_GET_TOTAL_POINTS_LEFT() {
124 // Initialize variables
127 if (getConfig('doubler_own') == 'Y') {
128 // Take points from doubler's own account
129 $points += getConfig('doubler_points') - getConfig('doubler_used');
132 if ((getConfig('doubler_jackpot') == 'Y') && (isExtensionActive('jackpot'))) {
134 $jackpot = getJackpotPoints();
136 if (!empty($jackpot)) $points += $jackpot;
139 if (getConfig('doubler_userid') > 0) {
141 $user = countSumTotalData(getConfig('doubler_userid'), 'user_points', 'points');