We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 5a4759fd authored by P. J. McDermott's avatar P. J. McDermott

Catch Exceptions thrown by User::__construct().

In most Nixtape views, code that instantiates User objects is now
encapsulated in try...catch blocks.
parent eb108ccd
......@@ -34,33 +34,33 @@ if(!isset($_GET['user']) && $logged_in == false) {
die();
}
$user = new User(urldecode($_GET['user']));
if(isset($user->name)) {
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
try {
$aUserTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->uniqueid);
$smarty->assign('user_tagcloud',$aUserTagCloud);
} catch (exception $e) {}
$smarty->assign('isme', ($_SESSION['user']->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('profile', true);
$smarty->assign('groups', Group::groupList($user));
$smarty->assign('extra_head_links', array(
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL('groups')))
)
));
$smarty->display('user-groups.tpl');
} else {
try {
$user = new User(urldecode($_GET['user']));
} catch (Exception $e) {
$smarty->assign('pageheading', 'User not found');
$smarty->assign('details', 'Shall I call in a missing persons report?');
$smarty->display('error.tpl');
die();
}
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
try {
$aUserTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->uniqueid);
$smarty->assign('user_tagcloud',$aUserTagCloud);
} catch (exception $e) {}
$smarty->assign('isme', ($_SESSION['user']->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('profile', true);
$smarty->assign('groups', Group::groupList($user));
$smarty->assign('extra_head_links', array(
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL('groups')))
)
));
$smarty->display('user-groups.tpl');
......@@ -34,7 +34,14 @@ if(!isset($_GET['user']) && $logged_in == false) {
die();
}
$user = new User(urldecode($_GET['user']));
try {
$user = new User(urldecode($_GET['user']));
} catch (Exception $e) {
$smarty->assign('pageheading', $error);
$smarty->assign('details', 'Shall I call in a missing persons report?');
$smarty->display('error.tpl');
die();
}
if(! $user->journal_rss ) {
$smarty->assign('pageheading', 'Error!');
......
......@@ -33,51 +33,52 @@ if(!isset($_GET['user']) && $logged_in == false) {
die();
}
$user = new User(urldecode($_GET['user']));
try {
$user = new User(urldecode($_GET['user']));
} catch (Exception $e) {
$smarty->assign('pageheading', 'User not found');
$smarty->assign('details', 'Shall I call in a missing persons report?');
$smarty->display('error.tpl');
die();
}
$scrobbleCount = (int)$_GET['count'];
if ($scobbleCount >= 1200)
$scrobbleCount = 1200;
elseif (!$scrobbleCount)
$scrobbleCount = 100;
if(isset($user->name)) {
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
try {
$aUserScrobbles = $user->getScrobbles( $scrobbleCount );
$smarty->assign('scrobbles', $aUserScrobbles);
} catch (exception $e) {}
try {
$aUserTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->uniqueid);
$smarty->assign('user_tagcloud',$aUserTagCloud);
} catch (exception $e) {}
$smarty->assign('isme', ($this_user->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('profile', true);
$smarty->assign('pagetitle', $user->name . '\'s recent tracks');
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
try {
$aUserScrobbles = $user->getScrobbles( $scrobbleCount );
$smarty->assign('scrobbles', $aUserScrobbles);
} catch (exception $e) {}
try {
$aUserTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->uniqueid);
$smarty->assign('user_tagcloud',$aUserTagCloud);
} catch (exception $e) {}
$smarty->assign('isme', ($this_user->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('profile', true);
$smarty->assign('pagetitle', $user->name . '\'s recent tracks');
$smarty->assign('extra_head_links', array(
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' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL()))
)
));
$smarty->assign('extra_head_links', array(
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' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL()))
)
));
$submenu = user_menu($user, 'Recent Tracks');
$smarty->assign('submenu', $submenu);
$smarty->assign('headerfile', 'maxiprofile.tpl');
$submenu = user_menu($user, 'Recent Tracks');
$smarty->assign('submenu', $submenu);
$smarty->assign('headerfile', 'maxiprofile.tpl');
$smarty->display('user-recent-tracks.tpl');
} else {
$smarty->assign('pageheading', 'User not found');
$smarty->assign('details', 'Shall I call in a missing persons report?');
$smarty->display('error.tpl');
}
$smarty->display('user-recent-tracks.tpl');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment