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'));
 }
 /**
  * (non-PHPdoc)
  * @see Command::execute()
  */
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     $term = $context->get('term');
     if (!isset($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $user = UserStatus::getUsername();
     $student = StudentFactory::getStudentByUsername($user, $term);
     // Load the student's application. Should be a lottery application.
     $application = HousingApplicationFactory::getAppByStudent($student, $term);
     // If there isn't a valid application in the DB, then we have a problem.
     if (!isset($application) || !$application instanceof LotteryApplication) {
         throw new InvalidArgumentException('Null application object.');
     }
     // Check to make sure the date isn't already set
     $time = $application->getWaitingListDate();
     if (isset($time)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You have already applied for the waiting list.');
         $cmd = CommandFactory::getCommand('ShowStudentMenu');
         $cmd->redirect();
     }
     // Set the date
     $application->setWaitingListDate(time());
     // Save the application again
     $application->save();
     // Log it to the activity log
     HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_REAPP_WAITINGLIST_APPLY, UserStatus::getUsername());
     // Success command
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->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)
 {
     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();
 }
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'approve_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to approve RLC applications.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     # Foreach rlc assignment made
     # $app_id is the 'id' column in the 'learning_community_applications' table, tells which student we're assigning
     # $rlc_id is the 'id' column in the 'learning_communitites' table, and refers to the RLC selected for the student
     foreach ($_REQUEST['final_rlc'] as $app_id => $rlc_id) {
         if ($rlc_id <= 0) {
             continue;
         }
         $app = HMS_RLC_Application::getApplicationById($app_id);
         $student = StudentFactory::getStudentByUsername($app->username, $app->term);
         # Insert a new assignment in the 'learning_community_assignment' table
         $assign = new HMS_RLC_Assignment();
         $assign->rlc_id = $rlc_id;
         $assign->gender = $student->getGender();
         $assign->assigned_by = UserStatus::getUsername();
         $assign->application_id = $app->id;
         $assign->state = 'new';
         $assign->save();
         # Log the assignment
         PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
         HMS_Activity_Log::log_activity($app->username, ACTIVITY_ASSIGN_TO_RLC, UserStatus::getUsername(), "New Assignment");
     }
     // Show a success message
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Successfully assigned RLC applicant(s).');
     $context->goBack();
 }
예제 #6
0
 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);
     }
     if (UserStatus::getUsername() != $roommate->requestee) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to reject roommate pairing {$roommate->id}");
     }
     $requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term);
     $name = $requestor->getFullName();
     $username = $requestor->getUsername();
     $roommate->delete();
     HMS_Activity_Log::log_activity($roommate->requestor, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestee, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
     HMS_Activity_Log::log_activity($roommate->requestee, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestor, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
     // Email both parties
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_reject_emails($roommate);
     NQ::Simple('hms', hms\NotificationView::SUCCESS, "<b>You rejected the roommate request from {$name}.</b>  If this was an error, you may re-request using their username, <b>{$username}</b>.");
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
예제 #7
0
 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)
 {
     $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)
 {
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     $term = $context->get('term');
     // Application must exist
     $app = HMS_RLC_Application::getApplicationByUsername(UserStatus::getUsername(), $term);
     if (is_null($app)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'No RLC application exists.');
         $context->goBack();
     } else {
         if (!HMS_RLC_Assignment::checkForAssignment(UserStatus::getUsername(), $term)) {
             // Delete the app
             $app->delete();
             // Log it
             PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
             HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_RLC_APPLICATION_DELETED, UserStatus::getUsername());
             // Show a notification and go back
             NQ::simple('hms', hms\NotificationView::SUCCESS, 'RLC application deleted.');
             $context->goBack();
         } else {
             NQ::simple('hms', hms\NotificationView::WARNING, 'You have already been assigned to an RLC.');
             $context->goBack();
         }
     }
 }
 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 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 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 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());
 }
