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', '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 __construct() { parent::__construct(); // Check permissions if (UserStatus::isAdmin()) { if (Current_User::allow('hms', 'learning_community_maintenance')) { $this->addCommandByName('Add/Edit Communities', 'ShowEditRlc'); } if (Current_User::allow('hms', 'view_rlc_applications')) { $this->addCommandByName('Assign Applicants to RLCs', 'ShowAssignRlcApplicants'); $this->addCommandByName('View Denied Applications', 'ShowDeniedRlcApplicants'); } if (Current_User::allow('hms', 'learning_community_maintenance')) { $this->addCommandByName('Send RLC Email Invites', 'ShowSendRlcInvites'); } if (Current_User::allow('hms', 'view_rlc_members')) { $this->addCommandByName('View RLC Members by RLC', 'ShowSearchByRlc'); $this->addCommandByName('View RLC Assignments', 'ViewRlcAssignments'); } if (Current_User::allow('hms', 'email_rlc_rejections')) { // Using JSConfirm, ask user if the _really_ want to send the emails $onConfirmCmd = CommandFactory::getCommand('SendRlcRejectionEmails'); $cmd = CommandFactory::getCommand('JSConfirm'); $cmd->setLink('Send RLC Rejection Emails'); $cmd->setTitle('Send RLC Rejection Emails'); $cmd->setQuestion('Send notification emails to denied RLC applicants for selected term?'); $cmd->setOnConfirmCommand($onConfirmCmd); $this->addCommand('Send RLC Rejection Emails', $cmd); } } }
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 __construct() { parent::__construct(); // Check-in if (Current_User::allow('hms', 'checkin')) { $this->addCommandByName('Check-in', 'ShowCheckinStart'); } // Check-out if (Current_User::allow('hms', 'checkin')) { $this->addCommandByName('Check-out', 'ShowCheckoutStart'); } // Room Damage Assessment if (Current_User::allow('hms', 'damage_assessment')) { $this->addCommandByName('Damage Assessment', 'ShowRoomDamageAssessment'); } // Room Damage Notifications if (Current_User::allow('hms', 'damage_notification')) { $this->addCommandByName('Send Room Damage Notices', 'SendRoomDamageNotifications'); $cmd = CommandFactory::getCommand('JSConfirm'); $cmd->setLink('Send Room Damage Notices'); $cmd->setTitle('Send Room Damage Notices'); $cmd->setQuestion('Send room damage notification emails for the selected term?'); $cmd->setOnConfirmCommand(CommandFactory::getCommand('SendRoomDamageNotifications')); $this->addCommand('Send Room Damage Notices', $cmd); } /* if (UserStatus::isAdmin()) { if(Current_User::allow('hms', 'package_desk')){ $this->addCommandByName('Package Desk', 'ShowPackageDeskMenu'); } } */ }
public function __construct() { parent::__construct(); // Check permissions if (UserStatus::isAdmin()) { if (Current_User::allow('hms', 'hall_view')) { $residenceHallCmd = CommandFactory::getCommand('SelectResidenceHall'); $residenceHallCmd->setTitle('Edit a Residence Hall'); $residenceHallCmd->setOnSelectCmd(CommandFactory::getCommand('EditResidenceHallView')); $this->addCommand('Edit a residence hall', $residenceHallCmd); } if (Current_User::allow('hms', 'floor_view')) { $floorCmd = CommandFactory::getCommand('SelectFloor'); $floorCmd->setTitle('Edit a Floor'); $floorCmd->setOnSelectCmd(CommandFactory::getCommand('EditFloorView')); $this->addCommand('Edit a floor', $floorCmd); } if (Current_User::allow('hms', 'room_view')) { $roomCmd = CommandFactory::getCommand('SelectRoom'); $roomCmd->setTitle('Edit a Room'); $roomCmd->setOnSelectCmd(CommandFactory::getCommand('EditRoomView')); $this->addCommand('Edit a room', $roomCmd); } if (Current_User::allow('hms', 'bed_view')) { $bedCmd = CommandFactory::getCommand('SelectBed'); $bedCmd->setTitle('Edit a Bed'); $bedCmd->setOnSelectCmd(CommandFactory::getCommand('EditBedView')); $this->addCommand('Edit a bed', $bedCmd); } } }
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 (!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) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'view_activity_log')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to view the activity log.'); } PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'ActivityLogView.php'); $actee = $context->get('actee'); $actor = $context->get('actor'); $notes = $context->get('notes'); $exact = $context->get('exact'); $begin = $context->get('begin'); $end = $context->get('end'); if (!is_null($begin) && !is_null($end) && $end <= $begin) { unset($_REQUEST['begin_year'], $_REQUEST['begin_month'], $_REQUEST['begin_day'], $_REQUEST['end_year'], $_REQUEST['end_month'], $_REQUEST['end_day']); $begin = null; $end = null; NQ::simple('hms', hms\NotificationView::WARNING, 'Invalid date range. The search results will not be filtered by date.'); } $activityMap = HMS_Activity_Log::getActivityMapping(); $activities = array(); foreach ($activityMap as $i => $t) { $act = $context->get("a{$i}"); if (!is_null($act)) { $activities[] = $i; } } $activityLogView = new ActivityLogView($actee, $actor, $notes, $exact, $begin, $end, $activities); $context->setContent($activityLogView->show()); }
public function show() { Layout::addPageTitle("Hall Notification Edit"); $tpl = array(); $submitCmd = CommandFactory::getCommand('ReviewHallNotificationMessage'); $form = new PHPWS_Form('email_content'); $submitCmd->initForm($form); if (Current_User::allow('hms', 'anonymous_notifications')) { $form->addCheck('anonymous'); $form->setMatch('anonymous', $this->anonymous); $form->setLabel('anonymous', 'Send Anonymously'); } $form->addText('subject', !is_null($this->subject) ? $this->subject : ''); $form->setLabel('subject', 'Subject'); $form->addCssClass('subject', 'form-control'); $form->setSize('subject', 35); $form->setExtra('subject', 'autofocus'); $form->addTextarea('body', !is_null($this->body) ? $this->body : ''); $form->addCssClass('body', 'form-control'); $form->setLabel('body', 'Message:'); if (!empty($this->halls)) { $form->addHidden('hall', $this->halls); } if (!empty($this->floors)) { $form->addHidden('floor', $this->floors); } return PHPWS_Template::process($form->getTemplate(), 'hms', 'admin/hall_notification_email_page.tpl'); }
public function 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 (!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(); }
function showFP() { $db = new PHPWS_DB('ps_page'); $db->addWhere('front_page', 1); if ($db->isTableColumn('deleted')) { $db->addWhere('deleted', 0); } Key::restrictView($db, 'pagesmith'); $db->loadClass('pagesmith', 'PS_Page.php'); $result = $db->getObjects('PS_Page'); if (!PHPWS_Error::logIfError($result) && !empty($result)) { PHPWS_Core::initModClass('pagesmith', 'PageSmith.php'); foreach ($result as $page) { $content = $page->view(); if ($content && !PHPWS_Error::logIfError($content)) { if (Current_User::allow('pagesmith', 'edit_page', $page->id)) { $content .= sprintf('<p class="pagesmith-edit">%s</p>', $page->editLink()); } Layout::add($content, 'pagesmith', 'view_' . $page->id, TRUE); } } } else { return null; } }
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) { // 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 (!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) { // 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) { $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; }
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) { 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()); }
/** * 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); }
/** * 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) { // 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()); }
/** * The main function for executing the command. */ public function execute() { $returnData = array('username' => \Current_User::getUsername(), 'deity' => \Current_User::isDeity(), 'view' => \Current_User::allow('appsync', 'view'), 'purge' => \Current_User::allow('appsync', 'purge')); // Echo the values back to the front end after encoding them. echo json_encode($returnData); exit; }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); Layout::addPageTitle("RLC Application Review"); $tags = array(); if (UserStatus::isAdmin()) { $menuCmd = CommandFactory::getCommand('ShowAssignRlcApplicants'); $tags['MENU_LINK'] = $menuCmd->getURI(); } else { $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $tags['MENU_LINK'] = $menuCmd->getURI(); } $tags['FULL_NAME'] = $this->student->getFullName(); $tags['STUDENT_TYPE'] = $this->student->getPrintableType(); $tags['TERM'] = Term::toString($this->application->getTerm()); $appType = $this->application->getApplicationType(); if ($appType == RLC_APP_FRESHMEN) { $tags['APPLICATION_TYPE'] = 'Freshmen'; } else { if ($appType == RLC_APP_RETURNING) { $tags['APPLICATION_TYPE'] = 'Re-application'; } } $rlcs = HMS_Learning_Community::getRlcList(); $tags['FIRST_CHOICE'] = $rlcs[$this->application->rlc_first_choice_id]; if (isset($this->application->rlc_second_choice_id)) { $tags['SECOND_CHOICE'] = $rlcs[$this->application->rlc_second_choice_id]; } if (isset($this->application->rlc_third_choice_id)) { $tags['THIRD_CHOICE'] = $rlcs[$this->application->rlc_third_choice_id]; } $tags['WHY_SPECIFIC'] = $this->application->why_specific_communities; $tags['STRENGTHS_AND_WEAKNESSES'] = $this->application->strengths_weaknesses; $tags['WHY_FIRST_CHOICE'] = $this->application->rlc_question_0; if (isset($this->application->rlc_second_choice_id)) { $tags['WHY_SECOND_CHOICE'] = $this->application->rlc_question_1; } if (isset($this->application->rlc_second_choice_id)) { $tags['WHY_THIRD_CHOICE'] = $this->application->rlc_question_2; } // If this application is denied and the person logged in is an admin, show a warning if ($this->application->isDenied() && UserStatus::isAdmin()) { NQ::simple('hms', hms\NotificationView::WARNING, 'This application has been denied.'); } // Show options depending of status of application. if (UserStatus::isAdmin() && Current_User::allow('hms', 'approve_rlc_applications')) { if (!$this->application->denied && !HMS_RLC_Assignment::checkForAssignment($this->student->getUsername(), Term::getSelectedTerm())) { // Approve application for the community selected from dropdown $approvalForm = $this->getApprovalForm(); $approvalForm->mergeTemplate($tags); $tags = $approvalForm->getTemplate(); // Deny application $tags['DENY_APP'] = $this->getDenialLink(); } } return PHPWS_Template::process($tags, 'hms', 'student/rlc_application.tpl'); }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); $tpl = array(); $template = new PHPWS_Template('hms'); $template->setFile('admin/review_hall_email.tpl'); if (is_array($this->floors)) { foreach ($this->floors as $floorId) { $floor = new HMS_Floor(); $floor->id = $floorId; $floor->load(); $floor->loadHall(); $tpl['halls'][$floor->_hall->getHallName()][] = 'Floor ' . $floor->getFloorNumber(); } } else { $floor = new HMS_Floor(); $floor->id = $this->floors; $floor->load(); $floor->loadHall(); $tpl['halls'][$floor->_hall->getHallName()][] = 'Floor ' . $floor->getFloorNumber(); } $tpl['FROM'] = $this->anonymous && Current_User::allow('hms', 'anonymous_notifications') ? FROM_ADDRESS : Current_User::getUsername() . '@' . DOMAIN_NAME; $tpl['SUBJECT'] = $this->subject; $tpl['BODY'] = preg_replace('/\\n/', '<br />', $this->body); $editCmd = CommandFactory::getCommand('ShowHallNotificationEdit'); $tpl['EDIT_URI'] = $editCmd->getUri(); /* $form->addHidden('anonymous', isset($this->anonymous) ? $this->anonymous : ''); $form->addHidden('subject', $this->subject); $form->addHidden('body', $this->body); $form->addHidden('hall', $this->halls); $form->addHidden('floor', $this->floors); $form->addSubmit('back', 'Edit Message'); */ $form2 = new PHPWS_Form('review_email'); $sendCmd = CommandFactory::getCommand('SendNotificationEmails'); $sendCmd->initForm($form2); $form2->addHidden('anonymous', isset($this->anonymous) ? $this->anonymous : ''); $form2->addHidden('subject', $this->subject); $form2->addHidden('body', $this->body); $form2->addHidden('hall', $this->halls); $form2->addHidden('floor', $this->floors); foreach ($tpl['halls'] as $hall => $floors) { foreach ($floors as $floor) { $template->setCurrentBlock('floors'); $template->setData(array("FLOOR" => $floor)); $template->parseCurrentBlock(); } $template->setCurrentBlock('halls'); $template->setData(array("HALL" => $hall)); $template->parseCurrentBlock(); } $form2->mergeTemplate($tpl); $tpl = $form2->getTemplate(); $template->setCurrentBlock('remainder'); $template->setData($tpl); $template->parseCurrentBlock(); return $template->get(); }
/** * @see Command::execute() */ public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'hall_attributes')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit halls.'); } // Make sure a hall ID was set $hallId = $context->get('hallId'); if (is_null($hallId)) { throw new InvalidArgumentException('Missing hall ID.'); } $viewCmd = CommandFactory::getCommand('EditResidenceHallView'); $viewCmd->setHallId($hallId); PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); // Create the hall object given the hall id $hall = new HMS_Residence_Hall($hallId); if (!$hall) { NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid hall.'); $viewCmd->redirect(); } if ($context->get('tab') == 'settings') { // Compare the hall's gender and the gender the user selected // If they're not equal, call 'can_change_gender' public function if ($hall->gender_type != $_REQUEST['gender_type']) { if (!$hall->can_change_gender($_REQUEST['gender_type'])) { NQ::simple('hms', hms\NotificationView::ERROR, 'Incompatible gender detected. No changes were made.'); $viewCmd->redirect(); } } // Grab all the input from the form and save the hall $hall->hall_name = $context->get('hall_name'); $hall->gender_type = $context->get('gender_type'); // Set the defaults for the check boxes $context->setDefault('air_conditioned', 0); $context->setDefault('is_online', 0); $context->setDefault('meal_plan_required', 0); $context->setDefault('assignment_notifications', 0); $hall->air_conditioned = $context->get('air_conditioned'); $hall->is_online = $context->get('is_online'); $hall->meal_plan_required = $context->get('meal_plan_required'); $hall->assignment_notifications = $context->get('assignment_notifications'); $hall->setPackageDeskId($context->get('package_desk')); } else { if ($context->get('tab') == 'images') { $hall->exterior_image_id = $context->get('exterior_image_id'); $hall->other_image_id = $context->get('other_image_id'); $hall->map_image_id = $context->get('map_image_id'); $hall->room_plan_image_id = $context->get('room_plan_image_id'); } } $result = $hall->save(); if (!$result || PHPWS_Error::logIfError($result)) { NQ::simple('hms', hms\NotificationView::ERROR, 'There was a problem saving the Residence Hall. No changes were made.'); $viewCmd->redirect(); } NQ::simple('hms', hms\NotificationView::SUCCESS, 'The Residence hall was updated successfully.'); $viewCmd->redirect(); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'learning_community_maintenance')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit RLCs.'); } $view = new EditRlcView(); $context->setContent($view->show()); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'view_rlc_members')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to view RLC members.'); } $view = new RlcAssignmentsView(); $context->setContent($view->show()); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'lottery_admin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to add lottery entries.'); } $view = new LotteryWaitingListView(); $context->setContent($view->show()); }