Fix user downloads in profile. The list works once again.

This commit is contained in:
Darko
2015-04-09 12:12:55 +02:00
parent 488ce49958
commit 71644436b1
3 changed files with 11 additions and 11 deletions
+7 -5
View File
@@ -1038,15 +1038,16 @@ class Users
{
$db = new DB();
$sql = sprintf("select distinct hosthash from userdownloads where userid = %d and hosthash is not null and hosthash != ''", $userid);
/*$sql = sprintf("select distinct hosthash from userdownloads where userid = %d and hosthash is not null and hosthash != ''", $userid);
$rows = $db->query($sql);
$hashsql = "";
foreach ($rows as $row)
$hashsql .= sprintf("userdownloads.hosthash = %s or ", $db->escapeString($row["hosthash"]));
$hashsql .= " 1=2 ";
*/
$sql = sprintf("select userdownloads.*, releases.guid, releases.searchname from userdownloads left outer join releases on releases.id = userdownloads.releaseid where userdownloads.userid = %d or %s order by userdownloads.timestamp desc", $userid, $hashsql);
$sql = sprintf("select userdownloads.*, releases.guid, releases.searchname from userdownloads left outer join releases on releases.id = userdownloads.releaseid where userdownloads.userid = %d order by userdownloads.timestamp desc", $userid);
return $db->query($sql);
}
@@ -1058,13 +1059,14 @@ class Users
*
* @return bool|int
*/
public function addDownloadRequest($userID)
public function addDownloadRequest($userID, $releaseID)
{
$db = new DB();
return $db->queryInsert(
sprintf(
"INSERT INTO userdownloads (userid, timestamp) VALUES (%d, NOW())",
$userID
"INSERT INTO userdownloads (userid, releaseid, timestamp) VALUES (%d, %d, NOW())",
$userID,
$releaseID
)
);
}
+2 -2
View File
@@ -66,7 +66,7 @@ if (isset($_GET["id"]) && isset($_GET["zip"]) && $_GET["zip"] == "1") {
$users->incrementGrabs($uid, count($guids));
foreach ($guids as $guid) {
$rel->updateGrab($guid);
$users->addDownloadRequest($uid);
$users->addDownloadRequest($uid, $rel['id']);
if (isset($_GET["del"]) && $_GET["del"] == 1) {
$users->delCartByUserAndRelease($guid, $uid);
@@ -95,7 +95,7 @@ if (isset($_GET["id"])) {
if ($reldata) {
$rel->updateGrab($_GET["id"]);
$users->addDownloadRequest($uid);
$users->addDownloadRequest($uid, $reldata['id']);
$users->incrementGrabs($uid);
if (isset($_GET["del"]) && $_GET["del"] == 1) {
$users->delCartByUserAndRelease($_GET["id"], $uid);
@@ -90,13 +90,12 @@
{if $userdata.role==2 && $downloadlist|@count > 0}
<div style="padding-top:20px;">
<h2>Downloads for User and Host</h2>
<h2>Downloads for User</h2>
<table style="margin-top:10px;" class="data">
<tr>
<th>date</th>
<th>hosthash</th>
<th>release</th>
</tr>
@@ -106,8 +105,7 @@
{/if}
<tr {if $download@iteration >= 10}class="extra" style="display:none;"{/if}>
<td width="80" title="{$download.timestamp}">{$download.timestamp|date_format}</td>
<td title="{$download.hosthash}">{if $download.hosthash == ""}n/a{else}{$download.hosthash|truncate:10}{/if}</td>
<td>{if $download.guid == ""}n/a{else}<a href="{$smarty.const.WWW_TOP}/details/{$download.guid}/{$download.searchname|escape:"seourl"}">{$download.searchname}</a>{/if}</td>
<td>{if $download.guid == ""}n/a{else}<a href="{$smarty.const.WWW_TOP}/details/{$download.guid}/{$download.searchname|escape:"htmlall"}">{$download.searchname}</a>{/if}</td>
</tr>
{/foreach}
</table>