예제 #14
0
 public function execute(CommandContext $context)
 {
     $term = Term::getSelectedTerm();
     $messageAll = Current_User::allow('hms', 'email_all');
     $db = new PHPWS_DB('hms_residence_hall');
     $db->addWhere('term', $term);
     $results = $db->getObjects('HMS_Residence_Hall');
     if (PHPWS_Error::logIfError($results) || is_null($results)) {
         $errorMsg = array();
         if (is_null($results)) {
             $errorMsg['error'] = 'You do not have permission to message any halls, sorry.';
         } else {
             $errorMsg['error'] = 'There was a problem reading the database, please try reloading the page.  If the problem persists contact ESS.';
         }
         echo json_encode($errorMsg);
         exit;
     }
     $permission = new HMS_Permission();
     $data = array();
     foreach ($results as $hall) {
         $somethingEnabled = false;
         $floors = $hall->get_floors();
         unset($obj);
         $obj = new stdClass();
         $obj->name = $hall->getHallName();
         $obj->id = $hall->getId();
         $obj->floors = array();
         //$blah = 'Verify: ' . ($permission->verify(UserStatus::getUsername(), $hall, 'email') ? 'true' : 'false');
         if ($permission->verify(UserStatus::getUsername(), $hall, 'email') || $messageAll) {
             $obj->enabled = true;
             $somethingEnabled = true;
             foreach ($floors as $floor) {
                 unset($floor_obj);
                 $floor_obj = new stdClass();
                 $floor_obj->name = "Floor: " . $floor->getFloorNumber();
                 $floor_obj->id = $floor->getId();
                 $floor_obj->enabled = true;
                 $obj->floors[] = $floor_obj;
             }
         } else {
             $obj->enabled = false;
             foreach ($floors as $floor) {
                 unset($floor_obj);
                 $floor_obj = new stdClass();
                 $floor_obj->name = "Floor: " . $floor->getFloorNumber();
                 $floor_obj->id = $floor->getId();
                 $floor_obj->enabled = $permission->verify(Current_User::getUsername(), $floor, 'email');
                 $obj->floors[] = $floor_obj;
                 if ($floor_obj->enabled) {
                     $somethingEnabled = true;
                 }
             }
         }
         if ($somethingEnabled) {
             $data[] = $obj;
         }
     }
     echo json_encode($data);
     exit;
 }
예제 #15
0
 public function getStudentById($id, $term)
 {
     // Sanity checking on the Banner ID
     $id = trim($id);
     if (!isset($id) || empty($id) || $id == '') {
         throw new InvalidArgumentException('Missing Banner id. Please enter a valid Banner ID (nine digits).');
     }
     if (strlen($id) > 9 || strlen($id) < 9 || !preg_match("/^[0-9]{9}\$/", $id)) {
         throw new InvalidArgumentException('That was not a valid Banner ID. Please enter a valid Banner ID (nine digits).');
     }
     $student = new Student();
     $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER);
     $soapData = $soap->getStudentProfile($id, $term);
     if ($soapData->error_num == 1101 && $soapData->error_desc == 'LookupStudentID') {
         PHPWS_Core::initModClass('hms', 'exception/StudentNotFoundException.php');
         throw new StudentNotFoundException('No matching student found.');
     } elseif (isset($soapData->error_num) && $soapData->error_num > 0) {
         //test($soapData,1);
         throw new SOAPException("Error while accessing SOAP interface: {$soapData->error_desc} ({$soapData->error_num})", $soapData->error_num, 'getStudentProfile', array($id, $term));
     }
     SOAPDataProvider::plugSOAPData($student, $soapData);
     //SOAPDataProvider::applyExceptions($student);
     require_once PHPWS_SOURCE_DIR . SOAP_DATA_OVERRIDE_PATH;
     $dataOverride = new SOAPDataOverride();
     $dataOverride->applyExceptions($student);
     $student->setDataSource(get_class($this));
     return $student;
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     $term = $context->get('term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $errorCmd = CommandFactory::getCommand('ShowReApplication');
     $errorCmd->setTerm($term);
     $depositAgreed = $context->get('deposit_check');
     if (is_null($depositAgreed)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must check the box indicating you understand the License Contract deposit fees.');
         $errorCmd->redirect();
     }
     // 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();
         }
     }
     //$mealPlan = $context->get('meal_plan');
     /* Emergency Contact Sanity Checking */
     $emergencyName = $context->get('emergency_contact_name');
     $emergencyRelationship = $context->get('emergency_contact_relationship');
     $emergencyPhone = $context->get('emergency_contact_phone');
     $emergencyEmail = $context->get('emergency_contact_email');
     if (empty($emergencyName) || empty($emergencyRelationship) || empty($emergencyPhone) || empty($emergencyEmail)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please complete all of the emergency contact person information.');
         $errorCmd->redirect();
     }
     /* Missing Persons Sanity Checking */
     $missingPersonName = $context->get('missing_person_name');
     $missingPersonRelationship = $context->get('missing_person_relationship');
     $missingPersonPhone = $context->get('missing_person_phone');
     $missingPersonEmail = $context->get('missing_person_email');
     if (empty($missingPersonName) || empty($missingPersonRelationship) || empty($missingPersonPhone) || empty($missingPersonEmail)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please complete all of the missing persons contact information.');
         $errorCmd->redirect();
     }
     $specialNeed = $context->get('special_need');
     if (isset($specialNeed)) {
         $onSubmitCmd = CommandFactory::getCommand('ReApplicationFormSave');
         $onSubmitCmd->loadContext($context);
         $onSubmitCmd->setTerm($term);
         $specialNeedCmd = CommandFactory::getCommand('ShowSpecialNeedsForm');
         $specialNeedCmd->setTerm($term);
         $specialNeedCmd->setVars($context->getParams());
         $specialNeedCmd->setOnSubmitCmd($onSubmitCmd);
         $specialNeedCmd->redirect();
     } else {
         $reviewCmd = CommandFactory::getCommand('ReApplicationFormSave');
         $reviewCmd->setTerm($term);
         $reviewCmd->loadContext($context);
         $reviewCmd->redirect();
     }
 }
