user-profile.php 3.34 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

   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');
Mike Sheldon's avatar
Mike Sheldon committed
23
require_once('user-menu.php');
tonyb486's avatar
tonyb486 committed
24 25
require_once('templating.php');
require_once('data/User.php');
26
require_once('data/RemoteUser.php');
fauno's avatar
fauno committed
27
require_once('data/TagCloud.php');
28
require_once('data/Server.php');
tonyb486's avatar
tonyb486 committed
29

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

clint's avatar
clint committed
37
try {
38 39 40 41 42
	if(strstr($_GET['user'], '@')) {
		$user = new RemoteUser($_GET['user']);
	} else {
		$user = new User($_GET['user']);
	}
43
} catch (Exception $e) {
clint's avatar
clint committed
44 45
	$error = 'User not found';
}
fauno's avatar
fauno committed
46

47
if (isset($user->name)) {
48

49
	$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
50 51
	try {
		$aUserScrobbles = $user->getScrobbles(10);
52
		$smarty->assign('scrobbles', $aUserScrobbles);
53
	} catch (Exception $e) {}
54
	try {
Mike Sheldon's avatar
Mike Sheldon committed
55
		$aUserNowPlaying = $user->getNowPlaying(10);
56
		$smarty->assign('nowplaying', $aUserNowPlaying);
57 58
	} catch (Exception $e) {}
	if ($user->hasLoved()) {
59 60
		$recommendedArtists = $user->getRecommended(10);
		$smarty->assign('recommendedArtists', $recommendedArtists);
61
		$lovedArtists = TagCloud::generateTagCloud('loved', 'artist', 10, 'userid', $user->uniqueid);
62
		$smarty->assign('lovedArtists', $lovedArtists);
63
	}
64
	$smarty->assign('isme', ($this_user->name == $user->name));
65
	$smarty->assign('me', $user);
66
	$smarty->assign('pagetitle', $user->name);
clint's avatar
clint committed
67

tobyink's avatar
tobyink committed
68
	$smarty->assign('extra_head_links', array(
69
				array(
70 71
					'rel'   => 'alternate',
					'type'  => 'application/rss+xml',
72
					'title' => 'RSS 1.0 Feed (Recent plays)',
Clint Adams's avatar
Clint Adams committed
73
					'href'  => $base_url . '/rdf.php?fmt=rss&page=' . rawurlencode(str_replace($base_url, '', $user->getURL('recent-tracks')))
74
					),
75
				array(
76 77
					'rel'   => 'alternate',
					'type'  => 'application/rss+xml',
78
					'title' => 'RSS 1.0 Feed (Journal)',
79
					'href'  => $user->journal_rss
80
					),
81
				array(
82 83
					'rel'   => 'meta',
					'type'  => 'application/rdf+xml',
84
					'title' => 'FOAF',
Clint Adams's avatar
Clint Adams committed
85
					'href'  => $base_url . '/rdf.php?fmt=xml&page=' . rawurlencode(str_replace($base_url, '', $user->getURL()))
86
					)
87
				));
clint's avatar
clint committed
88

89
	$neighbours = $user->getNeighbours(9);
90
	if (!empty($neighbours)) {
91 92 93
		$smarty->assign('neighbours', $neighbours);
		$smarty->assign('sideblocks', array('sidebar-neighbours.tpl'));
	}
Mike Sheldon's avatar
Mike Sheldon committed
94

95
	$submenu = user_menu($user, 'Overview');
Mike Sheldon's avatar
Mike Sheldon committed
96
	$smarty->assign('submenu', $submenu);
Mike Sheldon's avatar
Mike Sheldon committed
97
	$smarty->assign('headerfile', 'maxiprofile.tpl');
Mike Sheldon's avatar
Mike Sheldon committed
98

99
	$smarty->display('user-profile.tpl');
tonyb486's avatar
tonyb486 committed
100
} else {
101
	$smarty->assign('pageheading', $error);
102 103
	$smarty->assign('details', 'Shall I call in a missing persons report?');
	$smarty->display('error.tpl');
tonyb486's avatar
tonyb486 committed
104
}