git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

user-profile.php 3.4 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);
70
        $smarty->assign('awesomenumber', $user->id);
clint's avatar
clint committed
71

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

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

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

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