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) { // 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 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(); }
/** * (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) { // 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.'); } PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $bannerId = $context->get('banner_id'); $hallId = $context->get('residence_hall_hidden'); $errorCmd = CommandFactory::getCommand('ShowCheckoutStart'); // TODO 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(); } // Everything checks out, so redirect to the form $cmd = CommandFactory::getCommand('ShowCheckoutForm'); // TODO $cmd->setBannerId($bannerId); $cmd->setHallId($hallId); $cmd->redirect(); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'edit_role_members')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit role members.'); } $username = $context->get('username'); $rolename = $context->get('role'); $class = $context->get('className'); $instance = $context->get('instance'); if (is_null($username) || is_null($rolename)) { echo json_encode(false); exit; } $db = new PHPWS_DB('hms_role'); $db->addWhere('name', $rolename); $result = $db->select('row'); if (PHPWS_Error::logIfError($result) || is_null($result['id'])) { echo json_encode(false); exit; } $role_id = $result['id']; $role = new HMS_Role(); $role->id = $role_id; if ($role->load()) { echo json_encode($role->removeUser($username, $class, $instance)); exit; } echo json_encode(false); exit; }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'edit_role_members')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit role members.'); } $username = $context->get('username'); $role_id = $context->get('role'); $classname = $context->get('class'); $instance = $context->get('instance'); if (is_null($username) || is_null($role_id)) { echo json_encode(false); exit; } $role = new HMS_Role(); $role->id = $role_id; if ($role->load()) { try { $role->addUser($username, $classname, $instance); echo json_encode('true'); exit; } catch (Exception $e) { echo json_encode($e->getMessage()); exit; } } }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'bed_structure')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to remove a bed.'); } PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); $viewCmd = CommandFactory::getCommand('EditRoomView'); $viewCmd->setRoomId($context->get('roomId')); $bedId = $context->get('bedId'); $roomId = $context->get('roomId'); if (!isset($roomId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing room ID.'); $viewCmd->redirect(); } if (!isset($bedId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing bed ID.'); $viewCmd->redirect(); } # Try to delete the bed try { HMS_Bed::deleteBed($bedId); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error deleting the bed: ' . $e->getMessage()); $viewCmd->redirect(); } NQ::simple('hms', hms\NotificationView::SUCCESS, 'Bed successfully deleted.'); $viewCmd->redirect(); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'assign_by_floor')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to assign students by floor.'); } $username = $context->get('username'); $banner_id = (int) $context->get('banner_id'); $reason = $context->get('reason'); $meal_plan = $context->get('meal_plan'); $bed_id = $context->get('bed_id'); $term = Term::getSelectedTerm(); try { if ($banner_id) { $student = StudentFactory::getStudentByBannerID($banner_id, Term::getSelectedTerm()); } elseif (!empty($username)) { $student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm()); } else { $context->setContent(json_encode(array('status' => 'failure', 'message' => 'Did not receive Banner ID or user name.'))); return; } try { HMS_Assignment::assignStudent($student, $term, null, $bed_id, $meal_plan, null, null, $reason); } catch (AssignmentException $e) { $context->setContent(json_encode(array('status' => 'failure', 'message' => $e->getMessage()))); return; } $message = $student->first_name . ' ' . $student->last_name; $context->setContent(json_encode(array('status' => 'success', 'message' => $message, 'student' => $student))); } catch (\StudentNotFoundException $e) { $context->setContent(json_encode(array('status' => 'failure', 'message' => $e->getMessage()))); } }
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) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'search')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to lookup student names!'); } $student = null; $error = new JsonError(403); $username = $context->get('username'); $banner_id = (int) $context->get('banner_id'); try { if ($banner_id) { $student = StudentFactory::getStudentByBannerID($banner_id, Term::getSelectedTerm()); } elseif (!empty($username)) { $student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm()); } else { $error->setMessage('Did not receive Banner ID or user name.'); $context->setContent(json_encode($error)); } $student->gender_string = HMS_Util::formatGender($student->gender); $context->setContent(json_encode($student)); } catch (\StudentNotFoundException $e) { $error->setMessage($e->getMessage()); $context->setContent(json_encode($error)); } }
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 = new Term(Term::getSelectedTerm()); $term->setDocusignTemplate($context->get('template')); $term->setDocusignUnder18Template($context->get('under18_template')); $term->save(); $cmd = CommandFactory::getCommand('ShowEditTerm'); $cmd->redirect(); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'cancel_housing_application')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to cancel housing applications.'); } // Check for a housing application id $applicationId = $context->get('applicationId'); if (!isset($applicationId) || is_null($applicationId)) { throw new InvalidArgumentException('Missing housing application id.'); } // Check for a cancellation reason $cancelReason = $context->get('cancel_reason'); if (!isset($cancelReason) || is_null($cancelReason)) { throw new InvalidArgumentException('Missing cancellation reason.'); } // Load the housing application PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); $application = HousingApplicationFactory::getApplicationById($applicationId); // Load the student $student = $application->getStudent(); $username = $student->getUsername(); $term = $application->getTerm(); // Load the cancellation reasons $reasons = HousingApplication::getCancellationReasons(); // Check for an assignment and remove it // Decide which term to use - If this application is in a past fall term, then use the current term if ($term < Term::getCurrentTerm() && Term::getTermSem($term) == TERM_FALL) { $assignmentTerm = Term::getCurrentTerm(); } else { $assignmentTerm = $term; } PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $assignmentTerm); if (isset($assignment)) { // TODO: Don't hard code cancellation refund percentage HMS_Assignment::unassignStudent($student, $assignmentTerm, 'Application cancellation: ' . $reasons[$cancelReason], UNASSIGN_CANCEL, 100); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($username, $term); if (!is_null($rlcAssignment)) { $rlcAssignment->delete(); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $rlcApplication = HMS_RLC_Application::getApplicationByUsername($username, $term); if (!is_null($rlcApplication)) { $rlcApplication->denied = 1; $rlcApplication->save(); HMS_Activity_Log::log_activity($username, ACTIVITY_DENIED_RLC_APPLICATION, \Current_User::getUsername(), Term::toString($term) . ' Denied RLC Application due to Contract Cancellation'); } // Cancel the application $application->cancel($cancelReason); $application->save(); echo 'success'; exit; }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'RoommateProfile.php'); PHPWS_Core::initModClass('hms', 'RoommateProfileView.php'); $student = StudentFactory::getStudentByBannerID($context->get('banner_id'), $context->get('term')); $profile = RoommateProfileFactory::getProfile($context->get('banner_id'), $context->get('term')); $view = new RoommateProfileView($student, $profile); $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', 'CreateRoommateGroupView.php'); $createView = new CreateRoommateGroupView($context->get('roommate1'), $context->get('roommate2')); $context->setContent($createView->show()); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'LotteryConfirmRoommateRequestView.php'); $request = HMS_Lottery::get_lottery_roommate_invite_by_id($context->get('requestId')); $term = PHPWS_Settings::get('hms', 'lottery_term'); $mealPlan = $context->get('meal_plan'); $view = new LotteryConfirmRoommateRequestView($request, $term, $mealPlan); $context->setContent($view->show()); }
public function execute(CommandContext $context) { $roomId = $context->get('roomId'); $roommates = $context->get('roommates'); $mealPlan = $context->get('mealPlan'); $term = PHPWS_Settings::get('hms', 'lottery_term'); PHPWS_Core::initModClass('hms', 'LotteryConfirmView.php'); $view = new LotteryConfirmView($roomId, $mealPlan, $roommates, $term); $context->setContent($view->show()); }
public function execute(CommandContext $context) { $term = $context->get('term'); $specialNeeds = $context->get('special_needs'); $submitCmd = CommandFactory::getCommand($context->get('onSubmit')); $submitCmd->setTerm($term); $submitCmd->loadContext($context); $specialNeedsForm = new SpecialNeedsFormView($term, $specialNeeds, $submitCmd); $context->setContent($specialNeedsForm->show()); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'SelectHallView.php'); PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); $term = Term::getSelectedTerm(); $halls = HMS_Residence_Hall::get_halls_array($term); $onSelectCmd = CommandFactory::getCommand($context->get('onSelectAction')); $hallView = new SelectHallView($onSelectCmd, $halls, $context->get('title'), $term); $context->setContent($hallView->show()); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'AssignByFloorView.php'); PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); $term = Term::getSelectedTerm(); $halls = HMS_Residence_Hall::getHallsDropDownValues($term); $onSelectCmd = CommandFactory::getCommand($context->get('onSelectAction')); $onSelectCmd->setFloorId($context->get('floor')); $floorView = new AssignByFloorView($onSelectCmd, $halls, $context->get('title'), $term); $context->setContent($floorView->show()); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'CheckinFactory.php'); PHPWS_Core::initModClass('hms', 'RoomDamageFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModClass('hms', 'BedFactory.php'); $term = Term::getCurrentTerm(); $bannerId = $context->get('bannerId'); $hallId = $context->get('hallId'); $errorCmd = CommandFactory::getCommand('ShowCheckoutStart'); if (!isset($bannerId) || is_null($bannerId) || $bannerId == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing student ID.'); $errorCmd->redirect(); } if (!isset($hallId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing residence hall ID.'); $errorCmd->redirect(); } // If search string is all numeric, make sure it looks like a valid Banner ID if (is_numeric($bannerId) && 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 { // If it's all numeric assume it's a student ID, otherwise assume it's a username if (is_numeric($bannerId) && strlen((string) $bannerId) == 9) { $student = StudentFactory::getStudentByBannerId($bannerId, $term); } else { $student = StudentFactory::getStudentByUsername($bannerId, $term); } } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not locate a student with that Banner ID.'); $errorCmd->redirect(); } // Find the earliest checkin that matches hall the user selected $hall = new HMS_Residence_Hall($hallId); $checkin = CheckinFactory::getPendingCheckoutForStudentByHall($student, $hall); if (!isset($checkin)) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, we couldn't find a matching check-in at {$hall->getHallName()} for this student to check-out of."); $errorCmd->redirect(); } $bed = BedFactory::getBedByPersistentId($checkin->getBedPersistentId(), $term); $room = $bed->get_parent(); // Get the damages for this student's room $damages = RoomDamageFactory::getDamagesByRoom($room); PHPWS_Core::initModClass('hms', 'CheckoutFormView.php'); $view = new CheckoutFormView($student, $hall, $room, $bed, $damages, $checkin); $context->setContent($view->show()); }
/** * * @param CommandContext $context * @throws PermissionException */ public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'assignment_maintenance')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to unassign students.'); } PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $username = $context->get('username'); $unassignReason = $context->get('unassignment_type'); $cmd = CommandFactory::getCommand('ShowUnassignStudent'); // $cmd->setUsername($username); if (!isset($username) || is_null($username)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid or missing username.'); $cmd->redirect(); } // Make sure a valid reason was chosen if (!isset($unassignReason) || $unassignReason == -1) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a valid reason.'); $cmd->setUsername($username); $cmd->redirect(); } // Check refund percentage field $refund = $context->get('refund'); // Is a required field if (!isset($refund) || $refund == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Please enter a refund percentage.'); $cmd->redirect(); } // Must be numeric if (!is_numeric($refund) || $refund < 0 || $refund > 100) { NQ::simple('hms', hms\NotificationView::ERROR, 'The refund percentage must be between 0 and 100 percent.'); $cmd->redirect(); } // Must be whole number if (is_float($refund)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Only whole number refund percentages are supported, no decimal place is allowed.'); $cmd->redirect(); } $term = Term::getSelectedTerm(); $student = StudentFactory::getStudentByUsername($username, $term); $notes = $context->get('note'); try { HMS_Assignment::unassignStudent($student, $term, $notes, $unassignReason, $refund); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Error: ' . $e->getMessage()); $cmd->setUsername($username); $cmd->redirect(); } NQ::simple('hms', hms\NotificationView::SUCCESS, 'Successfully unassigned ' . $student->getFullName()); $cmd->redirect(); }
function execute(CommandContext $context) { $manager = Registry::getAccessManager(); $user = $context->get('username'); $pass = $context->get('pass'); $user_obj = $manager->login($user, $pass); if (is_null($user_obj)) { $context->setError($manager->getError()); return false; } $context->addParam("user", $user_obj); return true; }
function execute(CommandContext $context) { $manager = ReceiverFactory::getAccessManager(); $user = $context->get('username'); $pass = $context->get('pass'); $user = $manager->login($user, $pass); if (!$user) { $this->context->setError($manager->getError()); return false; } $context->addParam("user", $user); return true; }
function execute(CommandContext $context) { $msgSystem = Registry::getMessageSystem(); $email = $context->get('email'); $msg = $context->get('msg'); $topic = $context->get('topic'); $result = $msgSystem->send($email, $msg, $topic); if (!$result) { $context->setError($msgSystem->getError()); return false; } return true; }
public function execute(CommandContext $context) { $term = $context->get('term'); if (!isset($term)) { throw new InvalidArgumentException('Missing term!'); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentConfirmedState.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentDeclinedState.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername(UserStatus::getUsername(), $term); $rlcApplication = $rlcAssignment->getApplication(); $student = StudentFactory::getStudentByUsername($rlcApplication->getUsername(), $rlcApplication->getTerm()); $acceptStatus = $context->get('acceptance'); $termsCheck = $context->get('terms_cond'); if ($acceptStatus == 'accept' && !isset($termsCheck)) { // Student accepted the invite, but didn't check the terms/conditions box $errorCmd = CommandFactory::getCommand('ShowAcceptRlcInvite'); $errorCmd->setTerm($term); NQ::simple('hms', hms\NotificationView::ERROR, 'Please check the box indicating that you agree to the learning communitiy terms and conditions.'); $errorCmd->redirect(); } else { if ($acceptStatus == 'accept' && isset($termsCheck)) { // Student accepted the invite and checked the terms/conditions box $rlcAssignment->changeState(new RlcAssignmentConfirmedState($rlcAssignment)); NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have <strong>accepted</strong> your Residential Learning Community invitation.'); // Log this! HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_ACCEPT_RLC_INVITE, UserStatus::getUsername(), $rlcAssignment->getRlcName()); $successCmd = CommandFactory::getCommand('ShowStudentMenu'); $successCmd->redirect(); } else { if ($acceptStatus == 'decline') { // student declined $rlcAssignment->changeState(new RlcAssignmentDeclinedState($rlcAssignment)); NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have <strong>declined</strong> your Residential Learning Community invitation.'); // Log this! HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_DECLINE_RLC_INVITE, UserStatus::getUsername(), $rlcAssignment->getRlcName()); $successCmd = CommandFactory::getCommand('ShowStudentMenu'); $successCmd->redirect(); } else { // Didn't choose $errorCmd = CommandFactory::getCommand('ShowAcceptRlcInvite'); $errorCmd->setTerm($term); NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose to either accept or decline your learning community invitation.'); $errorCmd->redirect(); } } } $context->setContent('confirmed or denied'); }
function execute(CommandContext $context) { $msgSystem = ReceiverFactory::getMessageSystem(); $email = $context->get('email'); $msg = $context->get('pass'); $topic = $context->get('topic'); $result = $msgSystem->despatch($email, $msg, $topic); if (!$user) { $this->context->setError($msgSystem->getError()); return false; } $context->addParam("user", $user); return true; }
public function execute(CommandContext $context) { $send_to = array(); $send_to[] = '*****@*****.**'; $send_to[] = '*****@*****.**'; $send_to[] = '*****@*****.**'; $send_to[] = '*****@*****.**'; $from = FROM_ADDRESS; $subject = 'HMS Contact Form'; $body = "Username: "******"\n"; $body .= "Application date: " . $context->get('application_term') . "\n"; $body .= "Student Type: " . $context->get('student_type') . "\n"; $body .= "\n\nInput from student:\n\n"; $body .= "Name: " . $context->get('name') . "\n"; $body .= "Email: " . $context->get('email') . "\n"; $body .= "Phone #: " . $context->get('phone') . "\n"; $body .= "Type: " . $context->get('stype') . "\n"; $body .= "Text field:\n"; $body .= "" . $context->get('comments') . "\n\n"; if (!HMS_Email::send_email($send_to, $from, $subject, $body)) { //Maybe we shouldn't say anything... //NQ::simple('hms', hms\NotificationView::ERROR, 'Error sending email!'); } $view = new ContactFormThankYouView(); $context->setContent($view->show()); }
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(); }