예제 #17
0
 /**
  * Create a new RoomChangeReuqest.
  *
  * @param integer $term
  * @param String $reason
  */
 public function __construct($term, $reason)
 {
     $this->id = 0;
     $this->term = $term;
     $this->reason = $reason;
     // Set initial state
     $this->setState(new RoomChangeStatePending($this, time(), null, UserStatus::getUsername()));
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'FreshmenMainMenuView.php');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), Term::getCurrentTerm());
     $view = new FreshmenMainMenuView($student);
     $context->setContent($view->show());
 }
예제 #19
0
 public function getMenuBlockView(Student $student)
 {
     PHPWS_Core::initModClass('hms', 'ReapplicationWaitingListMenuBlockView.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $application = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term, 'lottery');
     return new ReapplicationWaitingListMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $application);
 }
예제 #20
0
 /**
  * Initalizes the report object we're wrapping. Sets creation dates/users.
  *
  * @param int $scheduledExecTime Unix timestamp of the time this report should be executed.
  */
 public function newReport($scheduledExecTime)
 {
     $this->report = $this->getReportInstance();
     $this->report->setCreatedBy(UserStatus::getUsername());
     $this->report->setCreatedOn(time());
     $this->report->setScheduledExecTime($scheduledExecTime);
     $this->report->setBeganTimestamp(null);
     $this->report->setCompletedTimestamp(null);
 }
