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

   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');
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');
29

30
if (!isset($_GET['user']) && $logged_in == false) {
31
	displayError("Error", "User not set. You shouldn't be here.");
32 33
}

clint's avatar
clint committed
34
try {
35 36 37 38 39
	if(strstr($_GET['user'], '@')) {
		$user = new RemoteUser($_GET['user']);
	} else {
		$user = new User($_GET['user']);
	}
40
} catch (Exception $e) {
41
	$user = null;
clint's avatar
clint committed
42
}
fauno's avatar
fauno committed
43

44
if (isset($user->name)) {
45

46
	$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
47 48
	try {
		$aUserScrobbles = $user->getScrobbles(10);
49
		$smarty->assign('scrobbles', $aUserScrobbles);
50
	} catch (Exception $e) {}
51
	try {
52
		$aUserNowPlaying = $user->getNowPlaying(10);
53
		$smarty->assign('nowplaying', $aUserNowPlaying);
54 55
	} catch (Exception $e) {}
	if ($user->hasLoved()) {
56 57
		$recommendedArtists = $user->getRecommended(10);
		$smarty->assign('recommendedArtists', $recommendedArtists);
58 59 60 61 62 63 64 65
		if($user->remote) {
			// Just get the 10 most recently loved artists from a remote user
			$lovedArtists = $user->getLovedArtists(10);
			$smarty->assign('lovedArtists', $lovedArtists);
		} else {
			$lovedArtists = TagCloud::generateTagCloud('loved', 'artist', 10, 'userid', $user->uniqueid);
			$smarty->assign('lovedArtists', $lovedArtists);
		}
66
	}
67
	$smarty->assign('isme', ($this_user->name == $user->name));
68
	$smarty->assign('me', $user);
69
	$smarty->assign('pagetitle', $user->name);
clint's avatar
clint committed
70

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

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

98
	$submenu = user_menu($user, 'Overview');
Mike Sheldon's avatar
Mike Sheldon committed
99 100
	$smarty->assign('submenu', $submenu);

101
	$smarty->display('user-profile.tpl');
102
} else {
Jonas Haraldsson's avatar
Jonas Haraldsson committed
103
	displayError("User not found", "User not found, shall I call in a missing persons report?");
104
}