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(); }
public static function execute() { PHPWS_Core::initModClass('hms', 'HMS.php'); // Copied and pasted from index.php require_once PHPWS_SOURCE_DIR . 'mod/hms/inc/defines.php'; // Copied and pasted from ExecuteLotteryCommand.php PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); HMS_Lottery::runLottery(); $now = time(); $date = date('m/d/Y H:i:s', $now); if ($_SESSION['UNSCHEDULE_LOTTERY']) { echo "Lottery has executed. The time is {$date}. Lottery asked to be unscheduled.\n"; } else { $hr = date('H', $now); $day = date('d', $now); if ($hr >= 9 && $hr < 16) { $then = strtotime("16:00:00", $now); } else { if ($hr >= 16) { $then = strtotime("+1 day 09:00:00", $now); } else { $then = strtotime("09:00:00", $now); } } $newdate = date('m/d/Y H:i:s', $then); echo "Lottery has executed. The time is {$date}. Lottery has been scheduled to run at {$newdate}.\n"; $sp = $this->makeClone(); $sp->execute_at = $then; $sp->save(); } return TRUE; }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'LotteryApplication.php'); $this->setTitle('Special Interest Group'); javascript('jquery'); $tpl = array(); $groups = HMS_Lottery::getSpecialInterestGroupsMap(); // If a group was selected if (!is_null($this->group) && $this->group != 'none') { $tpl['GROUP_PAGER'] = LotteryApplication::specialInterestPager($this->group, PHPWS_Settings::get('hms', 'lottery_term')); $tpl['GROUP'] = $groups[$this->group]; } // Show the drop down box of groups $form = new PHPWS_Form('special_interest'); $form->setMethod('get'); $form->addDropBox('group', $groups); $form->setClass('group', 'form-control'); $form->setMatch('group', $this->group); $cmd = CommandFactory::getCommand('ShowSpecialInterestGroupApproval'); $cmd->initForm($form); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'admin/special_interest_approval.tpl'); }
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(); }
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()); }
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()); }
public function getMenuBlockView(Student $student) { PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'RlcSelfSelectionMenuBlockView.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->getTerm()); $roomAssignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $this->getTerm()); $roommateRequests = HMS_Lottery::get_lottery_roommate_invites($student->getUsername(), $this->term); return new RlcSelfSelectionMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $rlcAssignment, $roomAssignment, $roommateRequests); }
public function getMenuBlockView(Student $student) { PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'ReapplicationMenuBlockView.php'); $assignment = HMS_Assignment::getAssignment($student->getUsername(), $this->term); $application = HousingApplication::getApplicationByUser($student->getUsername(), $this->term); if (!$application instanceof LotteryApplication) { $application = null; } $roommateRequests = HMS_Lottery::get_lottery_roommate_invites($student->getUsername(), $this->term); return new ReapplicationMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $assignment, $application, $roommateRequests); }
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()); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); $term = $context->get('term'); # Double check that the student is eligible if (!HMS_Lottery::determineEligibility(UserStatus::getUsername())) { NQ::simple('hms', hms\NotificationView::ERROR, 'You are not eligible to re-apply for on-campus housing for this semester.'); $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $menuCmd->redirect(); } # Check if the student has already applied. If so, redirect to the student menu $result = HousingApplication::checkForApplication(UserStatus::getUsername(), $term); if ($result !== FALSE) { NQ::simple('hms', hms\NotificationView::WARNING, 'You have already re-applied for on-campus housing for that term.'); $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $menuCmd->redirect(); } # Make sure the student agreed to the terms, if not, send them back to the terms & agreement command $event = $context->get('event'); $_SESSION['application_data'] = array(); # If they haven't agreed, redirect to the agreement if (is_null($event) || !isset($event) || $event != 'signing_complete' && $event != 'viewing_complete') { $onAgree = CommandFactory::getCommand('ShowReApplication'); $onAgree->setTerm($term); $agreementCmd = CommandFactory::getCommand('ShowTermsAgreement'); $agreementCmd->setTerm($term); $agreementCmd->setAgreedCommand($onAgree); $agreementCmd->redirect(); } $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); PHPWS_Core::initModClass('hms', 'ReApplicationFormView.php'); $view = new ReApplicationFormView($student, $term); $context->setContent($view->show()); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $roomId = $context->get('roomId'); $roommates = $context->get('roommates'); $mealPlan = $context->get('mealPlan'); $term = PHPWS_Settings::get('hms', 'lottery_term'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); $errorCmd = CommandFactory::getCommand('LotteryShowConfirm'); $errorCmd->setRoomId($roomId); $errorCmd->setRoommates($roommates); $errorCmd->setMealPlan($mealPlan); $successCmd = CommandFactory::getCommand('LotteryShowConfirmed'); $successCmd->setRoomId($roomId); PHPWS_Core::initCoreClass('Captcha.php'); $captcha = Captcha::verify(TRUE); // returns the words entered if correct, FALSE otherwise //$captcha = TRUE; if ($captcha === FALSE) { NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, the words you eneted were incorrect. Please try again.'); $errorCmd->redirect(); } PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Room.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'HMS_Util.php'); PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php'); $room = new HMS_Room($roomId); // Check for an RLC assignment in the self-select status $rlcAssignment = RlcMembershipFactory::getMembership($student, $term); // Check roommates for validity foreach ($roommates as $bed_id => $username) { // Double check the student is valid try { $roommate = StudentFactory::getStudentByUsername($username, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is not a valid student. Please choose a different roommate."); $errorCmd->redirect(); } // Make sure the bed is still empty $bed = new HMS_Bed($bed_id); if ($bed->has_vacancy() != TRUE) { NQ::simple('hms', hms\NotificationView::ERROR, 'One or more of the beds in the room you selected is no longer available. Please try again.'); $errorCmd->redirect(); } // Make sure none of the needed beds are reserved if ($bed->is_lottery_reserved()) { NQ::simple('hms', hms\NotificationView::ERROR, 'One or more of the beds in the room you selected is no longer available. Please try again.'); $errorCmd->redirect(); } // Double check the genders are all the same as the person logged in if ($student->getGender() != $roommate->getGender()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is a different gender. Please choose a roommate of the same gender."); $errorCmd->redirect(); } // Double check the genders are the same as the room (as long as the room isn't AUTO) if ($room->gender_type != AUTO && $roommate->getGender() != $room->gender_type) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is a different gender. Please choose a roommate of the same gender."); $errorCmd->redirect(); } // If this student is an RLC-self-selection, then each roommate must be in the same RLC and in the selfselect-invite state too if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { // This student is an RLC-self-select, so check the roommate's RLC status $roommateRlcAssign = RlcMembershipFactory::getMembership($roommate, $term); // Make sure the roommate is a member of the same RLC and is eligible for self-selection if ($roommateRlcAssign == null || $roommateRlcAssign->getStateName() != 'selfselect-invite' || $rlcAssignment->getRlc()->getId() != $roommateRlcAssign->getRlc()->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$roommate} must be a member of the same learning community as you, and must also be eligible for self-selction."); $errorCmd->redirect(); } // Otherwise (if not RLC members), make sure each roommate is eligible } else { if (HMS_Lottery::determineEligibility($username) !== TRUE) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is not eligible for assignment."); $errorCmd->redirect(); } } // If this student is a self-select RLC member, then this student must also be a self-select RLC member of the same RLC if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { $roommateRlcAssign = RlcMembershipFactory::getMembership($roommate, $term); if ($roommateRlcAssign == null || $roommateRlcAssign->getStateName() != 'selfselect-invite' || $rlcAssignment->getRlc()->getId() != $roommateRlcAssign->getRlc()->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} must be a member of the same learning community as you, and must also be eligible for self-selction."); $errorCmd->redirect(); } } } // If the room's gender is 'AUTO' and no one is assigned to it yet, switch it to the student's gender if ($room->gender_type == AUTO && $room->get_number_of_assignees() == 0) { $room->gender_type = $student->getGender(); $room->save(); } // Assign the student to the requested bed $bed_id = array_search(UserStatus::getUsername(), $roommates); // Find the bed id of the student who's logged in try { $result = HMS_Assignment::assignStudent($student, PHPWS_Settings::get('hms', 'lottery_term'), NULL, $bed_id, $mealPlan, 'Confirmed lottery invite', TRUE, ASSIGN_LOTTERY); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error creating your room assignment. Please try again or contact University Housing.'); $errorCmd->redirect(); } // Log the assignment HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ROOM_CHOSEN, UserStatus::getUsername(), 'Captcha: ' . $captcha); // Update the student's meal plan in the housing application, just for future reference $app = HousingApplication::getApplicationByUser($student->getUsername(), $term); $app->setMealPlan($mealPlan); $app->save(); // If this student was an RLC self-select, update the RLC memberhsip state if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment)); } foreach ($roommates as $bed_id => $username) { // Skip the current user if ($username == $student->getUsername()) { continue; } # Reserve the bed for the roommate $expires_on = time() + INVITE_TTL_HRS * 3600; $bed = new HMS_Bed($bed_id); if (!$bed->lottery_reserve($username, $student->getUsername(), $expires_on)) { NQ::smiple('hms', hms\NotificationView::WARNING, "You were assigned, but there was a problem reserving space for your roommates. Please contact University Housing."); $successCmd->redirect(); } HMS_Activity_Log::log_activity($username, ACTIVITY_LOTTERY_REQUESTED_AS_ROOMMATE, $student->getUsername(), 'Expires: ' . HMS_Util::get_long_date_time($expires_on)); # Invite the selected roommates $roomie = StudentFactory::getStudentByUsername($username, $term); $term = PHPWS_Settings::get('hms', 'lottery_term'); $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term)); HMS_Email::send_lottery_roommate_invite($roomie, $student, $expires_on, $room->where_am_i(), $year); } HMS_Email::send_lottery_assignment_confirmation($student, $room->where_am_i(), $term); $successCmd->redirect(); }
public function show() { $term = Term::getSelectedTerm(); $db = new PHPWS_DB('hms_residence_hall'); $db->addWhere('is_online', '1'); $db->addWhere('term', $term); $num_online = $db->select('count'); unset($db); $db = new PHPWS_DB('hms_residence_hall'); $db->addWhere('is_online', '0'); $db->addWhere('term', $term); $num_offline = $db->select('count'); unset($db); $db = new PHPWS_DB('hms_learning_communities'); $num_lcs = $db->select('count'); unset($db); $db = new PHPWS_DB('hms_assignment'); $db->addWhere('term', $term); $num_assigned = $db->select('count'); unset($db); $db = new PHPWS_DB('hms_new_application'); $db->addWhere('term', $term); $db->addWhere('student_type', TYPE_FRESHMEN); $num_f_applications = $db->select('count'); unset($db); $db = new PHPWS_DB('hms_new_application'); $db->addWhere('term', $term); $db->addWhere('student_type', TYPE_TRANSFER); $num_t_applications = $db->select('count'); unset($db); $db = new PHPWS_DB('hms_learning_community_applications'); $db->addWhere('term', $term); $num_rlc_applications = $db->select('count'); unset($db); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); $lottery_term = PHPWS_Settings::get('hms', 'lottery_term'); $db = new PHPWS_DB('hms_lottery_entry'); $db->addWhere('term', $lottery_term); $num_lottery_entries = $db->select('count'); unset($db); $db = new PHPWS_DB('hms_assignment'); $db->addWhere('term', $lottery_term); $db->addWhere('lottery', 1); $num_lottery_assigned = $db->select('count'); $tpl = array(); $tpl['TITLE'] = "HMS Overview - {$term}"; $tpl['NUM_LCS'] = $num_lcs; $tpl['NUM_ONLINE'] = $num_online; $tpl['NUM_OFFLINE'] = $num_offline; $tpl['NUM_ASSIGNED'] = $num_assigned; $tpl['NUM_F_APPLICATIONS'] = $num_f_applications; $tpl['NUM_T_APPLICATIONS'] = $num_t_applications; $tpl['NUM_RLC_APPLICATIONS'] = $num_rlc_applications; PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); $lottery_term = PHPWS_Settings::get('hms', 'lottery_term'); $tpl['LOTTERY_APPLICATIONS'] = $num_lottery_entries; $tpl['SOPH_APPLICATIONS'] = HMS_Lottery::count_applications_by_class($lottery_term, CLASS_SOPHOMORE); $tpl['JR_APPLICATIONS'] = HMS_Lottery::count_applications_by_class($lottery_term, CLASS_JUNIOR); $tpl['SR_APPLICATIONS'] = HMS_Lottery::count_applications_by_class($lottery_term, CLASS_SENIOR); $tpl['LOTTERY_ASSIGNED'] = $num_lottery_assigned; $tpl['SOPH_ASSIGNED'] = HMS_Lottery::count_assignments_by_class($lottery_term, CLASS_SOPHOMORE); $tpl['JR_ASSIGNED'] = HMS_Lottery::count_assignments_by_class($lottery_term, CLASS_JUNIOR); $tpl['SR_ASSIGNED'] = HMS_Lottery::count_assignments_by_class($lottery_term, CLASS_SENIOR); $tpl['SOPH_ENTRIES_REMAIN'] = HMS_Lottery::count_remaining_entries_by_class($lottery_term, CLASS_SOPHOMORE); $tpl['JR_ENTRIES_REMAIN'] = HMS_Lottery::count_remaining_entries_by_class($lottery_term, CLASS_JUNIOR); $tpl['SR_ENTRIES_REMAIN'] = HMS_Lottery::count_remaining_entries_by_class($lottery_term, CLASS_SENIOR); $tpl['OUTSTANDING_INVITES'] = HMS_Lottery::count_outstanding_invites($lottery_term, MALE) + HMS_Lottery::count_outstanding_invites($lottery_term, FEMALE); $tpl['SOPH_OUTSTANDING'] = HMS_Lottery::count_outstanding_invites_by_class($lottery_term, CLASS_SOPHOMORE); $tpl['JR_OUTSTANDING'] = HMS_Lottery::count_outstanding_invites_by_class($lottery_term, CLASS_JUNIOR); $tpl['SR_OUTSTANDING'] = HMS_Lottery::count_outstanding_invites_by_class($lottery_term, CLASS_SENIOR); $tpl['ROOMMATE_INVITES'] = HMS_Lottery::count_outstanding_roommate_invites($lottery_term); $tpl['REMAINING_ENTRIES'] = HMS_Lottery::count_remaining_entries($lottery_term); $tpl['SOPH_INVITES'] = HMS_Lottery::count_invites_by_class($lottery_term, CLASS_SOPHOMORE); $tpl['JR_INVITES'] = HMS_Lottery::count_invites_by_class($lottery_term, CLASS_JUNIOR); $tpl['SR_INVITES'] = HMS_Lottery::count_invites_by_class($lottery_term, CLASS_SENIOR); $final = PHPWS_Template::process($tpl, 'hms', 'admin/statistics.tpl'); Layout::addPageTitle("Statistics"); return $final; }
public function show() { $tpl = array(); $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate); $tpl['STATUS'] = ""; $hardCapReached = LotteryProcess::hardCapReached($this->term); if (!is_null($this->assignment)) { // Student has already been assigned. $tpl['ICON'] = FEATURE_COMPLETED_ICON; //$tpl['ASSIGNED'] = $this->assignment->where_am_i(); $tpl['ASSIGNED'] = ''; } else { if ($hardCapReached) { // Hard cap has been reached $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['HARD_CAP'] = ""; // dummy tag } else { if (!is_null($this->application) && $this->application->isWinner()) { // Student has won, let them choose their room $tpl['ICON'] = FEATURE_OPEN_ICON; $chooseRoomCmd = CommandFactory::getCommand('LotteryShowChooseHall'); $tpl['SELECT_LINK'] = $chooseRoomCmd->getLink('Click here to select your room'); } else { if (!is_null($this->application)) { // Student has already re-applied $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['ALREADY_APPLIED'] = ""; // dummy tag, text is in template } else { if (time() < $this->startDate) { // Too early $tpl['ICON'] = FEATURE_NOTYET_ICON; $tpl['BEGIN_DEADLINE'] = HMS_Util::getFriendlyDate($this->startDate); } else { if (time() > $this->endDate) { // Too late $tpl['ICON'] = FEATURE_LOCKED_ICON; // fade out header $tpl['STATUS'] = "locked"; $tpl['END_DEADLINE'] = HMS_Util::getFriendlyDate($this->endDate); } else { if (HMS_Lottery::determineEligibility(UserStatus::getUsername())) { $tpl['ICON'] = FEATURE_OPEN_ICON; $reAppCommand = CommandFactory::getCommand('ShowReApplication'); $reAppCommand->setTerm($this->term); $tpl['ELIGIBLE'] = ""; //dummy tag, text is in template $tpl['LOTTERY_TERM_1'] = Term::toString($this->term); $tpl['NEXT_TERM_1'] = Term::toString(Term::getNextTerm($this->term)); $tpl['ENTRY_LINK'] = $reAppCommand->getLink('Click here to re-apply.'); } else { $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['NOT_ELIGIBLE'] = ""; //dummy tag, text is in template $tpl['LOTTERY_TERM_2'] = Term::toString($this->term); $tpl['NEXT_TERM_2'] = Term::toString(Term::getNextTerm($this->term)); } } } } } } } if (!$hardCapReached && time() > $this->startDate) { if ($this->roommateRequests != FALSE && !is_null($this->roommateRequests) && $this->assignment != TRUE && !PEAR::isError($this->assignment)) { $tpl['roommates'] = array(); $tpl['ROOMMATE_REQUEST'] = ''; // dummy tag foreach ($this->roommateRequests as $invite) { $cmd = CommandFactory::getCommand('LotteryShowRoommateRequest'); $cmd->setRequestId($invite['id']); $roommie = StudentFactory::getStudentByUsername($invite['requestor'], $this->term); $tpl['roommates'][]['ROOMMATE_LINK'] = $cmd->getLink($roommie->getName()); //$tpl['roommates'][]['ROOMMATE_LINK'] = PHPWS_Text::secureLink(HMS_SOAP::get_name($invite['requestor']), 'hms', array('type'=>'student', 'op'=>'lottery_show_roommate_request', 'id'=>$invite['id'])); } } } return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/reApplicationMenuBlock.tpl'); }
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; }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'add_rlc_members')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to view RLC members.'); } PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'RlcApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php'); // Get the selected term $term = Term::getSelectedTerm(); // Get the request community $communityId = $context->get('communityId'); if (!isset($communityId) || $communityId == '') { throw new InvalidArgumentException('Missing community id.'); } $community = new HMS_Learning_Community($communityId); // Get banner ID list and make sure it has content $bannerIds = $context->get('banner_id_list'); if (!isset($bannerIds) || $bannerIds == '') { $errorCmd = CommandFactory::getCommand('ShowAdminAddRlcMember'); $errorCmd->setCommunity($community); $errorCmd->redirect(); } // Break up string into an array of individual ids $bannerIds = explode("\n", $bannerIds); foreach ($bannerIds as $banner) { // Clean up the banner id $banner = trim($banner); // Skip blank lines if ($banner == '') { continue; } // Get the student try { $student = StudentFactory::getStudentByBannerId($banner, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "Couldn't find a student with ID: {$e->getRequestedId()}"); continue; } catch (InvalidArgumentException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "This doesn't look like a banner ID: {$banner}"); continue; } // Check for an existing housing application $housingApp = HousingApplicationFactory::getAppByStudent($student, $term); // If no housing app, show a warning if (is_null($housingApp)) { NQ::simple('hms', hms\NotificationView::WARNING, "No housing application found for: {$student->getName()}({$student->getBannerID()})"); } // Check for an existing learning community application $rlcApp = RlcApplicationFactory::getApplication($student, $term); if ($rlcApp == null) { // Create a new learning community application $rlcApp = new HMS_RLC_Application(); $rlcApp->setUsername($student->getUsername()); $rlcApp->setDateSubmitted(time()); $rlcApp->setFirstChoice($community->getId()); $rlcApp->setSecondChoice(null); $rlcApp->setThirdChoice(null); $rlcApp->setWhySpecificCommunities('Application created administratively.'); $rlcApp->setStrengthsWeaknesses(''); $rlcApp->setRLCQuestion0(null); $rlcApp->setRLCQuestion1(null); $rlcApp->setRLCQuestion2(null); $rlcApp->setEntryTerm($term); if ($student->getType() == TYPE_CONTINUING) { $rlcApp->setApplicationType(RLC_APP_RETURNING); } else { $rlcApp->setApplicationType(RLC_APP_FRESHMEN); } $rlcApp->save(); } else { // Reset the application's denial flag, see #1026 $rlcApp->setDenied(0); $rlcApp->save(); // RLC application already exists NQ::simple('hms', hms\NotificationView::WARNING, "RLC application already exists for {$student->getName()}({$student->getBannerID()})"); } // Check for RLC membership $membership = RlcMembershipFactory::getMembership($student, $term); if ($membership !== false) { NQ::simple('hms', hms\NotificationView::ERROR, "RLC membership already exists for {$student->getName()}({$student->getBannerID()})"); continue; } // Check Student's Eligibility $eligibility = HMS_Lottery::determineEligibility($student->getUsername()); if ($eligibility == false) { NQ::simple('hms', hms\NotificationView::ERROR, "{$student->getName()} ({$student->getBannerID()}) is not currently eligible for housing"); continue; } // Create RLC Membership $membership = new HMS_RLC_Assignment(); $membership->rlc_id = $community->getId(); $membership->gender = $student->getGender(); $membership->assigned_by = UserStatus::getUsername(); $membership->application_id = $rlcApp->id; $membership->state = 'new'; $membership->save(); } $successCmd = CommandFactory::getCommand('ShowViewByRlc'); $successCmd->setRlcId($community->getId()); $successCmd->redirect(); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'LotteryApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); // TODO Use the HousingApplicationFactory class to get all this data $term = $context->get('term'); # Double check that the student is eligible if (!HMS_Lottery::determineEligibility(UserStatus::getUsername())) { NQ::simple('hms', hms\NotificationView::ERROR, 'You are not eligible to re-apply for on-campus housing for this semester.'); $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $menuCmd->redirect(); } $errorCmd = CommandFactory::getCommand('ShowReApplication'); $errorCmd->setTerm($term); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Data sanity checking $doNotCall = $context->get('do_not_call'); $number = $context->get('number'); if (is_null($doNotCall)) { // do not call checkbox was not selected, so check the number if (is_null($number)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please provide a cell-phone number or click the checkbox stating that you do not wish to share your number with us.'); $errorCmd->redirect(); } } if (!is_null($doNotCall)) { $cellPhone = null; } else { $cellPhone = $number; } $mealPlan = $context->get('meal_plan'); $specialNeeds = $context->get('special_needs'); $physicalDisability = isset($specialNeeds['physical_disability']) ? 1 : 0; $psychDisability = isset($specialNeeds['psych_disability']) ? 1 : 0; $genderNeed = isset($specialNeeds['gender_need']) ? 1 : 0; $medicalNeed = isset($specialNeeds['medical_need']) ? 1 : 0; /** * Special interest housing groups */ // Sororities - If they checked the box, and their pref is APH, // then record her sorority choice $sororityCheck = $context->get('sorority_check'); if (isset($sororityCheck) && $context->get('sorority_pref') == 'aph') { $sororityPref = $context->get('sorority_drop'); } else { $sororityPref = null; } // Teaching Fellows, Watauga Global, and Honors //$tfPref = ($context->get('tf_pref') == 'with_tf')?1:0; $wgPref = $context->get('wg_pref') == 'with_wg' ? 1 : 0; $honorsPref = $context->get('honors_pref') == 'with_honors' ? 1 : 0; // Learning Community Interest $rlcInterest = $context->get('rlc_interest'); $rlcInterest = isset($rlcInterest) ? 1 : 0; // Contract early release $earlyRelease = $context->get('early_release'); if ($earlyRelease == 'no') { $earlyRelease = NULL; } // International $international = $student->isInternational(); $magicWinner = 0; // The student's type should always be 'C' (continuing), // even if thes student began in the Spring. $studentType = 'C'; /************************** * Emergency Contact Info * */ $application = new LotteryApplication(0, $term, $student->getBannerId(), $student->getUsername(), $student->getGender(), $studentType, $student->getApplicationTerm(), $cellPhone, $mealPlan, $physicalDisability, $psychDisability, $genderNeed, $medicalNeed, $international, NULL, $magicWinner, $sororityPref, $wgPref, $honorsPref, $rlcInterest, $earlyRelease); $application->setEmergencyContactName($context->get('emergency_contact_name')); $application->setEmergencyContactRelationship($context->get('emergency_contact_relationship')); $application->setEmergencyContactPhone($context->get('emergency_contact_phone')); $application->setEmergencyContactEmail($context->get('emergency_contact_email')); $application->setEmergencyMedicalCondition($context->get('emergency_medical_condition')); $application->setMissingPersonName($context->get('missing_person_name')); $application->setMissingPersonRelationship($context->get('missing_person_relationship')); $application->setMissingPersonPhone($context->get('missing_person_phone')); $application->setMissingPersonEmail($context->get('missing_person_email')); try { $application->save(); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error saving your re-application. Please try again or contact the Department of University Housing.'); $errorCmd->redirect(); } // Log the fact that the entry was saved HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ENTRY, UserStatus::getUsername()); // Send email confirmation PHPWS_Core::initModClass('hms', 'HMS_Email.php'); $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term)); HMS_Email::send_lottery_application_confirmation($student, $year); // Show success message NQ::simple('hms', hms\NotificationView::SUCCESS, 'Your re-application was submitted successfully.'); // Redirect to the RLC Reapplication form is the student is interested in RLCs, otherwise, show the student menu if ($rlcInterest == 1) { $cmd = CommandFactory::getCommand('ShowRlcReapplication'); $cmd->setTerm($term); } else { $cmd = CommandFactory::getCommand('ShowStudentMenu'); } $cmd->redirect(); }