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(); }
/** * The main function for executing the command. */ public function execute() { // Retrieve the values from the request $umbrellaId = $_REQUEST['umbrellaId']; // Retrieve other important values and objects $username = \Current_User::getUsername(); $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdmin($username, $umbrellaId); // If the permissions array is empty then the user does not have permission to use this command // throw an error back to the front end. if (sizeof($permissions) == 0) { echo '<div style="display: none;">User does not have permission to access this data.</div>'; exit; } // Attempt to retrieve the portals and do a fuzzy search of them for the searchString try { $portals = \AppSync\PortalFactory::getPortals(); $searchString = $_REQUEST['searchString']; $umbrella = $_REQUEST['umbrellaId']; $portList = $this->portalFuzzySearch($searchString, $umbrella, $portals); echo $this->encodePortals($portList); } catch (\Exception $e) { echo '<div style="display: none;">' . $e->getMessage() . '</div>'; } exit; }
public static function process() { if (!Current_User::authorized('analytics')) { Current_User::disallow(); } $panel = self::cpanel(); if (isset($_REQUEST['command'])) { $command = $_REQUEST['command']; } else { $command = $panel->getCurrentTab(); } switch ($command) { case 'list': $panel->setContent(self::listTrackers()); break; case 'new': $panel->setContent(self::newTracker()); break; case 'create': $panel->setContent(self::createTracker()); break; case 'edit': $panel->setContent(self::editTracker()); break; case 'delete': $panel->setContent(self::deleteTracker()); break; case 'save_tracker': $panel->setContent(self::saveTracker()); break; } Layout::add(PHPWS_ControlPanel::display($panel->display())); }
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 static function test($value, $show_recursive = FALSE) { if (DEITY_ONLY_TEST && (!isset($_SESSION['User']) || !class_exists('Current_User') || !Current_User::isDeity())) { return; } if (empty($value)) { $value = PHPWS_Debug::emptyVal($value); } switch (1) { case is_object($value): return PHPWS_Debug::testObject($value, 1, $show_recursive); break; case is_array($value): return 'Array' . PHPWS_Debug::testArray($value, 1, $show_recursive); break; case is_bool($value): if ($value) { return '<pre>bool(TRUE)</pre>'; } else { return '<pre>bool(FALSE)</pre>'; } case is_numeric($value): return '<pre>' . $value . '</pre>'; case is_string($value): return '<pre>' . preg_replace('/\\n|(\\r\\n)/', '\\n', htmlspecialchars($value)) . '</pre>'; break; default: return '<pre>' . $value . '</pre>'; } }
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', 'roommate_maintenance')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to create/edit roommate groups.'); } PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $id = $context->get('id'); if (is_null($id)) { throw new InvalidArgumentException('Missing roommate group id.'); } $viewCmd = CommandFactory::getCommand('EditRoommateGroupsView'); try { $roommate = new HMS_Roommate($id); $roommate->delete(); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Error deleting roommate group: ' . $e->getMessage()); $viewCmd->redirect(); } // Log the success $notes = "{$roommate->getRequestor()} requested {$roommate->getRequestee()}"; HMS_Activity_Log::log_activity($roommate->getRequestor(), ACTIVITY_ADMIN_REMOVED_ROOMMATE, UserStatus::getUsername(), $notes); HMS_Activity_Log::log_activity($roommate->getRequestee(), ACTIVITY_ADMIN_REMOVED_ROOMMATE, UserStatus::getUsername(), $notes); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Roommate group successfully deleted.'); $viewCmd->redirect(); }
public function execute(CommandContext $context) { // 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(); }
/** * 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 (!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', '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 __construct($asu_username, $term) { $this->asu_username = $asu_username; $this->term = $term; $this->created_on = time(); $this->created_by = Current_User::getUsername(); }
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 display() { // permissions... if (!\Current_User::isDeity()) { \NQ::simple('intern', NotifyUI::ERROR, 'You cannot edit administrators.'); return false; } // set up some stuff for the page template $tpl = array(); // create the list of admins $adminList = Admin::getAdminPager(); // get the list of departments $depts = Department::getDepartmentsAssoc(); // make the form for adding a new admin $form = new \PHPWS_Form('add_admin'); $form->addSelect('department_id', $depts); $form->setLabel('department_id', 'Department'); $form->addText('username'); $form->setLabel('username', 'Username'); $form->addCheck('all'); $form->setLabel('all', 'All Departments'); $form->addSubmit('submit', 'Create Admin'); $form->setAction('index.php?module=intern&action=edit_admins'); $form->addHidden('add', 1); // TODO: Add Javascript autocomplete for usernames. javascript('jquery'); javascript('jquery_ui'); javascriptMod('intern', 'admin'); $tpl['PAGER'] = $adminList; $form->mergeTemplate($tpl); return \PHPWS_Template::process($form->getTemplate(), 'intern', 'edit_admin.tpl'); }
public function checkRequiredFields(Internship $i) { if (!$i->isSecondaryPart()) { // Check the course subject $courseSubj = $i->getSubject(); if (!isset($courseSubj) || $courseSubj == '' || $courseSubj->id == 0) { throw new MissingDataException("Please select a course subject."); } // Check the course number $courseNum = $i->getCourseNumber(); if (!isset($courseNum) || $courseNum == '') { throw new MissingDataException("Please enter a course number."); } // Check the course section number $sectionNum = $i->getCourseSection(); if (!isset($sectionNum) || $sectionNum == '') { throw new MissingDataException("Please enter a course section number."); } // Check the course credit hours field $creditHours = $i->getCreditHours(); if (!isset($creditHours) || $creditHours == '') { throw new MissingDataException("Please enter the number of course credit hours."); } if (!\Current_User::isDeity() && $creditHours <= 0) { throw new MissingDataException("The number of course credit hours should be greater than zero."); } } }
/** * 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); }
/** * 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 main() { $auth = Current_User::getAuthorization(); if (!Current_User::isLogged() || !$auth->local_user) { PHPWS_Core::errorPage('403'); } $result = $this->init(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'The is a problem with My Page.'))); return; } elseif (!$result) { Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'No modules are registered to My Page.'))); return; } $panel = My_Page::cpanel(); $module = $panel->getCurrentTab(); if (!$this->moduleIsRegistered($module)) { Layout::add(dgettext('users', 'This module is not registered with My Page')); return; } $content = My_Page::userOption($module); if (PHPWS_Error::isError($content)) { $content = $content->getMessage(); } Layout::add(PHPWS_ControlPanel::display($content)); }
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 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 static function setTitle($module, $link, $add_authkey = false) { if ($add_authkey) { $link = sprintf('%s&authkey=%s', $link, Current_User::getAuthKey()); } $GLOBALS['MiniAdmin'][$module]['title_link'] = $link; }
/** * The main function for executing the command. */ public function execute() { // Make sure the user has the appropriate permissions to make changes to the permissions settings. // Basically only deities will have access to permissions. if (!\Current_User::isDeity()) { echo json_encode('user does not have permission to retrieve other user information'); exit; } // Retrieve the permissions from the database $permissions = \AppSync\UmbrellaAdminFactory::getAllUmbrellaAdmins(); $userList = array(); $returnData = array(); // For each permission check to see if the username is in the userList array, // if not then add it to the array foreach ($permissions as $permission) { $username = $permission->getUsername(); if (!in_array($username, $userList, true)) { array_push($userList, $username); } } // For each username add it to an associative array to be sent to the front end foreach ($userList as $user) { $node = array('username' => $user); $returnData[] = $node; } echo json_encode($returnData); exit; }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'edit_role_members')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit role members.'); } $username = $context->get('username'); $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) { // 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 post(\Request $request) { if (!$request->isVar('command')) { throw new \Exception('Unknown Election command'); } $command = $request->getVar('command'); switch ($command) { case 'save': Factory::post(); break; case 'delete': if (\Current_User::isDeity()) { Factory::delete(Factory::pullPostInteger('electionId')); } else { throw new \Exception('Non-deity election deletion not allowed.'); } break; case 'saveTitle': $this->saveTitle(); break; case 'saveDates': $this->saveDates(); break; case 'resetVote': \election\Factory\Vote::resetVote(Factory::pullPostInteger('electionId'), Factory::pullPostInteger('bannerId')); break; default: throw new \Exception('Unknown Election command'); } $view = new \View\JsonView(array('success' => true)); $response = new \Response($view); return $response; }
/** * Returns a concrete instance of a MajorsProvider object, * which can be then be used to fetch the array of Major objects * * @return MajorsProvider */ public static function getProvider() { if (STUDENT_DATA_TEST) { return new TestMajorsProvider(\Current_User::getUsername()); } return new BannerMajorsProvider(\Current_User::getUsername()); }
public function setIpAddress($ip_address) { if (preg_match('/[^\\d\\.]/', $ip_address)) { return FALSE; } $ip_length = strlen((string) $ip_address); if (strpos($ip_address, '.')) { $ip_list = explode('.', $ip_address); } elseif ($ip_length % 3) { return FALSE; } else { for ($i = 0; $i < $ip_length; $i += 3) { $sub = (int) substr($ip_address, $i, 3); $ip_list[] = $sub; } } if (!$this->allow_or_deny) { if ($this->inRange($ip_list, '127.0.0.1')) { return FALSE; } elseif ($this->inRange($ip_list, Current_User::getIp())) { return FALSE; } } foreach ($ip_list as $key => $subset) { if ($subset > 255 || $subset == NULL) { return FALSE; } } $this->ip_address = implode('.', $ip_list); return TRUE; }
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) { $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 __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'); } } */ }