forked from pouetnet/pouet2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_watchlist.php
108 lines (88 loc) · 2.85 KB
/
user_watchlist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
require_once("bootstrap.inc.php");
class PouetBoxUserWatchlist extends PouetBox
{
public $prods;
function __construct()
{
parent::__construct();
$this->uniqueID = "pouetbox_userwatchlist";
$this->title = "your watchlist";
}
function LoadFromDB()
{
global $currentUser;
$ids = SQLLib::SelectRows(sprintf_esc("select prodID from watchlist where userID = %d",$currentUser->id));
if (!count($ids)) return;
$i = array();
foreach($ids as $v) $i[] = $v->prodID;
$sub = new SQLSelect();
$sub->AddField("max(comments.addedDate) as maxDate");
$sub->AddField("comments.which");
$sub->AddTable("comments");
$sub->AddJoin("left","prods","prods.id = comments.which");
$sub->AddGroup("comments.which");
$sub->AddWhere( sprintf_esc("prods.id in (%s)",implode(",",$i) ) );
$s = new BM_Query("prods");
$s->AddField("cmts.addedDate as lastcomment");
$s->AddField("cmts.rating as lastcommentrating");
$s->AddWhere( sprintf_esc("prods.id in (%s)",implode(",",$i) ) );
$s->AddJoin("left","(select comments.addedDate,comments.who,comments.which,comments.rating from (".$sub->GetQuery().") as dummy left join comments on dummy.maxDate = comments.addedDate and dummy.which = comments.which) as cmts","cmts.which=prods.id");
$s->attach(array("cmts"=>"who"),array("users as user"=>"id"));
$s->AddOrder("cmts.addedDate DESC");
$this->prods = $s->perform();
PouetCollectPlatforms($this->prods);
}
function RenderBody()
{
echo "\n\n";
echo "<table class='boxtable'>\n";
echo "<tr>\n";
echo " <th>name</th>\n";
echo " <th>group</th>\n";
echo " <th>platform</th>\n";
echo " <th>last comment</th>\n";
echo "</tr>\n";
foreach ($this->prods as $p)
{
echo "<tr>\n";
echo "<td>\n";
echo $p->RenderTypeIcons();
echo "<span class='prod'>".$p->RenderLink()."</span>\n";
echo "</td>\n";
echo "<td>\n";
echo $p->RenderGroupsShortProdlist();
echo "</td>\n";
echo "<td>\n";
echo $p->RenderPlatformIcons();
echo "</td>\n";
if ($p->user)
{
$rating = "isok";
if ($p->lastcommentrating < 0) $rating = "sucks";
if ($p->lastcommentrating > 0) $rating = "rulez";
echo "<td>";
echo "<span class='vote ".$rating."'>".$rating."</span> ";
echo $p->lastcomment." ".$p->user->PrintLinkedAvatar()."</td>\n";
}
else
echo "<td> </td>";
echo "</tr>\n";
}
echo "</table>\n";
}
};
$TITLE = "your watchlist";
require_once("include_pouet/header.php");
require("include_pouet/menu.inc.php");
if ($currentUser)
{
echo "<div id='content'>\n";
$box = new PouetBoxUserWatchlist();
$box->Load();
$box->Render();
echo "</div>\n";
}
require("include_pouet/menu.inc.php");
require_once("include_pouet/footer.php");
?>