We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit b5c2efa8 authored by clint's avatar clint

try nowplaying on profile page

parent e7b21e8d
......@@ -67,7 +67,7 @@ class User {
global $mdb2;
$res = $mdb2->query('SELECT * FROM Scrobbles WHERE username = ' .$mdb2->quote($this->name, 'text') . ' ORDER BY time DESC LIMIT '.$mdb2->quote($number, 'integer'));
$data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
foreach($data as &$i) {
foreach($data as &$i) {
$i = sanitize($i);
$i['timehuman'] = human_timestamp($i['time']);
}
......@@ -84,5 +84,23 @@ class User {
return "http://www.gravatar.com/avatar/" . md5($this->email) . "?s=" . $size . "&d=monsterid";
}
/**
* Get a user's now-playing tracks
*
* @return An array of nowplaying data
*/
function getNP() {
global $mdb2;
$res = $mdb2->query('SELECT username, artist, track, client,
ClientCodes.name, ClientCodes.url from Now_Playing LEFT OUTER JOIN Scrobble_Sessions ON Now_Playing.sessionid=Scrobble_Sessions.sessionid LEFT OUTER JOIN ClientCodes ON Scrobble_Sessions.client=ClientCodes.code WHERE username=' . $mdb->quote($this->name, 'text');
$data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
foreach($data as &$i) {
$i = sanitize($i);
}
return $data;
}
}
......@@ -41,6 +41,7 @@ if(isset($user->name)) {
$smarty->assign('scrobbles', $user->getScrobbles(20));
$smarty->assign('userlevel', $user->userlevel);
$smarty->assign('avatar', $user->getAvatar());
$smarty->assign('nowplaying', $user->getNP());
$smarty->display('profile.tpl');
} else {
$smarty->assign('error', 'User not found');
......
......@@ -20,6 +20,15 @@
<p>{$bio}</p>
</dd>
</dl>
{if $smarty.nowplaying|@count > 0}
<h3>Now Playing:</h3>
<ul>
{section name=i loop=$nowplaying}
<li>{$nowplaying[i].track} by {$nowplaying[i].artist} with {$nowplaying[i].client}</li>
{/section}
</ul>
{/if}
<h3>Latest {$scrobbles|@count} Gobbles:</h3>
{section name=i loop=$scrobbles}
{if $smarty.capture.artist_last <> $scrobbles[i].artist}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment