user-profile.php 3.15 KB
Newer Older
tonyb486's avatar
tonyb486 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?php

/* Libre.fm -- a free network service for sharing your music listening habits

   Copyright (C) 2009 Libre.fm Project

   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 35
	die();
}

$user = new User($_GET['user']);
fauno's avatar
fauno committed
36

37
if(isset($user->name)) {
tobyink's avatar
tobyink committed
38 39
	$smarty->assign("id", $user->id);
	$smarty->assign("acctid", $user->acctid);
40 41 42 43 44
	$smarty->assign('user', $user->name);
	$smarty->assign('email', $user->email);
	$smarty->assign('fullname', $user->fullname);
	$smarty->assign('bio', $user->bio);
	$smarty->assign('homepage', $user->homepage);
45
	$smarty->assign('journal_rss', $user->journal_rss);
tobyink's avatar
tobyink committed
46 47
	$smarty->assign('laconica_profile', $user->laconica_profile);
	$smarty->assign('has_identica', $user->has_identica);
48
	$smarty->assign('location', $user->location);
49
	$smarty->assign('location_uri', $user->location_uri);
50
	$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
51 52 53 54
	$aUserScrobbles = $user->getScrobbles(20);
	if (!PEAR::isError ($aUserScrobbles)) {
		$smarty->assign('scrobbles', $aUserScrobbles);
	}
55
	$smarty->assign('userlevel', $user->userlevel);
56
	$smarty->assign('avatar', $user->getAvatar());
57 58 59 60 61 62 63 64
	$aUserNowPlaying = $user->getNowPlaying(10);
	if (!PEAR::isError ($aUserNowPlaying)) {
		$smarty->assign('nowplaying', $aUserNowPlaying);
	}
	$aUserTagCloud =  TagCloud::GenerateTagCloud('Scrobbles', 'artist', 40, $user->name);
	if (!PEAR::isError ($aUserTagCloud)) {
		$smarty->assign('user_tagcloud',$aUserTagCloud);
	}
tobyink's avatar
tobyink committed
65
	$smarty->assign('isme', ($_SESSION['user']->name == $user->name));
tonyb486's avatar
tonyb486 committed
66
	$smarty->assign('profile', true);
tobyink's avatar
tobyink committed
67 68 69 70 71 72
	
	$smarty->assign('extra_head_links', array(
			array(
				'rel'=>'alternate',
				'type' => 'application/rss+xml' ,
				'title' => 'RSS 1.0 Feed (Recent plays)',
73
				'href' => $base_url.'/rdf.php?fmt=rss&page='.htmlentities($_SERVER['REQUEST_URI'])
tobyink's avatar
tobyink committed
74 75 76 77 78
				),
			array(
				'rel' => 'meta',
				'type' => 'application/rdf+xml' ,
				'title' => 'FOAF',
79
				'href' => $base_url.'/rdf.php?fmt=xml&page='.htmlentities($_SERVER['REQUEST_URI'])
tobyink's avatar
tobyink committed
80 81
				)
		));
clint's avatar
clint committed
82

clint's avatar
er  
clint committed
83
	$smarty->assign('toptracks', $user->getTopTracks());
tobyink's avatar
tobyink committed
84
	
85
	$smarty->display('user-profile.tpl');
tonyb486's avatar
tonyb486 committed
86
} else {
87 88 89
	$smarty->assign('error', 'User not found');
	$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
?>