* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
$result_user = SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' ORDER BY `userid` ASC", __FUNCTION__, __LINE__);
// Let's begin with the userids...
- while ($content = merge_array($content, SQL_FETCHARRAY($result_user))) {
+ while ($row = SQL_FETCHARRAY($result_user)) {
+ // Merge both arrays
+ $content = merge_array($content, $row);
+
$un = false;
// Get refs by userid
// Check if line is already included...
$result_ref = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_rallye_users` WHERE `rallye_id`=%s AND `userid`=%s LIMIT 1",
array(bigintval($id), bigintval($content['userid'])), __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result_ref) == '0') {
+ if (SQL_NUMROWS($result_ref) == 0) {
// Free memory
SQL_FREERESULT($result_ref);
} // END - switch
// Load prices
- $result_prices = SQL_QUERY("SELECT
+ $result_prices = SQL_QUERY_ESC("SELECT
`price_level`, `points`, `info`
FROM
`{?_MYSQL_PREFIX?}_rallye_prices`
WHERE
- `rallye_id`='".$rallye."'
+ `rallye_id`=%s
ORDER BY
`price_level` ASC",
- __FUNCTION__, __LINE__);
+ array($rallye), __FUNCTION__, __LINE__);
+
+ // Entries found?
if (SQL_NUMROWS($result_prices) > 0) {
// Load prices
if ($mode == "\n") $prices = "{--RALLYE_MEMBER_PRICES_ADDED--}:".$mode."------------------------------".$mode;
$prices = '';
while ($content = SQL_FETCHARRAY($result_prices)) {
- $prices .= $content['price_level'].getMessage('RALLYE_PRICE').": ";
+ $prices .= $content['price_level']. '{--RALLYE_PRICE--}: ';
if (!empty($content['info'])) {
$prices .= $content['info'];
} else {
$SW = 3 - $SW;
} // END - for
- // Translate min_prices/users
- $content['min_prices'] = determineReferalRallyeMinimumPrices($min_prices);
- $content['min_users'] = determineReferalRallyeMinimumUsers($min_users);
+ // Add min_prices/users
+ $content['min_prices'] = bigintval($min_prices);
+ $content['min_users'] = bigintval($min_users);
// Add footer
$OUT .= loadTemplate('guest_rallye_footer', true, $content);
$add = '';
// Updated extension?
- if (getExtensionVersion('rallye') >= '0.2.0') {
+ if (isExtensionInstalledAndNewer('rallye', '0.2.0')) {
$add .= ", `min_users`, `min_prices`";
} // END - if
$min_users = '0'; $min_prices = '0';
// Load data
- if (getExtensionVersion('rallye') >= '0.2.0') {
+ if (isExtensionInstalledAndNewer('rallye', '0.2.0')) {
list($id, $title, $start, $end, $notify, $min_users, $min_prices) = SQL_FETCHROW($result);
} else {
list($id, $title, $start, $end, $notify) = SQL_FETCHROW($result);
$read = substr($read, 7, strpos($read, '.') - 7);
// Accept only template names between 1 and 255 chars length
- if ((strlen($read) < 256) && (!empty($read))) $ral[] = $read;
- } // END - while
+ if ((strlen($read) < 256) && (!empty($read))) {
+ // Valid entry found!
+ $ral[$read] = $read;
+ } else {
+ // Log invalid
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("WARNING: Template %s not used.", $read));
+ }
+ } // END - foreach
// Do we have found templates which we can link with the new rallye?
if (!empty($ral[0])) {
// Generate selection box for all found templates
- // @TODO Rewrite this to our API function
- $OUT = "<select name=\"".$name."\" size=\"1\" class=\"admin_select\">
- <option value=\"\">{--SELECT_NONE--}</option>\n";
- foreach ($ral as $rallye) {
- $OUT .= " <option value=\"".$rallye."\"";
- if ($default == $rallye) $OUT .= ' selected="selected"';
- $OUT .= ">".$rallye."</option>\n";
- } // END - foreach
- $OUT .= "</select>\n";
+ $OUT = '<select name="' . $name . '" size="1" class="admin_select">';
+ $OUT .= generateOptionList('/ARRAY/', array_keys($ral), array_values($ral), $default, '', 'none');
+ $OUT .= '</select>';
} else {
// No rallye templates found
$OUT = getMessage('RALLYE_NO_TEMPLATES_FOUND');
return $OUT;
}
-//
-function getReferalRallyeRefsCount ($userid, $old = '0') {
+// @TODO Please document this function
+function getReferalRallyeRefsCount ($currUserid, $old = '0') {
// Check current refs
- if (getExtensionVersion('cache') >= '0.1.2') {
+ if (isExtensionInstalledAndNewer('cache', '0.1.2')) {
// Get refs from cache
$cnt = '0';
foreach ($GLOBALS['cache_array']['refsystem']['userid'] as $id => $userid) {
// Do we have a ref for this user?
//* DEBUG: */ print("id={$id},userid={$userid},userid={$userid},old={$old},level={$GLOBALS['cache_array']['refsystem']['level'][$id]}<br />");
- if (($userid == $userid) && ($GLOBALS['cache_array']['refsystem']['level'][$id] == 1)) {
+ if (($currUserid == $userid) && ($GLOBALS['cache_array']['refsystem']['level'][$id] == 1)) {
//* DEBUG: */ print("userid matches!<br />");
foreach ($GLOBALS['cache_array']['refdepths']['level'] as $level) {
if (($level == $GLOBALS['cache_array']['refsystem']['level'][$id]) && ($level == 1)) {
} // END - if
} else {
// Load current refs from database
- $result_ref = SQL_QUERY_ESC("SELECT SUM(s.counter) AS cnt
-FROM `{?_MYSQL_PREFIX?}_refsystem` AS s
-LEFT JOIN `{?_MYSQL_PREFIX?}_refdepths` AS d
-ON s.level=d.level
-WHERE s.userid=%s AND s.level=1", array(bigintval($userid)), __FUNCTION__, __LINE__);
+ $result_ref = SQL_QUERY_ESC("SELECT
+ SUM(s.counter) AS cnt
+FROM
+ `{?_MYSQL_PREFIX?}_refsystem` AS s
+LEFT JOIN
+ `{?_MYSQL_PREFIX?}_refdepths` AS d
+ON
+ s.level=d.level
+WHERE
+ s.userid=%s AND
+ s.level=1",
+ array(
+ bigintval($userid)
+ ), __FUNCTION__, __LINE__);
+
+ // Load count @TODO Can't we rewrite this to our API?
list($cnt) = SQL_FETCHROW($result_ref);
+
+ // Free result
SQL_FREERESULT($result_ref);
if (empty($cnt)) {
$cnt = '0';