/** * Returns all information of a user given his email. * @param $id * @throws Exception * @internal param $db */ public static function getSingle($id) { self::validateId($id); return TutorFetcher::retrieveSingle($id); }
*/ require __DIR__ . '/../app/init.php'; $general->loggedOutProtect(); $pageTitle = "Personnel"; $section = "staff"; try { // protect again any sql injections on url if (isset($_GET['id']) && preg_match("/^[0-9]+\$/", $_GET['id'])) { $userId = $_GET['id']; $pageTitle = "Profile"; if (($data = User::getSingle($userId)) === false) { header('Location: ' . BASE_URL . 'error-404'); exit; } if (strcmp($data['type'], 'tutor') === 0) { $tutor = TutorFetcher::retrieveSingle($userId); $curUser = new Tutor($data['id'], $data['f_name'], $data['l_name'], $data['email'], $data['mobile'], $data['img_loc'], $data['profile_description'], $data['date'], $data['type'], $data['active'], $tutor[MajorFetcher::DB_COLUMN_NAME]); $schedules = ScheduleFetcher::retrieveCurrWorkingHours($curUser->getId()); $teachingCourses = TutorFetcher::retrieveCurrTermTeachingCourses($curUser->getId()); } else { if (strcmp($data['type'], 'secretary') === 0) { $curUser = new Secretary($data['id'], $data['f_name'], $data['l_name'], $data['email'], $data['mobile'], $data['img_loc'], $data['profile_description'], $data['date'], $data['type'], $data['active']); } else { if (strcmp($data['type'], 'admin') === 0) { $curUser = new Admin($data['id'], $data['f_name'], $data['l_name'], $data['email'], $data['mobile'], $data['img_loc'], $data['profile_description'], $data['date'], $data['type'], $data['active']); } else { throw new Exception("Something terrible has happened with the database. <br/>The software developers will tremble with fear."); } } } } else {
} // protect again any sql injections on url if (!isset($_GET['id']) || !preg_match("/^[0-9]+\$/", $_GET['id'])) { // header('Location: ' . BASE_URL . 'error-404'); exit; } else { $staffId = $_GET['id']; } try { if (($data = User::getSingle($staffId)) === false) { // header('Location: ' . BASE_URL . 'error-404'); exit; } // TODO: fix this code -- is ugly. if (strcmp($data['type'], 'tutor') === 0) { $tutor = TutorFetcher::retrieveSingle($staffId); $curUser = new Tutor($data['id'], $data['f_name'], $data['l_name'], $data['email'], $data['mobile'], $data['img_loc'], $data['profile_description'], $data['date'], $data['type'], $data['active'], $tutor[TutorFetcher::DB_COLUMN_MAJOR_ID]); } else { if (strcmp($data['type'], 'secretary') === 0) { $curUser = new Secretary($data['id'], $data['f_name'], $data['l_name'], $data['email'], $data['mobile'], $data['img_loc'], $data['profile_description'], $data['date'], $data['type'], $data['active']); } else { if (strcmp($data['type'], 'admin') === 0) { $curUser = new Admin($data['id'], $data['f_name'], $data['l_name'], $data['email'], $data['mobile'], $data['img_loc'], $data['profile_description'], $data['date'], $data['type'], $data['active']); } else { throw new Exception("Something terrible has happened with the database. <br/>The software developers will tremble with fear."); } } } // retrieve courses data only user type is tutor if ($curUser->isTutor()) { $teachingCourses = TutorFetcher::retrieveCurrTermTeachingCourses($curUser->getId());