public function execute(CommandContext $context) { /* if(!Current_User::allow('hms', 'email_hall') && !Current_User::allow('hms', 'email_all')){ PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to send messages.'); } */ if (is_null($context->get('hall')) && is_null($context->get('floor'))) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must select a hall to continue!'); $cmd = CommandFactory::getCommand('ShowHallNotificationSelect'); $cmd->redirect(); } $subject = $context->get('subject'); $body = $context->get('body'); $anonymous = !is_null($context->get('anonymous')) ? $context->get('anonymous') : false; $halls = $context->get('hall'); $floors = $context->get('floor'); $cmd = CommandFactory::getCommand('ShowHallNotificationEdit'); if (empty($subject)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must fill in the subject line of the email.'); $cmd->loadContext($context); $cmd->redirect(); } else { if (empty($body)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must fill in the message to be sent.'); $cmd->loadContext($context); $cmd->redirect(); } } $view = new ReviewHallNotificationMessageView($subject, $body, $anonymous, $halls, $floors); $context->setContent($view->show()); }
public function show() { $username = UserStatus::getUsername(); $currentTerm = Term::getCurrentTerm(); $student = StudentFactory::getStudentByUsername($username, $currentTerm); $applicationTerm = $student->getApplicationTerm(); $tpl = array(); $tpl['TITLE'] = 'Contact Form'; $form = new PHPWS_Form(); $form->addText('name'); $form->setLabel('name', 'Name'); $form->addText('email'); $form->setLabel('email', 'Email Address'); $form->addText('phone'); $form->setLabel('phone', 'Phone number'); $form->addDropBox('stype', array('F' => 'New Freshmen', 'T' => 'Transfer', 'C' => 'Returning')); $form->setLabel('stype', 'Classification'); $form->addTextArea('comments'); $form->setLabel('comments', 'Question, Comments, or Description of the Problem'); $form->addSubmit('Submit'); $form->mergeTemplate($tpl); $cmd = CommandFactory::getCommand('SubmitContactForm'); $cmd->setUsername($username); $cmd->setApplicationTerm($applicationTerm); $cmd->setStudentType($student->getType()); $cmd->initForm($form); $tpl = $form->getTemplate(); //var_dump($tpl);exit; return PHPWS_Template::process($tpl, 'hms', 'student/contact_page.tpl'); }
public function execute(CommandContext $context) { $term = $context->get('term'); if (!isset($term) || is_null($term) || empty($term)) { throw new InvalidArgumentException('Missing term.'); } $cmd = CommandFactory::getCommand('ShowStudentMenu'); $feature = ApplicationFeature::getInstanceByNameAndTerm('RlcApplication', $term); // Make sure the RLC application feature is enabled if (is_null($feature) || !$feature->isEnabled()) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, RLC applications are not avaialable for this term."); $cmd->redirect(); } // Check feature's deadlines if ($feature->getStartDate() > time()) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, it is too soon to fill out an RLC application."); $cmd->redirect(); } else { if ($feature->getEndDate() < time()) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, the RLC application deadline has already passed. Please contact University Housing if you are interested in applying for a RLC."); $cmd->redirect(); } } // Get the Student object $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), Term::getCurrentTerm()); $view = new RlcApplicationPage1View($context, $student); $context->setContent($view->show()); }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Util.php'); $tpl = array(); $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate); $tpl['STATUS'] = ""; if (!is_null($this->application) && $this->application->getApplicationType() == 'offcampus_waiting_list') { $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['ALREADY_APPLIED'] = ""; } else { if (time() < $this->startDate) { $tpl['ICON'] = FEATURE_NOTYET_ICON; $tpl['BEGIN_DEADLINE'] = HMS_Util::getFriendlyDate($this->startDate); } else { if (time() > $this->endDate) { $tpl['ICON'] = FEATURE_LOCKED_ICON; // fade out header $tpl['STATUS'] = "locked"; $tpl['END_DEADLINE'] = HMS_Util::getFriendlyDate($this->endDate); } else { //TODO $tpl['ICON'] = FEATURE_OPEN_ICON; $waitListCommand = CommandFactory::getCommand('ShowOffCampusWaitListApplication'); $waitListCommand->setTerm($this->term); $tpl['WAIT_LIST_LINK'] = $waitListCommand->getLink('Apply to the waiting list'); } } } return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/OffCampusWaitingListMenuBlock.tpl'); }
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) { $reminders = $context->get('send_reminders'); $sendReminders = isset($reminders) ? true : false; $magic = $context->get('magic_flag'); $sendMagic = isset($magic) ? true : false; $srMale = $context->get('sr_male'); $srFemale = $context->get('sr_female'); $jrMale = $context->get('jr_male'); $jrFemale = $context->get('jr_female'); $sophMale = $context->get('soph_male'); $sophFemale = $context->get('soph_female'); PHPWS_Core::initModClass('hms', 'LotteryProcess.php'); $inviteCounts = array(); $inviteCounts[CLASS_SENIOR][MALE] = $srMale; $inviteCounts[CLASS_SENIOR][FEMALE] = $srFemale; $inviteCounts[CLASS_JUNIOR][MALE] = $jrMale; $inviteCounts[CLASS_JUNIOR][FEMALE] = $jrFemale; $inviteCounts[CLASS_SOPHOMORE][MALE] = $sophMale; $inviteCounts[CLASS_SOPHOMORE][FEMALE] = $sophFemale; $lottery = new LotteryProcess($sendMagic, $sendReminders, $inviteCounts); $lottery->sendInvites(); $_SESSION['LOTTERY_OUTPUT'] = $lottery->getOutput(); $viewCmd = CommandFactory::getCommand('ShowLotteryInviteResults'); $viewCmd->redirect(); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'roommate_maintenance')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to create/edit roommate groups.'); } PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $id = $context->get('id'); if (is_null($id)) { throw new InvalidArgumentException('Missing roommate group id.'); } $viewCmd = CommandFactory::getCommand('EditRoommateGroupsView'); try { $roommate = new HMS_Roommate($id); $roommate->delete(); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Error deleting roommate group: ' . $e->getMessage()); $viewCmd->redirect(); } // Log the success $notes = "{$roommate->getRequestor()} requested {$roommate->getRequestee()}"; HMS_Activity_Log::log_activity($roommate->getRequestor(), ACTIVITY_ADMIN_REMOVED_ROOMMATE, UserStatus::getUsername(), $notes); HMS_Activity_Log::log_activity($roommate->getRequestee(), ACTIVITY_ADMIN_REMOVED_ROOMMATE, UserStatus::getUsername(), $notes); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Roommate group successfully deleted.'); $viewCmd->redirect(); }
/** * (non-PHPdoc) * @see Command::execute() */ public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $term = $context->get('term'); // Check if the student has already applied. If so, redirect to the student menu $app = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term); if (isset($result) && $result->getApplicationType == 'offcampus_waiting_list') { NQ::simple('hms', hms\NotificationView::ERROR, 'You have already enrolled on the on-campus housing Open Waiting List for this 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('ShowOffCampusWaitListApplication'); $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', 'ReApplicationOffCampusFormView.php'); $view = new ReApplicationOffCampusFormView($student, $term); $context->setContent($view->show()); }
public function execute(CommandContext $context) { // Get input $requestId = $context->get('requestId'); $participantId = $context->get('participantId'); // Command for showing the request, redirected to on success/error $cmd = CommandFactory::getCommand('ShowManageRoomChange'); $cmd->setRequestId($requestId); // Load the request $request = RoomChangeRequestFactory::getRequestById($requestId); // Load the participant $participant = RoomChangeParticipantFactory::getParticipantById($participantId); // Check permissions. Must be an RD for current bed, or an admin $rds = $participant->getFutureRdList(); if (!in_array(UserStatus::getUsername(), $rds) && !Current_User::allow('hms', 'admin_approve_room_change')) { throw new PermissionException('You do not have permission to approve this room change.'); } // Transition to CurrRdApproved $participant->transitionTo(new ParticipantStateFutureRdApproved($participant, time(), null, UserStatus::getUsername())); //TODO If all participants are approved, send notification to Housing if ($request->isApprovedByAllFutureRDs()) { HMS_Email::sendRoomChangeAdministratorNotice($request); } // Redirect to the manage request page $cmd->redirect(); }
public function show() { $tpl = array(); $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate); $tpl['STATUS'] = ""; if (isset($this->profile) && !is_null($this->profile)) { $tpl['ICON'] = FEATURE_COMPLETED_ICON; $editCmd = CommandFactory::getCommand('ShowRoommateProfileForm'); $editCmd->setTerm($this->term); $tpl['EDIT_PROFILE'] = $editCmd->getLink('view and edit your profile'); } else { if (time() < $this->startDate) { $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['BEGIN_DEADLINE'] = HMS_Util::getFriendlyDate($this->startDate); } else { if (time() > $this->endDate) { $tpl['END_DEADLINE'] = HMS_Util::getFriendlyDate($this->endDate); // fade out header $tpl['STATUS'] = "locked"; $tpl['ICON'] = FEATURE_LOCKED_ICON; } else { $tpl['ICON'] = FEATURE_OPEN_ICON; $createCmd = CommandFactory::getCommand('ShowRoommateProfileForm'); $createCmd->setTerm($this->term); $tpl['CREATE_PROFILE'] = $createCmd->getLink('Create your profile'); } } } return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/StudentProfileMenuBlock.tpl'); }
public function show() { Layout::addPageTitle("Hall Notification Edit"); $tpl = array(); $submitCmd = CommandFactory::getCommand('ReviewHallNotificationMessage'); $form = new PHPWS_Form('email_content'); $submitCmd->initForm($form); if (Current_User::allow('hms', 'anonymous_notifications')) { $form->addCheck('anonymous'); $form->setMatch('anonymous', $this->anonymous); $form->setLabel('anonymous', 'Send Anonymously'); } $form->addText('subject', !is_null($this->subject) ? $this->subject : ''); $form->setLabel('subject', 'Subject'); $form->addCssClass('subject', 'form-control'); $form->setSize('subject', 35); $form->setExtra('subject', 'autofocus'); $form->addTextarea('body', !is_null($this->body) ? $this->body : ''); $form->addCssClass('body', 'form-control'); $form->setLabel('body', 'Message:'); if (!empty($this->halls)) { $form->addHidden('hall', $this->halls); } if (!empty($this->floors)) { $form->addHidden('floor', $this->floors); } return PHPWS_Template::process($form->getTemplate(), 'hms', 'admin/hall_notification_email_page.tpl'); }
public function show() { PHPWS_Core::initCoreClass('Form.php'); javascript('jquery'); javascript('modules/hms/assign_student'); $unassignCmd = CommandFactory::getCommand('UnassignStudent'); $form = new PHPWS_Form(); $unassignCmd->initForm($form); $form->addText('username'); if (!is_null($this->student)) { $form->setValue('username', $this->student->getUsername()); } $form->addCssClass('username', 'form-control'); $form->setExtra('username', 'autofocus'); // Addition of "Unassignment Type" $form->addDropBox('unassignment_type', array('-1' => 'Choose a reason...', UNASSIGN_ADMIN => 'Administrative', UNASSIGN_REASSIGN => 'Re-assign', UNASSIGN_CANCEL => 'Contract Cancellation', UNASSIGN_PRE_SPRING => 'Pre-spring room change', UNASSIGN_RELEASE => 'Contract Release')); //$form->setMatch('unassignment_type', UNASSIGN_ADMIN); $form->setLabel('unassignment_type', 'Unassignment Type: '); $form->addCssClass('unassignment_type', 'form-control'); $form->addText('refund'); $form->setLabel('refund', 'Refund Percentage'); $form->setSize('refund', 4); $form->setMaxSize('refund', 3); $form->addCssClass('refund', 'form-control'); $form->addTextarea('note'); $form->setLabel('note', 'Note: '); $form->addCssClass('note', 'form-control'); $tpl = $form->getTemplate(); $tpl['TERM'] = Term::getPrintableSelectedTerm(); Layout::addPageTitle("Unassign Student"); return PHPWS_Template::process($tpl, 'hms', 'admin/unassignStudent.tpl'); }
/** * Shows the requested report's HTML output. * * @param CommandContext $context * @throws InvalidArgumentExection */ public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'reports')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do no have permission to run reports.'); } $reportId = $context->get('reportId'); if (!isset($reportId) || is_null($reportId)) { throw new InvalidArgumentExection('Missing report id.'); } // Instantiate the report controller with the requested report id PHPWS_Core::initModClass('hms', 'ReportFactory.php'); $report = ReportFactory::getReportById($reportId); Layout::addPageTitle($report->getFriendlyName()); $detailCmd = CommandFactory::getCommand('ShowReportDetail'); $detailCmd->setReportClass($report->getClass()); $content = '<div> ' . $detailCmd->getLink('« back') . ' </div>'; $content .= file_get_contents($report->getHtmlOutputFilename()); if ($content === FALSE) { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not open report file.'); PHPWS_Error::log('Could not open report file ' . $report->getCsvOutputFilename(), 'hms'); $reportCmd = CommandFactory::getCommand('ShowReportDetail'); $reportCmd->setReportClass($report->getClass()); $reportCmd->redirect(); } $context->setContent($content); }
public function show() { $tpl = array(); PHPWS_Core::initModClass('hms', 'HMS_Util.php'); $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate); if (is_null($this->application)) { // No application $tpl['ICON'] = FEATURE_NOTYET_ICON; $tpl['NOT_APP'] = ""; // this needs to be here to trigger the line in the template } else { if (time() < $this->startDate) { // too early $tpl['BEGIN_DEADLINE'] = HMS_Util::getFriendlyDate($this->startDate); $tpl['ICON'] = FEATURE_NOTYET_ICON; } else { if (time() > $this->endDate) { // too late $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['END_DEADLINE'] = HMS_Util::getFriendlyDate($this->endDate); } else { $tpl['ICON'] = FEATURE_OPEN_ICON; $cmd = CommandFactory::getCommand('ShowEmergencyContactForm'); $cmd->setTerm($this->application->getTerm()); $tpl['UPDATE_CONTACT'] = $cmd->getLink('update your emergency contact info'); } } } return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/updateEmergencyContactMenuBlock.tpl'); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'floor_view')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit floors.'); } // Check for a hall ID $floorId = $context->get('floor'); if (!isset($floorId)) { throw new InvalidArgumentException('Missing floor ID.'); } PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); PHPWS_Core::initModClass('hms', 'HMS_Floor.php'); PHPWS_Core::initModClass('hms', 'FloorView.php'); $floor = new HMS_Floor($floorId); if ($floor->term != Term::getSelectedTerm()) { $floorCmd = CommandFactory::getCommand('SelectFloor'); $floorCmd->setTitle('Edit a Floor'); $floorCmd->setOnSelectCmd(CommandFactory::getCommand('EditFloorView')); $floorCmd->redirect(); } $hall = $floor->get_parent(); $floorView = new FloorView($hall, $floor); $context->setContent($floorView->show()); }
public function show() { $tpl = array(); $submitCmd = CommandFactory::getCommand('SendLotteryInvites'); $form = new PHPWS_Form(); $submitCmd->initForm($form); $form->addCheckAssoc('send_reminders', array('send_reminders' => "Send Invite Reminders")); $form->setMatch('send_reminders', 'send_reminders'); $form->addCheckAssoc('magic_flag', array('magic_flag' => "Send 'Magic Winner' Invites")); $form->setMatch('magic_flag', 'magic_flag'); $form->addText('sr_male', 0); $form->setLabel('sr_male', 'Male:'); $form->setClass('sr_male', 'form-control'); $form->addText('sr_female', 0); $form->setLabel('sr_female', 'Female:'); $form->setClass('sr_female', 'form-control'); $form->addText('jr_male', 0); $form->setLabel('jr_male', 'Male:'); $form->setClass('jr_male', 'form-control'); $form->addText('jr_female', 0); $form->setLabel('jr_female', 'Female:'); $form->setClass('jr_female', 'form-control'); $form->addText('soph_male', 0); $form->setLabel('soph_male', 'Male:'); $form->setClass('soph_male', 'form-control'); $form->addText('soph_female', 0); $form->setLabel('soph_female', 'Female:'); $form->setClass('soph_female', 'form-control'); $form->addSubmit('submit', 'Send Invites'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'admin/SendLotteryInvitesView.tpl'); }
public function execute(CommandContext $context) { $id = $context->get('roommateId'); if (is_null($id)) { throw new InvalidArgumentException('Must set roommateId'); } PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $roommate = new HMS_Roommate($id); if ($roommate->id == 0) { throw new InvalidArgumentException('Invalid roommateId ' . $id); } $username = UserStatus::getUsername(); if ($username != $roommate->requestee) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException("{$username} tried to display confirmation screen for pairing {$roommate->id}"); } $tpl = array(); $acceptCmd = CommandFactory::getCommand('ShowRoommateConfirmAccept'); $acceptCmd->setRoommateId($roommate->id); $tpl['ACCEPT'] = $acceptCmd->getURI(); $rejectCmd = CommandFactory::getCommand('RoommateReject'); $rejectCmd->setRoommateId($roommate->id); $tpl['DECLINE'] = $rejectCmd->getURI(); $cancelCmd = CommandFactory::getCommand('ShowStudentMenu'); $tpl['CANCEL'] = $cancelCmd->getURI(); $requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term); $tpl['REQUESTOR_NAME'] = $requestor->getFullName(); $context->setContent(PHPWS_Template::process($tpl, 'hms', 'student/roommate_accept_reject_screen.tpl')); }
public function show() { $tpl = array(); $tpl['TERM'] = Term::getPrintableSelectedTerm(); $form = new PHPWS_Form('roommate_group'); $submitCmd = CommandFactory::getCommand('CreateRoommateGroup'); $submitCmd->initForm($form); if (isset($this->roommate1)) { $form->addText('roommate1', $this->roommate1); } else { $form->addText('roommate1'); } $form->addCssClass('roommate1', 'form-control'); $form->setExtra('roommate1', 'autofocus'); if (isset($this->roommate1)) { $form->addText('roommate2', $this->roommate2); } else { $form->addText('roommate2'); } $form->addCssClass('roommate2', 'form-control'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); Layout::addPageTitle("Create Roommate Group"); return PHPWS_Template::process($tpl, 'hms', 'admin/createRoommateGroup.tpl'); }
public function show() { $tpl = array(); if ($this->halls == NULL) { NQ::simple('hms', hms\NotificationView::ERROR, 'There are no halls available for the selected term.'); $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu'); $cmd->redirect(); } $tpl['TITLE'] = $this->title; $tpl['TERM'] = Term::getPrintableSelectedTerm(); javascript('jquery'); javascript('modules/hms/select_floor'); # Setup the form $form = new PHPWS_Form(); $this->onSelectCmd->initForm($form); $form->setMethod('get'); $form->addDropBox('residence_hall', $this->halls); $form->setLabel('residence_hall', 'Residence hall'); $form->setMatch('residence_hall', 0); $form->setClass('residence_hall', 'form-control'); $form->addDropBox('floor', array(0 => '')); $form->setLabel('floor', 'Floor'); $form->setClass('floor', 'form-control'); $form->addSubmit('submit_button', 'Select'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); Layout::addPageTitle("Select Floor"); return PHPWS_Template::process($tpl, 'hms', 'admin/select_floor.tpl'); }
public function execute(CommandContext $context) { // Check for report ID $reportId = $context->get('reportId'); if (!isset($reportId) || is_null($reportId)) { throw new InvalidArgumentException('Missing report id.'); } PHPWS_Core::initModClass('hms', 'ReportFactory.php'); // Load the report to get its class try { $report = ReportFactory::getReportById($reportId); } catch (InvalidArgumentException $e) { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.'); $context->goBack(); } $db = new PHPWS_DB('hms_report'); $db->addWhere('id', $reportId); $result = $db->delete(); if (PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.'); $cmd = CommandFactory::getCommand('ShowReportDetail'); $cmd->setReportClass($report->getClass()); $cmd->redirect(); }
public function show() { $tpl = array(); $tpl['REVIEW_MSG'] = ''; // set this to show the review message $tpl['STUDENT_NAME'] = $this->student->getFullName(); $tpl['TERM'] = Term::toString($this->term); /* Emergency Contact */ $tpl['EMERGENCY_CONTACT_NAME'] = $this->app->getEmergencyContactName(); $tpl['EMERGENCY_CONTACT_RELATIONSHIP'] = $this->app->getEmergencyContactRelationship(); $tpl['EMERGENCY_CONTACT_PHONE'] = $this->app->getEmergencyContactPhone(); $tpl['EMERGENCY_CONTACT_EMAIL'] = $this->app->getEmergencyContactEmail(); $tpl['EMERGENCY_MEDICAL_CONDITION'] = $this->app->getEmergencyMedicalCondition(); /* Missing Person */ $tpl['MISSING_PERSON_NAME'] = $this->app->getMissingPersonName(); $tpl['MISSING_PERSON_RELATIONSHIP'] = $this->app->getMissingPersonRelationship(); $tpl['MISSING_PERSON_PHONE'] = $this->app->getMissingPersonPhone(); $tpl['MISSING_PERSON_EMAIL'] = $this->app->getMissingPersonEmail(); $form = new PHPWS_Form('hidden_form'); $submitCmd = CommandFactory::getCommand('EmergencyContactConfirm'); $submitCmd->setVars($_REQUEST); $submitCmd->initForm($form); $form->addSubmit('submit', 'Confirm & Continue'); $redoCmd = CommandFactory::getCommand('ShowEmergencyContactForm'); $redoCmd->setTerm($this->term); $redoCmd->setVars($_REQUEST); $tpl['REDO_BUTTON'] = $redoCmd->getLink('modify your information'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'student/emergency_contact_form.tpl'); }
public function show() { $tpl = array(); $tpl['TERM'] = Term::toString($this->term); $form = new PHPWS_Form('rlc_reapp'); $submitCmd = CommandFactory::getCommand('SubmitRLCReapplicationPage2'); $submitCmd->setTerm($this->term); $submitCmd->initForm($form); foreach ($this->rlcs as $i => $rlc) { $question = $this->rlcs[$i]->getReturningQuestion(); if (!isset($question)) { throw new Exception("Missing returning question for {$this->rlcs[$i]->get_community_name()}"); } if (isset($this->reApp) && isset($this->reApp->{"rlc_question_{$i}"})) { $form->addTextArea("rlc_question_{$i}", $this->reApp->{"rlc_question_{$i}"}); } else { $form->addTextArea("rlc_question_{$i}"); } $form->setLabel("rlc_question_{$i}", $this->rlcs[$i]->getReturningQuestion()); $form->addCssClass("rlc_question_{$i}", 'form-control'); } $form->addSubmit('submit', 'Submit Application'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'student/RlcReapplicationPage2.tpl'); }
public function execute(CommandContext $context) { // Check permissions if (!Current_User::allow('hms', 'checkin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to checkin students.'); } $term = Term::getSelectedTerm(); $bannerId = $context->get('bannerId'); $hallId = $context->get('hallId'); $errorCmd = CommandFactory::getCommand('ShowCheckinStart'); if (!isset($bannerId) || is_null($bannerId) || $bannerId == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing Banner ID.'); $errorCmd->redirect(); } if (!isset($hallId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing residence hall ID.'); $errorCmd->redirect(); } // Check the Banner ID if (preg_match("/[\\d]{9}/", $bannerId) == false) { NQ::simple('hms', hms\NotificationView::ERROR, 'Imporperly formatted Banner ID.'); $errorCmd->redirect(); } // Try to lookup the student in Banner try { $student = StudentFactory::getStudentByBannerId($bannerId, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not locate a student with that Banner ID.'); $errorCmd->redirect(); } // Make sure the student is assigned in the current term $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $term); if (!isset($assignment) || is_null($assignment)) { NQ::simple('hms', hms\NotificationView::ERROR, $student->getName() . ' is not assigned for ' . Term::toString($term) . '. Please contact the University Housing Assignments Office at 828-262-6111.'); $errorCmd->redirect(); } // Make sure the student's assignment matches the hall the user selected $bed = $assignment->get_parent(); $room = $bed->get_parent(); $floor = $room->get_parent(); $hall = $floor->get_parent(); if ($hallId != $hall->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, 'Wrong hall! ' . $student->getName() . ' is assigned to ' . $assignment->where_am_i()); $errorCmd->redirect(); } // Load any existing check-in $checkin = CheckinFactory::getLastCheckinByBannerId($bannerId, $term); // If there is a checkin for the same bed, and the difference between the current time and the checkin time is // greater than 48 hours, then show an error. if (!is_null($checkin)) { $checkoutDate = $checkin->getCheckoutDate(); if ($checkin->getBedId() == $bed->getId() && !isset($checkoutDate) && time() - $checkin->getCheckinDate() > Checkin::CHECKIN_TIMEOUT) { NQ::simple('hms', hms\NotificationView::ERROR, $student->getName() . ' has already checked in to ' . $assignment->where_am_i()); $errorCmd->redirect(); } } $view = new CheckinFormView($student, $assignment, $hall, $floor, $room, $checkin); $context->setContent($view->show()); }
public function show() { $tpl = array(); $tpl['TERM'] = Term::toString($this->room->getTerm()); $tpl['TITLE'] = 'Add New Bed'; $tpl['HALL_NAME'] = $this->hall->getLink(); $tpl['FLOOR_NUMBER'] = $this->floor->getLink(); $tpl['ROOM_NUMBER'] = $this->room->getLink(); $tpl['ASSIGNED_TO'] = '<unassigned>'; $submitCmd = CommandFactory::getCommand('AddBed'); $submitCmd->setRoomId($this->room->id); $tpl['HALL_ABBR'] = $this->hall->getBannerBuildingCode(); $form = new PHPWS_Form(); $submitCmd->initForm($form); if (isset($this->bedLetter)) { $form->addText('bed_letter', $this->bedLetter); } else { $form->addText('bed_letter', chr($this->room->get_number_of_beds() + 97)); } $form->addCssClass('bed_letter', 'form-control'); if (isset($this->bedroomLabel)) { $form->addText('bedroom_label', $this->bedroomLabel); } else { $form->addText('bedroom_label', 'a'); } $form->addCssClass('bedroom_label', 'form-control'); if (isset($this->phoneNumber)) { $form->addText('phone_number', $this->phoneNumber); } else { // Try to guess at the phone number $beds = $this->room->get_beds(); if (sizeof($beds) > 0) { $form->addText('phone_number', $beds[0]->phone_number); } else { $form->addText('phone_number'); } } $form->setMaxSize('phone_number', 4); $form->setSize('phone_number', 5); $form->addCssClass('phone_number', 'form-control'); if (isset($this->bannerId)) { $form->addText('banner_id', $this->bannerId); } else { // try to guess a the banner ID // Strip any text out of the room number, just get the numbers $match = null; preg_match("/[0-9]*/", $this->room->room_number, $match); $roomNumber = $match[0]; $form->addText('banner_id', '0' . $roomNumber . ($this->room->get_number_of_beds() + 1)); } $form->addCssClass('banner_id', 'form-control'); $form->addCheckBox('ra', 1); $form->addCheckBox('ra_roommate', 1); $form->addCheckBox('international_reserved', 1); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); Layout::addPageTitle("Add Bed"); // Reusing the edit bed template here return PHPWS_Template::process($tpl, 'hms', 'admin/addBed.tpl'); }
public function execute(CommandContext $context) { $id = $context->get('roommateId'); if (is_null($id)) { throw new InvalidArgumentException('Must set roommateId'); } PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $roommate = new HMS_Roommate($id); if ($roommate->id == 0) { throw new InvalidArgumentException('Invalid roommateId ' . $id); } $username = UserStatus::getUsername(); if ($username != $roommate->requestor) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}"); } $roommate->delete(); $other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term); HMS_Activity_Log::log_activity($other->getUsername(), ACTIVITY_STUDENT_CANCELLED_ROOMMATE_REQUEST, $username, "{$username} cancelled roommate request"); HMS_Activity_Log::log_activity($username, ACTIVITY_STUDENT_CANCELLED_ROOMMATE_REQUEST, $other->getUsername(), "{$username} cancelled roommate request"); // Email both parties PHPWS_Core::initModClass('hms', 'HMS_Email.php'); HMS_Email::send_cancel_emails($roommate); $name = $other->getFullName(); NQ::Simple('hms', hms\NotificationView::SUCCESS, "You have cancelled your roommate request for {$name}."); $cmd = CommandFactory::getCommand('ShowStudentMenu'); $cmd->redirect(); }
public function execute(CommandContext $context) { $resultCmd = CommandFactory::getCommand('ShowSendRlcInvites'); $respondByDate = $context->get('respond_by_date'); $respondByTime = $context->get('time'); if (!isset($respondByDate) || $respondByDate == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a \'respond by\' date.'); $resultCmd->redirect(); } $dateParts = explode('/', $respondByDate); $respondByTimestamp = mktime($respondByTime, null, null, $dateParts[0], $dateParts[1], $dateParts[2]); $term = Term::getSelectedTerm(); $studentType = $context->get('type'); if (!isset($studentType)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a student type.'); $resultCmd->redirect(); } PHPWS_Core::initModClass('hms', 'RlcAssignmentFactory.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentInvitedState.php'); $assignments = RlcAssignmentFactory::getAssignmentsByTermStateType($term, 'new', $studentType); if (sizeof($assignments) == 0) { NQ::simple('hms', hms\NotificationView::WARNING, 'No invites needed to be sent.'); $resultCmd->redirect(); } foreach ($assignments as $assign) { $assign->changeState(new RlcAssignmentInvitedState($assign, $respondByTimestamp)); } NQ::simple('hms', hms\NotificationView::SUCCESS, 'Learning community invites sent.'); $resultCmd->redirect(); }
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 function show() { $tpl = array(); // Check for an empty array of requests if (sizeof($this->requests) == 0) { $tpl['NO_REQUESTS'] = 'No pending requests found.'; return PHPWS_Template::process($tpl, 'hms', 'admin/roomChangeListView.tpl'); } javascriptMod('hms', 'livestamp'); $tpl['REQUESTS'] = array(); foreach ($this->requests as $request) { $row = array(); $participants = $request->getParticipants(); $participantNames = array(); foreach ($participants as $p) { $student = StudentFactory::getStudentByBannerId($p->getBannerId(), $this->term); $participantNames[] = $student->getName(); } $row['participants'] = implode(', ', $participantNames); $mgmtCmd = CommandFactory::getCommand('ShowManageRoomChange'); $mgmtCmd->setRequestId($request->getId()); $row['manage'] = $mgmtCmd->getURI(); $row['last_updated_timestamp'] = $request->getLastUpdatedTimestamp(); $row['last_updated_date'] = date("M j @ g:ia", $request->getLastUpdatedTimestamp()); $tpl['REQUESTS'][] = $row; } return PHPWS_Template::process($tpl, 'hms', 'admin/roomChangeListView.tpl'); }
public function execute(CommandContext $context) { $id = $context->get('roommateId'); if (is_null($id)) { throw new InvalidArgumentException('Must set roommateId'); } PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $roommate = new HMS_Roommate($id); if ($roommate->id = 0) { throw new InvalidArgumentException('Invalid roommateId ' . $id); } $username = UserStatus::getUsername(); if ($username != $roommate->requestor && $username != $roommate->requestee) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}"); } PHPWS_Core::initCoreClass('Captcha.php'); // get other roommate $other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term); $form = new PHPWS_Form(); $cmd = CommandFactory::getCommand('RoommateBreak'); $cmd->setRoommateId($id); $cmd->initForm($form); $form->addTplTag('CAPTCHA_IMAGE', Captcha::get()); $form->addTplTag('NAME', $other->getFullName()); $form->addSubmit('Confirm'); $form->addCssClass('submit', 'btn btn-danger'); $context->setContent(PHPWS_Template::process($form->getTemplate(), 'hms', 'student/roommate_break_confirm.tpl')); }
public function show() { $tpl = array(); $tpl['TERM'] = Term::getPrintableSelectedTerm(); $tpl['NAME'] = $this->student->getFullName(); $tpl['LOCATION'] = $this->assignment->where_am_i(); $submitCmd = CommandFactory::getCommand('AssignStudent'); $submitCmd->setUsername($this->student->getUsername()); $submitCmd->setRoom($this->room); $submitCmd->setBed($this->bed); $submitCmd->setMealPlan($this->mealPlan); $submitCmd->setMoveConfirmed("true"); $submitCmd->setAssignmentType($this->assignmentType); $submitCmd->setNotes($this->notes); $form = new PHPWS_Form(); $submitCmd->initForm($form); $form->addSubmit('submit', 'Confirm Move'); $form->setClass('submit', 'btn btn-danger'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); if (!empty($_SERVER['HTTP_REFERER'])) { $tpl['BACK'] = $_SERVER['HTTP_REFERER']; } else { $tpl['BACK'] = 'index.php?module=hms&action=ShowAssignStudent'; } Layout::addPageTitle("Assignment Move Confirmation"); return PHPWS_Template::process($tpl, 'hms', 'admin/assign_student_move_confirm.tpl'); }