public function execute(CommandContext $context) { $currentTerm = Term::getCurrentTerm(); $username = UserStatus::getUsername(); # Create a contact form command, redirect to it in case of error. $contactCmd = CommandFactory::getCommand('ShowContactForm'); //TODO add try catch blocks here for StudentNotFound exception $student = StudentFactory::getStudentByUsername($username, $currentTerm); $applicationTerm = $student->getApplicationTerm(); // In case this is a new freshmen, they'll likely have no student type in the "current" term. // So, instead, we need to lookup the student in their application term. if ($applicationTerm > $currentTerm) { $student = StudentFactory::getStudentByUsername($username, $applicationTerm); } $studentType = $student->getType(); $studentClass = $student->getClass(); $dob = $student->getDob(); # Check for banner errors in any of these calls if (empty($applicationTerm) || empty($studentType) || empty($studentClass) || empty($dob) || is_null($dob)) { # TODO: HMS_Mail here PHPWS_Error::log('Initial banner lookup failed', 'hms', 'show_welcome_screen', "username: "******"too early" message if (!Term::isValidTerm($applicationTerm)) { PHPWS_Core::initModClass('hms', 'WelcomeScreenViewInvalidTerm.php'); $view = new WelcomeScreenViewInvalidTerm($applicationTerm, $contactCmd); $context->setContent($view->show()); return; } # Make sure the student doesn't already have an assignment on file for the current term if (HMS_Assignment::checkForAssignment($username, $currentTerm)) { # No idea what's going on here, send to a contact page $contactCmd->redirect(); } # Check to see if the user has an application on file already for every required term # If so, forward to main menu $requiredTerms = HousingApplication::checkAppliedForAllRequiredTerms($student); if (count($requiredTerms) > 0) { # Student is missing a required application, so redirect to the application form for that term $appCmd = CommandFactory::getCommand('ShowHousingApplicationWelcome'); $appCmd->setTerm($requiredTerms[0]); $appCmd->redirect(); } else { $menuCmd = CommandFactory::getCommand('ShowFreshmenMainMenu'); $menuCmd->redirect(); } } } }