X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Flibs%2Frallye_functions.php;h=643c53f29fc691232ee75868161593de0cfa73f7;hp=796356caca854116dba09c067d42782580e5ed4c;hb=f7f6e55ee0d90558ad773ce6168767c0af816696;hpb=811c2a74188a97591fb05ed1dd3d1929b8bc23aa diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index 796356caca..643c53f29f 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -280,32 +280,44 @@ LIMIT 1", array(bigintval($uid), $_CONFIG['ref_payout'], $since), __FILE__, __LI function RALLYE_AUTOADD_USER($uid) { global $DATA; + $ADD = ""; + + // Updated extension? + if (GET_EXT_VERSION("rallye") >= "0.2.0") { + $ADD .= ", min_users, min_prices"; + } // END - if + // Check for an auto-add rallye - $result = SQL_QUERY("SELECT id, title, start_time, end_time, send_notify FROM "._MYSQL_PREFIX."_rallye_data WHERE is_active='Y' AND notified='Y' AND auto_add_new_user='Y' AND expired='N' LIMIT 1", __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + $result = SQL_QUERY("SELECT id, title, start_time, end_time, send_notify".$ADD." FROM "._MYSQL_PREFIX."_rallye_data WHERE is_active='Y' AND notified='Y' AND auto_add_new_user='Y' AND expired='N' LIMIT 1", __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 1) { + // Init variables + $min_users = 0; $min_prices = 0; // Load data - list($id, $title, $start, $end, $notify) = SQL_FETCHROW($result); + if (GET_EXT_VERSION("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); + } + + // Free result SQL_FREERESULT($result); // Check if line is already included... $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%s AND userid=%s LIMIT 1", - array(bigintval($id), bigintval($uid)), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 0) - { + array(bigintval($id), bigintval($uid)), __FILE__, __LINE__); + + // Is this user added? + if (SQL_NUMROWS($result) == 0) { // Add userid and his ref count to table $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_rallye_users (rallye_id, userid, refs) VALUES ('%s','%s','0')", array(bigintval($id), bigintval($uid)), __FILE__, __LINE__); - } - else - { + } else { // Free memory SQL_FREERESULT($result); } - if ($notify == "Y") - { + if ($notify == "Y") { // Transfer all neccessary data to the global $DATA array $DATA['start'] = MAKE_DATETIME($start, "2"); $DATA['end'] = MAKE_DATETIME($end , "2"); @@ -313,15 +325,32 @@ VALUES ('%s','%s','0')", $DATA['title'] = $title; $DATA['id'] = $id; // ID for the rallye details link $DATA['ref'] = 0; + $DATA['refs'] = GET_TOTAL_DATA($uid, "user_data", "userid", "refid", true); // Load prices $prices = RALLYE_ADD_PRICES($id); + if ($min_users == 0) { + // Rallye ends without user limitation + $DATA['min_users'] = RALLYE_END_NO_USER_LIMITATION; + } else { + // Rallye ends when X members are totally in your exchange + $DATA['min_users'] = RALLYE_END_USERS_1." ".$min_users." ".RALLYE_END_USERS_2; + } + + if ($min_prices == 0) { + // Rallye ends without user limitation + $DATA['min_prices'] = RALLYE_END_NO_PRICE_LIMITATION; + } else { + // Rallye ends when X members are totally in your exchange + $DATA['min_prices'] = RALLYE_END_PRICES_1." ".$min_prices." ".RALLYE_END_PRICES_2; + } + // Send notification to member $msg = LOAD_EMAIL_TEMPLATE("member_rallye_notify", array('prices' => $prices), $uid); SEND_EMAIL($uid, RALLYE_MEMBER_NOTIFY.$title, $msg); - } - } + } // END - if + } // END - if } // function RALLYE_EXPIRE_RALLYES($result) @@ -773,7 +802,7 @@ function RALLYE_GET_REFCOUNT($uid, $old=0) 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=0", array(bigintval($uid)), __FILE__, __LINE__); +WHERE s.userid=%s AND s.level=1", array(bigintval($uid)), __FILE__, __LINE__); list($cnt) = SQL_FETCHROW($result_ref); SQL_FREERESULT($result_ref); if (empty($cnt))