public static function getApplicationFromSession(array $sessionData, $term, Student $student, $applicationType) { $context = new CommandContext(); $context->clearParams(); $context->setParams($sessionData); return ContextApplicationFactory::getApplicationFromContext($context, $term, $student, $applicationType); }
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) { $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 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) { $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) { $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) { 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 (!Current_User::allow('hms', 'room_structure')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to add a room.'); } PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); PHPWS_Core::initModClass('hms', 'HMS_Floor.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Util.php'); PHPWS_Core::initModClass('hms', 'AddRoomView.php'); $floor_id = $context->get('floor'); $tpl = array(); # Setup the title and color of the title bar $tpl['TITLE'] = 'Add Room'; # Check to make sure we have a floor and hall. $floor = new HMS_Floor($floor_id); if (!$floor) { $tpl['ERROR_MSG'] = 'There was an error getting the floor object. Please contact ESS.'; return PHPWS_Template::process($tpl, 'hms', 'admin/add_room.tpl'); } $hall = $floor->get_parent(); if (!$hall) { $tpl['ERROR_MSG'] = 'There was an error getting the hall object. Please contact ESS.'; return PHPWS_Template::process($tpl, 'hms', 'admin/add_room.tpl'); } # Check Permissions if (!Current_User::allow('hms', 'room_structure')) { HMS_Floor::show_edit_floor($floor_id, NULL, 'You do not have permission to add rooms.'); } $view = new AddRoomView($floor); $context->setContent($view->show()); }
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) { 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; } } }
/** * (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(); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'room_view')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to view rooms.'); } // Check for a hall ID $roomId = $context->get('room'); if (!isset($roomId)) { throw new InvalidArgumentException('Missing room ID.'); } // Load the room $room = new HMS_Room($roomId); if ($room->term != Term::getSelectedTerm()) { $roomCmd = CommandFactory::getCommand('SelectRoom'); $roomCmd->setTitle('Edit a Room'); $roomCmd->setOnSelectCmd(CommandFactory::getCommand('EditRoomView')); $roomCmd->redirect(); } // Load the floor/hall $floor = $room->get_parent(); $hall = $floor->get_parent(); // Load the room damages and damage types $damageTypes = DamageTypeFactory::getDamageTypeAssoc(); $roomView = new RoomView($hall, $floor, $room, $damageTypes); $context->setContent($roomView->show()); }
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(); }
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/deny RLC applications.'); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); // Remove assignment $assignment = HMS_RLC_Assignment::getAssignmentById($context->get('assignId')); $rlcName = $assignment->getRlcName(); $rlcApp = $assignment->getApplication(); if (!is_null($assignment)) { $assignment->delete(); } else { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not find an RLC assignment with that id.'); } HMS_Activity_Log::log_activity($rlcApp->getUsername(), ACTIVITY_RLC_UNASSIGN, Current_User::getUsername(), "Removed from {$rlcName}"); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Removed from RLC'); // Deny application $rlcApp->denied = 1; $rlcApp->save(); NQ::simple('hms', hms\NotificationView::SUCCESS, 'RLC Application denied'); HMS_Activity_Log::log_activity($rlcApp->getUsername(), ACTIVITY_DENIED_RLC_APPLICATION, Current_User::getUsername(), 'RLC Application Denied'); $context->goBack(); }
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) { // 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(); }
/** * Exec * * @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); // Check to make sure the file exists if (!file_exists($report->getCsvOutputFilename())) { 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(); } $pdf = file_get_contents($report->getCsvOutputFilename()); // Hoepfully force the browser to open a 'save as' dialogue header('Content-Type: text/csv'); header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1 header('Pragma: public'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Length: ' . strlen($pdf)); header('Content-Disposition: attachment; filename="' . basename($report->getCsvOutputFilename()) . '";'); echo $pdf; exit; }
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 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 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(); }
/** * 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 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) { $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) { 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(); } } }
/** * (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) { $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 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) { PHPWS_Core::initModClass('hms', 'RoommateProfileSearchForm.php'); $term = $context->get('term'); $view = new RoommateProfileSearchForm($term); $context->setContent($view->show()); }
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(); }