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 __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 static function getHMS() { $rh = getallheaders(); if (isset(HMSFactory::$hms)) { return HMSFactory::$hms; } else { if (isset($_REQUEST['ajax']) || !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' || isset($_REQUEST['callback']) || array_key_exists('Accept', $rh) && stripos($rh['Accept'], 'application/json') !== FALSE) { PHPWS_Core::initModClass('hms', 'AjaxHMS.php'); HMSFactory::$hms = new AjaxHMS(); } else { if (UserStatus::isAdmin()) { PHPWS_Core::initModClass('hms', 'AdminHMS.php'); HMSFactory::$hms = new AdminHMS(); } else { if (UserStatus::isUser()) { PHPWS_Core::initModClass('hms', 'UserHMS.php'); HMSFactory::$hms = new UserHMS(); } else { // Guest PHPWS_Core::initModClass('hms', 'GuestHMS.php'); HMSFactory::$hms = new GuestHMS(); } } } } return HMSFactory::$hms; }
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)); } }
function execute(CommandContext $context) { if (!\UserStatus::isAdmin()) { header('Location: ./?action=ShowGuestHome'); } $image_url = "https://placeholdit.imgix.net/~text?txtsize=33&txt=250%C3%97150&w=250&h=150"; if ($_FILES['event_image']['size'] > 0 and $_FILES['event_image']['size'] < 2097152) { $tempFile = $_FILES['event_image']['tmp_name']; $targetPath = PHPWS_SOURCE_DIR . "mod/events/images/"; $targetFile = $targetPath . $_FILES['event_image']['name']; $image_url = "mod/events/images/" . $_FILES['event_image']['name']; move_uploaded_file($tempFile, $targetFile); } var_dump($_POST); var_dump($context); exit; $event_name = $context->get('event_name'); $event_location = $context->get('event_location'); $event_date = strtotime($context->get('event_date')) + 86399; $ticket_prices = $context->get('ticket_prices'); $ticket_location = $context->get('ticket_location'); $open_time = $context->get('open_time'); $start_time = $context->get('start_time'); $event_restrictions = $context->get('event_restrictions'); $artist_details = $context->get('event_details'); $db = \Database::getDB(); $pdo = $db->getPDO(); $query = "INSERT INTO events_events (id, eventname, eventlocation, eventdate, ticketprices, ticketlocation, opentime, starttime, eventrestrictions, artistdetails, imageurl)\n\t\t\t\t\tVALUES (nextval('events_seq'), :event_name, :event_location, :event_date, :ticket_prices, :ticket_location, :open_time, :start_time, :event_restrictions, :artist_details, :image_url)"; $sth = $pdo->prepare($query); $sth->execute(array('event_name' => $event_name, 'event_location' => $event_location, 'event_date' => $event_date, 'ticket_prices' => $ticket_prices, 'ticket_location' => $ticket_location, 'open_time' => $open_time, 'start_time' => $start_time, 'event_restrictions' => $event_restrictions, 'artist_details' => $artist_details, 'image_url' => $image_url)); header('Location: ./?action=ShowAdminHome'); }
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 (!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', 'roommate_maintenance')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to create/edit roommate groups.'); } PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $id = $context->get('id'); if (is_null($id)) { throw new InvalidArgumentException('Missing roommate group id.'); } $viewCmd = CommandFactory::getCommand('EditRoommateGroupsView'); try { $roommate = new HMS_Roommate($id); $roommate->delete(); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Error deleting roommate group: ' . $e->getMessage()); $viewCmd->redirect(); } // Log the success $notes = "{$roommate->getRequestor()} requested {$roommate->getRequestee()}"; HMS_Activity_Log::log_activity($roommate->getRequestor(), ACTIVITY_ADMIN_REMOVED_ROOMMATE, UserStatus::getUsername(), $notes); HMS_Activity_Log::log_activity($roommate->getRequestee(), ACTIVITY_ADMIN_REMOVED_ROOMMATE, UserStatus::getUsername(), $notes); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Roommate group successfully deleted.'); $viewCmd->redirect(); }
public function getStudentById($id, $term) { // Sanity checking on the Banner ID $id = trim($id); if (!isset($id) || empty($id) || $id == '') { throw new InvalidArgumentException('Missing Banner id. Please enter a valid Banner ID (nine digits).'); } if (strlen($id) > 9 || strlen($id) < 9 || !preg_match("/^[0-9]{9}\$/", $id)) { throw new InvalidArgumentException('That was not a valid Banner ID. Please enter a valid Banner ID (nine digits).'); } $student = new Student(); $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER); $soapData = $soap->getStudentProfile($id, $term); if ($soapData->error_num == 1101 && $soapData->error_desc == 'LookupStudentID') { PHPWS_Core::initModClass('hms', 'exception/StudentNotFoundException.php'); throw new StudentNotFoundException('No matching student found.'); } elseif (isset($soapData->error_num) && $soapData->error_num > 0) { //test($soapData,1); throw new SOAPException("Error while accessing SOAP interface: {$soapData->error_desc} ({$soapData->error_num})", $soapData->error_num, 'getStudentProfile', array($id, $term)); } SOAPDataProvider::plugSOAPData($student, $soapData); //SOAPDataProvider::applyExceptions($student); require_once PHPWS_SOURCE_DIR . SOAP_DATA_OVERRIDE_PATH; $dataOverride = new SOAPDataOverride(); $dataOverride->applyExceptions($student); $student->setDataSource(get_class($this)); return $student; }
public function execute(CommandContext $context) { 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() { 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'); }
/** * @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', 'edit_terms')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit terms.'); } $view = new CreateTermView(); $context->setContent($view->show()); }
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 (!UserStatus::isAdmin() || !Current_User::allow('hms', 'bed_structure')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to add a bed.'); } PHPWS_Core::initModClass('hms', 'HMS_Room.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); $errorCmd = CommandFactory::getCommand('ShowAddBed'); $errorCmd->setRoomId($context->get('roomId')); $errorCmd->setBedLetter($context->get('bed_letter')); $errorCmd->setBedroomLabel($context->get('bedroom_label')); $errorCmd->setBannerId($context->get('banner_id')); $viewCmd = CommandFactory::getCommand('EditRoomView'); $viewCmd->setRoomId($context->get('roomId')); $bedLetter = $context->get('bed_letter'); $bedroomLabel = $context->get('bedroom_label'); $bannerId = $context->get('banner_id'); $roomId = $context->get('roomId'); $phoneNumber = $context->get('phone_number'); if (!isset($bedLetter)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must enter a bed letter.'); $errorCmd->redirect(); } if (!isset($bedroomLabel)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must enter a bedroom label.'); $errorCmd->redirect(); } if (!isset($bannerId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must enter a banner ID.'); $errorCmd->redirect(); } if (!isset($roomId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing room ID.'); $errorCmd->redirect(); } $raBed = $context->Get('ra') == 1 ? 1 : 0; $raRoommate = $context->get('ra_roommate') == 1 ? 1 : 0; $intlReserved = $context->get('international_reserved') == 1 ? 1 : 0; $room = new HMS_Room($roomId); if (is_null($room)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not create bed. Invalid room.'); $errorCmd->redirect(); } $term = $room->term; $persistentId = uniqid(); # Try to create the bed try { HMS_Bed::addBed($roomId, $term, $bedLetter, $bedroomLabel, $phoneNumber, $bannerId, $raRoommate, $intlReserved, $raBed, $persistentId); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error creating the bed: ' . $e->getMessage()); $errorCmd->redirect(); } NQ::simple('hms', hms\NotificationView::SUCCESS, 'Bed added successfully.'); $viewCmd->redirect(); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'stats')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You are not allowed to view stats.'); } PHPWS_Core::initModClass('hms', 'StatsView.php'); $view = new StatsView(); $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 show() { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'edit_terms')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit terms.'); } $printable = Term::getPrintableSelectedTerm(); $tpl = array(); $tpl['TITLE'] = dgettext('hms', 'Term settings for ') . $printable; $newTermCmd = CommandFactory::getCommand('ShowCreateTerm'); $tpl['NEW_TERM_URI'] = $newTermCmd->getURI(); // Is this the Current Term? if (Term::isCurrentTermSelected()) { $tpl['CURRENT_TERM_TEXT'] = dgettext('hms', 'This term is the <strong>active term</strong>. To make another term active, please select it from the list at the top-left.'); } else { $tpl['CURRENT_TERM_TEXT'] = dgettext('hms', 'This term is <strong>not</strong> the active term.'); if (Current_User::allow('hms', 'activate_term')) { $cmd = CommandFactory::getCommand('SetCurrentTerm'); $cmd->setTerm(Term::getSelectedTerm()); $tpl['SET_TERM_URI'] = $cmd->getURI(); $tpl['SET_TERM_TEXT'] = "Make <strong>{$printable}</strong> the Current Term"; } } // What's with the Banner Queue? $term = new Term(Term::getSelectedTerm()); if ($term->getBannerQueue()) { $tpl['QUEUE_ENABLED'] = ''; $count = $term->getQueueCount(); $tpl['BANNER_QUEUE_COUNT'] = $count; if ($count > 0) { $cmd = CommandFactory::getCommand('ProcessBannerQueue'); $cmd->setTerm(Term::getSelectedTerm()); $tpl['BANNER_QUEUE_PROCESS_URI'] = $cmd->getURI(); } else { $cmd = CommandFactory::getCommand('DisableBannerQueue'); $cmd->setTerm(Term::getSelectedTerm()); $tpl['BANNER_QUEUE_LINK'] = $cmd->getLink('Disable'); } } else { $tpl['QUEUE_DISABLED'] = ''; $cmd = CommandFactory::getCommand('EnableBannerQueue'); $cmd->setTerm(Term::getSelectedTerm()); $tpl['BANNER_QUEUE_LINK'] = $cmd->getLink('Enable'); } // Terms and Conditions PHPWS_Core::initModClass('hms', 'TermsConditionsAdminView.php'); $tcav = new TermsConditionsAdminView($this->term); $tpl['TERMS_CONDITIONS_CONTENT'] = $tcav->show(); // Features and Deadlines PHPWS_Core::initModClass('hms', 'ApplicationFeatureListView.php'); $aflv = new ApplicationFeatureListView(Term::getSelectedTerm()); $tpl['FEATURES_DEADLINES_CONTENT'] = $aflv->show(); Layout::addPageTitle("Term Settings"); return PHPWS_Template::process($tpl, 'hms', 'admin/TermEditView.tpl'); }
/** * Exec * * @param CommandContext $context * @throws PermissionException */ public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'reports')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to run/view reports.'); } PHPWS_Core::initModClass('hms', 'ReportFactory.php'); PHPWS_Core::initModClass('hms', 'ListReportsView.php'); $reports = ReportFactory::getAllReportControllers(); $reportsList = new ListReportsView($reports); $context->setContent($reportsList->show()); }
public function __construct() { parent::__construct(); if (UserStatus::isAdmin()) { if (Current_User::allow('hms', 'assignment_maintenance')) { $this->addCommandByName('Assign student', 'ShowAssignStudent'); $this->addCommandByName('Unassign student', 'ShowUnassignStudent'); $this->addCommandByName('Set move-in times', 'ShowMoveinTimesView'); } if (Current_User::allow('hms', 'run_hall_overview')) { $hallOverviewCmd = CommandFactory::getCommand('SelectResidenceHall'); $hallOverviewCmd->setTitle('Hall Overview'); $hallOverviewCmd->setOnSelectCmd(CommandFactory::getCommand('HallOverview')); $this->addCommand('Hall Overview', $hallOverviewCmd); } if (Current_User::allow('hms', 'assign_by_floor')) { $floorAssignCmd = CommandFactory::getCommand('AssignByFloor'); $floorAssignCmd->setOnSelectCmd(CommandFactory::getCommand('ShowFloorAssignmentView')); $floorAssignCmd->setTitle('Assign Students to Floor'); $this->addCommand('Assign students by floor', $floorAssignCmd); } if (UserStatus::isAdmin() && Current_User::allow('hms', 'roommate_maintenance')) { $this->addCommandByName('Edit freshmen roommate requests', 'EditRoommateGroupsView'); } if (Current_User::allow('hms', 'autoassign')) { $autoAssignCmd = CommandFactory::getCommand('JSConfirm'); $autoAssignCmd->setLink('Auto-assign'); $autoAssignCmd->setTitle('Auto-assign'); $autoAssignCmd->setQuestion('Start auto-assign process for the selected term?'); $autoAssignCmd->setOnConfirmCommand(CommandFactory::getCommand('ScheduleAutoassign')); $this->addCommand('Start Autoassigner', $autoAssignCmd); } if (Current_User::allow('hms', 'withdrawn_search')) { $withdrawnSearchCmd = CommandFactory::getCommand('JSConfirm'); $withdrawnSearchCmd->setLink('Withdrawn search'); $withdrawnSearchCmd->setTitle('Withdrawn search'); $withdrawnSearchCmd->setQuestion('Start search for withdrawn students for the selected term?'); $withdrawnSearchCmd->setOnConfirmCommand(CommandFactory::getCommand('WithdrawnSearch')); $this->addCommand('Withdrawn search', $withdrawnSearchCmd); } $hms_perm = new HMS_Permission(); $memberships = $hms_perm->getMembership('room_change_approve', NULL, UserStatus::getUsername()); if (!empty($memberships)) { $RDRoomChangeCmd = CommandFactory::getCommand('ShowRDRoomChangeList'); $this->addCommand('Room Change Approval (RD)', $RDRoomChangeCmd); } if (Current_User::allow('hms', 'admin_approve_room_change')) { $adminRoomChangeCmd = CommandFactory::getCommand('ShowAdminRoomChangeList'); $this->addCommand('Room Change Approval (Admin)', $adminRoomChangeCmd); } } }
/** * * @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(); }
/** * (non-PHPdoc) * @see Command::execute() */ public function execute(CommandContext $context) { // Check permissions if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'package_desk')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to access the Package Desk.'); } PHPWS_Core::initModClass('hms', 'PackageDeskFactory.php'); $desks = PackageDeskFactory::getPackageDesksAssoc(); PHPWS_Core::initModClass('hms', 'PackageDeskView.php'); $view = new PackageDeskView($desks); $context->setContent($view->show()); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'activate_term')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to set the Current Term.'); } PHPWS_Core::initModClass('hms', 'TermEditView.php'); $this->term = $context->get('term'); Term::setCurrentTerm($this->term); NQ::simple('hms', hms\NotificationView::SUCCESS, 'The Current Term has been set to ' . Term::getPrintableCurrentTerm()); $cmd = CommandFactory::getCommand('ShowEditTerm'); $cmd->redirect(); }
public function show() { $this->addSignInOut(); $this->addUserStatus(); if (\UserStatus::isAdmin()) { $this->addTermSelector(); } $this->addSearch(); $this->addHallLink(); $this->addReportLink(); $this->addSettings(); return \PHPWS_Template::process($this->tpl, 'hms', 'navbar.tpl'); }
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.'); } if (!is_null($context->get('rlc')) && is_numeric($context->get('rlc'))) { $viewCmd = CommandFactory::getCommand('ShowViewByRlc'); $viewCmd->setRlcId($context->get('rlc')); $viewCmd->redirect(); } $view = new SearchByRlcView(); $context->setContent($view->show()); }
public function __construct() { parent::__construct(); //if(UserStatus::isAdmin() && (Current_User::allow('hms', 'email_hall') || Current_User::allow('hms', 'email_all'))){ $this->addCommandByName('Send messages by Hall', 'ShowHallNotificationSelect'); //} if (UserStatus::isAdmin() && Current_User::allow('hms', 'assignment_notify')) { $cmd = CommandFactory::getCommand('JSConfirm'); $cmd->setLink('Send assignment notifications'); $cmd->setTitle('Send assignment notification emails'); $cmd->setQuestion('Send assignment notification emails for the selected term?'); $cmd->setOnConfirmCommand(CommandFactory::getCommand('SendAssignmentNotification')); $this->addCommand('Send assignment notifications', $cmd); } }
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 create a bed.'); } PHPWS_Core::initModClass('hms', 'HMS_Room.php'); PHPWS_Core::initModClass('hms', 'AddBedView.php'); $roomId = $context->get('roomId'); $room = new HMS_Room($roomId); $floor = $room->get_parent(); $hall = $floor->get_parent(); $addBedView = new AddBedView($hall, $floor, $room, $context->get('bedLetter'), $context->get('bedroomLabel'), $context->get('phoneNumber'), $context->get('bannerId')); $context->setContent($addBedView->show()); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'select_term')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do no have permission to select other terms.'); } if (UserStatus::isGuest()) { $context->goBack(); } if (!isset($this->term)) { $this->term = $context->get('term'); } Term::setSelectedTerm($this->term); $context->goBack(); }