$top_unique_ids = null; $dal = new DAL($opts['hn'], $opts['db'], $opts['un'], $opts['pw']); try { $dal->beginTransaction(); $user = $dal->selectUser(); if (isset($_GET['pending'])) { $filter = 'Pending'; $top_unique_ids = $dal->selectUnapprovedUniqueIds(); } else { if (isset($_GET['person_id'])) { $person = $dal->selectPersonById($_GET['person_id']); if ($person === null) { throw new UserException('Profile not found.'); } $filter = formatPersonName($person); $top_unique_ids = $dal->selectUniqueIdsByPerdonId($_GET['person_id']); } else { $top = true; $top_unique_ids = $dal->selectTopUniqueIds(); } } $dal->commit(); } catch (UserException $e) { $dal->rollback(); $error = $e->getMessage(); } catch (Exception $e) { $dal->rollback(); throw $e; } if (empty($top_unique_ids)) { $message = 'None found.';