예제 #21
0
 /**
  * Create a new RoomChangeParticipant
  *
  * @param RoomChangeRequest $request
  * @param Student $student
  * @param HMS_Bed $fromBed
  */
 public function __construct(RoomChangeRequest $request, Student $student, HMS_Bed $fromBed)
 {
     $this->id = 0;
     $this->request_id = $request->getId();
     $this->banner_id = $student->getBannerId();
     $this->from_bed = $fromBed->getId();
     // Set initial state
     $this->setState(new ParticipantStateNew($this, time(), null, UserStatus::getUsername()));
 }
 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)
 {
     $term = Term::getCurrentTerm();
     // Get the list of role memberships this user has
     // NB: This gets memberships for all terms.. must filter later
     $hms_perm = new HMS_Permission();
     $memberships = $hms_perm->getMembership('room_change_approve', NULL, UserStatus::getUsername());
     // Use the roles to instantiate a list of floors this user has access to
     $floors = array();
     foreach ($memberships as $member) {
         if ($member['class'] == 'hms_residence_hall') {
             $hall = new HMS_Residence_Hall($member['instance']);
             // Filter out halls that aren't in the current term
             if ($hall->getTerm() != $term) {
                 continue;
             }
             $floors = array_merge($floors, $hall->getFloors());
         } else {
             if ($member['class'] == 'hms_floor') {
                 $f = new HMS_Floor($member['instance']);
                 // Filter out floors that aren't in the current term
                 if ($f->getTerm() != $term) {
                     continue;
                 }
                 $floors[] = $f;
             } else {
                 throw new Exception('Unknown object type.');
             }
         }
     }
     if (empty($floors)) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         NQ::simple('hms', hms\NotificationView::ERROR, "You do not have the 'RD' role on any residence halls or floors.");
         $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu');
         $cmd->redirect();
     }
     // Remove duplicate floors
     $uniqueFloors = array();
     foreach ($floors as $floor) {
         $uniqueFloors[$floor->getId()] = $floor;
     }
     // Use the list of floors to get a unique list of hall names
     $hallNames = array();
     foreach ($uniqueFloors as $floor) {
         $hall = $floor->get_parent();
         $hallNames[$hall->getId()] = $hall->getHallName();
     }
     // Get the set of room changes which are not complete based on the floor list
     $needsApprovalChanges = RoomChangeRequestFactory::getRoomChangesNeedsApproval($term, $uniqueFloors);
     $approvedChanges = RoomChangeRequestFactory::getRoomChangesByFloor($term, $uniqueFloors, array('Approved'));
     $allPendingChanges = RoomChangeRequestFactory::getRoomChangesByFloor($term, $uniqueFloors, array('Pending', 'Hold'));
     $completedChanges = RoomChangeRequestFactory::getRoomChangesByFloor($term, $uniqueFloors, array('Complete'));
     $inactiveChanges = RoomChangeRequestFactory::getRoomChangesByFloor($term, $uniqueFloors, array('Cancelled', 'Denied'));
     $view = new RoomChangeApprovalView($needsApprovalChanges, $approvedChanges, $allPendingChanges, $completedChanges, $inactiveChanges, $hallNames, $term);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFormView.php');
     // Make sure we have a valid term
     $term = $context->get('term');
     if (is_null($term) || !isset($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     // Determine the application type, based on the term
     $sem = Term::getTermSem($term);
     switch ($sem) {
         case TERM_FALL:
             $appType = 'fall';
             break;
         case TERM_SPRING:
             $appType = 'spring';
             break;
         case TERM_SUMMER1:
         case TERM_SUMMER2:
             $appType = 'summer';
             break;
     }
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Make sure the student agreed to the terms, if not, send them back to the terms & agreement command
     //$event = $context->get('event');
     // If they haven't agreed, redirect to the agreement
     // TODO: actually check via docusign API
     /*
     if(is_null($event) || !isset($event) || ($event != 'signing_complete' && $event != 'viewing_complete')){
         $agreementCmd = CommandFactory::getCommand('ShowTermsAgreement');
         $agreementCmd->setTerm($term);
         $agreementCmd->setAgreedCommand(CommandFactory::getCommand('ShowHousingApplicationForm'));
         $agreementCmd->redirect();
     }
     */
     // Check to see if the student's PIN is enabled. Don't let the student apply if the PIN is disabled.
     if ($student->pinDisabled()) {
         $pinCmd = CommandFactory::getCommand('ShowPinDisabled');
         $pinCmd->redirect();
     }
     // Check to see if the user has an existing application for the term in question
     $existingApplication = HousingApplication::getApplicationByUser($student->getUsername(), $term);
     // Check for an in-progress application on the context, ignore any exceptions (in case there isn't an application on the context)
     try {
         //TODO check to see if it looks like there might be something on the context before trying this
         $existingApplication = HousingApplicationFactory::getApplicationFromContext($context, $term, $student, $appType);
     } catch (Exception $e) {
         // ignored
         $contextApplication = NULL;
     }
     $appView = new HousingApplicationFormView($student, $term, $existingApplication);
     $context->setContent($appView->show());
 }
 public function execute(CommandContext $context)
 {
     $term = Term::getCurrentTerm();
     // Create the student
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // If the student has a pending request load it from the db
     $request = RoomChangeRequestFactory::getPendingByStudent($student, $term);
     $view = new RoomChangeRequestForm($student, $term);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     $term = $context->get('term');
     if (!isset($term) || is_null($term) || empty($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $view = new RlcApplicationPage1View($context, $student);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     // TODO make sure the application feature is really enabled
     PHPWS_Core::initModClass('hms', 'RoommateProfile.php');
     PHPWS_Core::initModClass('hms', 'RoommateProfileFormView.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $term = $context->get('term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $profile = RoommateProfileFactory::getProfile($student->getBannerID(), $term);
     $view = new RoommateProfileFormView($profile, $term);
     $context->setContent($view->show());
 }
예제 #28
0
 public function __construct()
 {
     parent::__construct();
     if (UserStatus::isAdmin()) {
         if (Current_User::allow('hms', 'assignment_maintenance')) {
             $this->addCommandByName('Assign student', 'ShowAssignStudent');
             $this->addCommandByName('Unassign student', 'ShowUnassignStudent');
             $this->addCommandByName('Set move-in times', 'ShowMoveinTimesView');
         }
         if (Current_User::allow('hms', 'run_hall_overview')) {
             $hallOverviewCmd = CommandFactory::getCommand('SelectResidenceHall');
             $hallOverviewCmd->setTitle('Hall Overview');
             $hallOverviewCmd->setOnSelectCmd(CommandFactory::getCommand('HallOverview'));
             $this->addCommand('Hall Overview', $hallOverviewCmd);
         }
         if (Current_User::allow('hms', 'assign_by_floor')) {
             $floorAssignCmd = CommandFactory::getCommand('AssignByFloor');
             $floorAssignCmd->setOnSelectCmd(CommandFactory::getCommand('ShowFloorAssignmentView'));
             $floorAssignCmd->setTitle('Assign Students to Floor');
             $this->addCommand('Assign students by floor', $floorAssignCmd);
         }
         if (UserStatus::isAdmin() && Current_User::allow('hms', 'roommate_maintenance')) {
             $this->addCommandByName('Edit freshmen roommate requests', 'EditRoommateGroupsView');
         }
         if (Current_User::allow('hms', 'autoassign')) {
             $autoAssignCmd = CommandFactory::getCommand('JSConfirm');
             $autoAssignCmd->setLink('Auto-assign');
             $autoAssignCmd->setTitle('Auto-assign');
             $autoAssignCmd->setQuestion('Start auto-assign process for the selected term?');
             $autoAssignCmd->setOnConfirmCommand(CommandFactory::getCommand('ScheduleAutoassign'));
             $this->addCommand('Start Autoassigner', $autoAssignCmd);
         }
         if (Current_User::allow('hms', 'withdrawn_search')) {
             $withdrawnSearchCmd = CommandFactory::getCommand('JSConfirm');
             $withdrawnSearchCmd->setLink('Withdrawn search');
             $withdrawnSearchCmd->setTitle('Withdrawn search');
             $withdrawnSearchCmd->setQuestion('Start search for withdrawn students for the selected term?');
             $withdrawnSearchCmd->setOnConfirmCommand(CommandFactory::getCommand('WithdrawnSearch'));
             $this->addCommand('Withdrawn search', $withdrawnSearchCmd);
         }
         $hms_perm = new HMS_Permission();
         $memberships = $hms_perm->getMembership('room_change_approve', NULL, UserStatus::getUsername());
         if (!empty($memberships)) {
             $RDRoomChangeCmd = CommandFactory::getCommand('ShowRDRoomChangeList');
             $this->addCommand('Room Change Approval (RD)', $RDRoomChangeCmd);
         }
         if (Current_User::allow('hms', 'admin_approve_room_change')) {
             $adminRoomChangeCmd = CommandFactory::getCommand('ShowAdminRoomChangeList');
             $this->addCommand('Room Change Approval (Admin)', $adminRoomChangeCmd);
         }
     }
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'LotteryChooseRoommatesView.php');
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $roomId = $context->get('roomId');
     if (!isset($roomId) || is_null($roomId) || empty($roomId)) {
         throw new InvalidArgumentException('Missing room id.');
     }
     $view = new LotteryChooseRoommatesView($student, $term, $roomId);
     $context->setContent($view->show());
 }
 public function onEnter()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     $application = $this->rlcAssignment->getApplication();
     $term = $application->getTerm();
     $username = $application->getUsername();
     $community = $this->rlcAssignment->getRlc();
     $student = StudentFactory::getStudentByUsername($username, $term);
     HMS_Email::sendRlcInviteEmail($student, $community, $term, $this->respondByTimestamp);
     HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_RLC_INVITE_SENT, UserStatus::getUsername());
 }