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,22 +34,27 @@ if(!isset($_GET['user']) && $logged_in == false) {
die();
}
$user = new User(urldecode($_GET['user']));
if(isset($user->name)) {
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 {
$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);
} 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('groups', Group::groupList($user));
$smarty->assign('extra_head_links', array(
$smarty->assign('extra_head_links', array(
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
......@@ -58,9 +63,4 @@ if(isset($user->name)) {
)
));
$smarty->display('user-groups.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-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,30 +33,36 @@ 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 {
$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);
} 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');
} 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(
$smarty->assign('extra_head_links', array(
array(
'rel'=>'alternate',
'type' => 'application/rss+xml' ,
......@@ -71,13 +77,8 @@ if(isset($user->name)) {
)
));
$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