コード例 #1
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     $requestId = $context->get('requestId');
     $errorCmd = CommandFactory::getCommand('LotteryShowDenyRoommateRequest');
     $errorCmd->setRequestId($requestId);
     # Confirm the captcha
     PHPWS_Core::initCoreClass('Captcha.php');
     $captcha = Captcha::verify(TRUE);
     if ($captcha === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'The words you entered were incorrect. Please try again.');
         $errorCmd->redirect();
     }
     # Get the roommate request
     $request = HMS_Lottery::get_lottery_roommate_invite_by_id($context->get('requestId'));
     # Make sure that the logged in user is the same as the confirming the request
     if (UserStatus::getUsername() != $request['asu_username']) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid roommate request. You can not confirm that roommate request.');
         $errorCmd->redirect();
     }
     # Deny the roommate requst
     try {
         HMS_Lottery::denyRoommateRequest($requestId);
     } catch (Exception $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error denying the roommate request. Please contact University Housing.');
         $errorCmd->redirect();
     }
     # Log that it happened
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ROOMMATE_DENIED, UserStatus::getUsername(), 'Captcha words: ' . $captcha);
     # Success
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'The roommate request was successfully declined.');
     $successCmd = CommandFactory::getCommand('ShowStudentMenu');
     $successCmd->redirect();
 }
コード例 #2
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php');
     $requestId = $context->get('requestId');
     $mealPlan = $context->get('mealPlan');
     $errorCmd = CommandFactory::getCommand('LotteryShowConfirmRoommateRequest');
     $errorCmd->setRequestId($requestId);
     $errorCmd->setMealPlan($mealPlan);
     // Confirm the captcha
     PHPWS_Core::initCoreClass('Captcha.php');
     $captcha = Captcha::verify(TRUE);
     if ($captcha === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'The words you entered were incorrect. Please try again.');
         $errorCmd->redirect();
     }
     // Check for a meal plan
     if (!isset($mealPlan) || $mealPlan == '') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a meal plan.');
         $errorCmd->redirect();
     }
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Update the meal plan field on the application
     $app = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term);
     $app->setMealPlan($mealPlan);
     try {
         $app->save();
     } catch (Exception $e) {
         PHPWS_Error::log('hms', $e->getMessage());
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.');
         $errorCmd->redirect();
     }
     // Try to actually make the assignment
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     try {
         HMS_Lottery::confirm_roommate_request(UserStatus::getUsername(), $requestId, $mealPlan);
     } catch (Exception $e) {
         PHPWS_Error::log('hms', $e->getMessage());
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.');
         $errorCmd->redirect();
     }
     # Log the fact that the roommate was accepted and successfully assigned
     HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_CONFIRMED_ROOMMATE, UserStatus::getUsername(), "Captcha: \"{$captcha}\"");
     // Check for an RLC membership and update status if necessary
     // If this student was an RLC self-select, update the RLC memberhsip state
     $rlcAssignment = RlcMembershipFactory::getMembership($student, $term);
     if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') {
         $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment));
     }
     $invite = HMS_Lottery::get_lottery_roommate_invite_by_id($requestId);
     $successCmd = CommandFactory::getCommand('LotteryShowConfirmedRoommateThanks');
     $successCmd->setRequestId($requestId);
     $successCmd->redirect();
 }
コード例 #3
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'LotteryDenyRoommateRequestView.php');
     $request = HMS_Lottery::get_lottery_roommate_invite_by_id($context->get('requestId'));
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $view = new LotteryDenyRoommateRequestView($request, $term);
     $context->setContent($view->show());
 }
コード例 #4
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'LotteryConfirmedRoommateThanksView.php');
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     $invite = HMS_Lottery::get_lottery_roommate_invite_by_id($context->get('requestId'));
     $bed = new HMS_Bed($invite['bed_id']);
     $view = new LotteryConfirmedRoommateThanksView($invite, $bed);
     $context->setContent($view->show());
 }
コード例 #5
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'LotteryRoommateRequestView.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     $request = HMS_Lottery::get_lottery_roommate_invite_by_id($context->get('requestId'));
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $housingApp = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term);
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Check for a self-select RLC membership for the logged-in student
     $rlcAssign = RlcMembershipFactory::getMembership($student, $term);
     if ($rlcAssign == false) {
         $rlcAssign = null;
     }
     $view = new LotteryRoommateRequestView($request, $term, $housingApp, $rlcAssign);
     $context->setContent($view->show());
 }
コード例 #6
0
ファイル: HMS_Lottery.php プロジェクト: jlbooker/homestead
 public static function confirm_roommate_request($username, $requestId, $meal_plan)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     // Get the roommate invite
     $invite = HMS_Lottery::get_lottery_roommate_invite_by_id($requestId);
     // If the invite wasn't found, show an error
     if ($invite === false) {
         return E_LOTTERY_ROOMMATE_INVITE_NOT_FOUND;
     }
     // Check that the reserved bed is still empty
     $bed = new HMS_Bed($invite['bed_id']);
     if (!$bed->has_vacancy()) {
         return E_ASSIGN_BED_NOT_EMPTY;
     }
     // Make sure the student isn't assigned anywhere else
     if (HMS_Assignment::checkForAssignment($username, $term)) {
         return E_ASSIGN_ALREADY_ASSIGNED;
     }
     $student = StudentFactory::getStudentByUsername($username, $term);
     $requestor = StudentFactory::getStudentByUsername($invite['requestor'], $term);
     // Actually make the assignment
     HMS_Assignment::assignStudent($student, $term, null, $invite['bed_id'], $meal_plan, 'Confirmed roommate invite', true, ASSIGN_LOTTERY);
     // return successfully
     HMS_Email::send_roommate_confirmation($student, $requestor);
     return E_SUCCESS;
 }