user-profile.php 2.85 KB
Newer Older
tonyb486's avatar
tonyb486 committed
1 2
<?php

3
/* GNU FM -- a free network service for sharing your music listening habits
tonyb486's avatar
tonyb486 committed
4

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

   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');
require_once('data/User.php');
fauno's avatar
fauno committed
25
require_once('data/TagCloud.php');
26
require_once('data/Server.php');
tonyb486's avatar
tonyb486 committed
27

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

clint's avatar
clint committed
35
try {
36
	$user = new User(urldecode($_GET['user']));
clint's avatar
clint committed
37 38 39
} catch (exception $e) {
	$error = 'User not found';
}
fauno's avatar
fauno committed
40

41
if(isset($user->name)) {
42

43
	$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
44 45
	try {
		$aUserScrobbles = $user->getScrobbles(10);
46
		$smarty->assign('scrobbles', $aUserScrobbles);
47 48
	} catch (exception $e) {}
	try {
49 50
	$aUserNowPlaying = $user->getNowPlaying(10);
		$smarty->assign('nowplaying', $aUserNowPlaying);
51
	} catch (exception $e) {}
52
	$smarty->assign('isme', ($this_user->name == $user->name));
53
	$smarty->assign('me', $user);
54
	$smarty->assign('pagetitle', $user->name);
clint's avatar
clint committed
55

56 57 58 59 60 61 62 63
	$station = 'librefm://user/' . $user->name . '/loved';
	if(isset($this_user)) {
		        $radio_session = $this_user->getRadioSession($station);
	} else {
		        $radio_session = Server::getRadioSession($station);
	}
	$smarty->assign('radio_session', $radio_session);

tobyink's avatar
tobyink committed
64
	$smarty->assign('extra_head_links', array(
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
				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'=>'alternate',
					'type' => 'application/rss+xml' ,
					'title' => 'RSS 1.0 Feed (Journal)',
					'href' => $user->journal_rss
				     ),
				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
84

85
	$smarty->display('user-profile.tpl');
tonyb486's avatar
tonyb486 committed
86
} else {
clint's avatar
clint committed
87
	$smarty->assign('error', $error);
88 89
	$smarty->assign('details', 'Shall I call in a missing persons report?');
	$smarty->display('error.tpl');
tonyb486's avatar
tonyb486 committed
90
}
fauno's avatar
fauno committed
91

tonyb486's avatar
tonyb486 committed
92
?>