public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'search')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to search for students.'); } PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'StudentProfile.php'); $username = $context->get('username'); $bannerId = $context->get('bannerId'); $term = Term::getSelectedTerm(); try { if (isset($bannerId)) { $student = StudentFactory::getStudentByBannerId($bannerId, $term); } else { $student = StudentFactory::getStudentByUsername($username, $term); } } catch (InvalidArgumentException $e) { NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage()); /* $cmd = CommandFactory::getCommand('ShowStudentSearch'); $cmd->setUsername($userid); $cmd->redirect(); */ $context->goBack(); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage()); /* $cmd = CommandFactory::getCommand('ShowStudentSearch'); $cmd->setUsername($userid); $cmd->redirect(); */ $context->goBack(); } $profile = new StudentProfile($student, $term); $context->setContent($profile->getProfileView()->show()); }