user-recent-tracks.php 2.78 KB
Newer Older
1 2
<?php

3
/* GNU FM -- a free network service for sharing your music listening habits
4

5
   Copyright (C) 2009 Free Software Foundation, Inc
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

require_once('database.php');
require_once('templating.php');
Mike Sheldon's avatar
Mike Sheldon committed
24
require_once('user-menu.php');
25 26 27 28 29
require_once('data/User.php');
require_once('data/TagCloud.php');
require_once('data/Server.php');

if(!isset($_GET['user']) && $logged_in == false) {
30
	$smarty->assign('pageheading', 'Error!');
31 32 33 34 35
	$smarty->assign('details', 'User not set! You shouldn\'t be here!');
	$smarty->display('error.tpl');
	die();
}

36 37 38 39 40 41 42 43 44
try {
	$user = new User(urldecode($_GET['user']));
} catch (Exception $e) {
	$smarty->assign('pageheading', 'User not found');
	$smarty->assign('details', 'Shall I call in a missing persons report?');
	$smarty->display('error.tpl');
	die();
}

tobyink's avatar
tobyink committed
45
$scrobbleCount = (int)$_GET['count'];
46 47 48
if ($scobbleCount >= 1200)
	$scrobbleCount = 1200;
elseif (!$scrobbleCount)
tobyink's avatar
tobyink committed
49
	$scrobbleCount = 100;
50

51 52 53 54 55 56 57 58 59 60 61 62 63
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
try {
	$aUserScrobbles = $user->getScrobbles( $scrobbleCount );
	$smarty->assign('scrobbles', $aUserScrobbles);
} catch (exception $e) {}
try {
$aUserTagCloud =  TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->uniqueid);
	$smarty->assign('user_tagcloud',$aUserTagCloud);
} catch (exception $e) {}
$smarty->assign('isme', ($this_user->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('profile', true);
$smarty->assign('pagetitle', $user->name . '\'s recent tracks');
64

65 66 67 68 69 70 71 72 73 74 75 76 77 78
$smarty->assign('extra_head_links', array(
		array(
			'rel'=>'alternate',
			'type' => 'application/rss+xml' ,
			'title' => 'RSS 1.0 Feed (Recent plays)',
			'href' => $base_url.'/rdf.php?fmt=rss&page='.urlencode(str_replace($base_url, '', $user->getURL('recent-tracks')))
			),
		array(
			'rel' => 'meta',
			'type' => 'application/rdf+xml' ,
			'title' => 'FOAF',
			'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL()))
			)
	));
clint's avatar
clint committed
79

80 81 82
$submenu = user_menu($user, 'Recent Tracks');
$smarty->assign('submenu', $submenu);
$smarty->assign('headerfile', 'maxiprofile.tpl');
83

84
$smarty->display('user-recent-tracks.tpl');