Beispiel #1
0
 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 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.");
         }
     }
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
Beispiel #5
0
 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;
 }
 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');
 }
 /**
  * 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 change permissions");
         exit;
     }
     // Retrieve the input values from the request
     $username = $_REQUEST['username'];
     $umbrellaId = $_REQUEST['umbrella'];
     // Retrieve the permissions from the database
     $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdmin($username, $umbrellaId);
     // If they already have permission to the given umbrella, then do nothing, otherwise
     // add the permission to their account.
     if (sizeof($permissions) == 0) {
         $newAdmin = new \AppSync\UmbrellaAdmin(null, $username, $umbrellaId);
         \AppSync\UmbrellaAdminFactory::save($newAdmin);
         echo json_encode("success");
         exit;
     } else {
         echo json_encode("already exists");
         exit;
     }
 }
 public function execute(CommandContext $context)
 {
     if (!Current_User::isDeity()) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit terms.');
     }
     PHPWS_Core::initModClass('hms', 'PulseEditView.php');
     $pulse = new PulseEditView();
     $context->setContent($pulse->show());
 }
 /**
  * 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 change permissions");
         exit;
     }
     // Retrieve the input values from the request
     $username = $_REQUEST['username'];
     $umbrellaId = $_REQUEST['umbrella'];
     // Remove the permission from the database
     \AppSync\UmbrellaAdminFactory::removeUmbrellaAdmin($username, $umbrellaId);
     // Echo the fact that it succeeded back to the front end
     echo json_encode("success");
     exit;
 }
 /**
  * Main display method
  */
 public function display()
 {
     javascript('jquery');
     // housekeeping
     if (isset($_SESSION['query'])) {
         unset($_SESSION['query']);
     }
     $tags = array();
     // Total number of internships for Diety users
     if (\Current_User::isDeity()) {
         $tags['GRAND_TOTAL_LABEL'] = _('Total Internships in Database: ');
         $db = new \PHPWS_DB('intern_internship');
         $gt = $db->select('count');
         $tags['GRAND_TOTAL'] = $gt;
     }
     // Example form link
     $tags['EXAMPLE_LINK'] = \PHPWS_Text::secureLink('Example form', 'intern', array('action' => 'example_form'));
     return \PHPWS_Template::process($tags, 'intern', 'menu.tpl');
 }
 /**
  * The main function for executing the command.
  */
 public function execute()
 {
     // Make sure the user has the appropriate permissions to access settings.
     // Basically only deities will have access to settings.
     if (!\Current_User::isDeity()) {
         echo json_encode('user does not have permission to retrieve live state');
         exit;
     }
     // Set the variables to base values
     $liveUrl = '';
     $testUrl = '';
     $key = '';
     $bannerUrl = '';
     // Retrieve the settings from the database
     $liveUrlSetting = \AppSync\SettingFactory::getSetting('orgsync_live_url');
     $testUrlSetting = \AppSync\SettingFactory::getSetting('orgsync_test_url');
     $keySetting = \AppSync\SettingFactory::getSetting('orgsync_key');
     $bannerUrlSetting = \AppSync\SettingFactory::getSetting('banner_url');
     // If the settings are non null then set the variables, otherwise leave them empty
     if ($liveUrlSetting) {
         $liveUrl = $liveUrlSetting->getValue();
     }
     if ($testUrlSetting) {
         $testUrl = $testUrlSetting->getValue();
     }
     if ($keySetting) {
         $key = $keySetting->getValue();
     }
     if ($bannerUrlSetting) {
         $bannerUrl = $bannerUrlSetting->getValue();
     }
     // If the state is not set it, set it to LIVE and use that as the state,
     // otherwise use the current state.
     if ($_SESSION['state'] != null) {
         $state = $_SESSION['state'];
     } else {
         $state = 'LIVE';
         $_SESSION['state'] = 'LIVE';
     }
     // Echo the values back to the front end after encoding them.
     echo json_encode(array('state' => $state, 'liveUrl' => $liveUrl, 'testUrl' => $testUrl, 'key' => $key, 'bannerUrl' => $bannerUrl));
     exit;
 }
 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 permissions');
         exit;
     }
     // Retrieve the permissions from the database
     $permissions = \AppSync\UmbrellaAdminFactory::getAllUmbrellaAdmins();
     $userList = array();
     $returnData = array();
     // For each permission if the username is not in the userList array add them
     foreach ($permissions as $permission) {
         $username = $permission->getUsername();
         if (!in_array($username, $userList, true)) {
             array_push($userList, $username);
         }
     }
     // For each user in the userList array create a permissionList that will be
     // returned to the front end
     foreach ($userList as $username) {
         $permissionList = "";
         $first = true;
         foreach ($permissions as $permission) {
             if ($permission->getUsername() == $username) {
                 $umbrella = \AppSync\UmbrellaFactory::getUmbrellaByOrgId($permission->getUmbrellaId());
                 if ($first) {
                     $permissionList = $umbrella->getName();
                     $first = false;
                 } else {
                     $permissionList .= ', ' . $umbrella->getName();
                 }
             }
         }
         $node = array('username' => $username, 'permissions' => $permissionList);
         array_push($returnData, $node);
     }
     // Echo the json encoded data back to the front end.
     echo json_encode($returnData);
     exit;
 }
 /**
  * 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 change permissions");
         exit;
     }
     // Retrieve the umbrellas
     $umbrellasResult = \AppSync\UmbrellaFactory::getUmbrellas();
     $umbrellas = array();
     $i = 0;
     // For each umbrella add it to the umbrellas array as an id and a name
     foreach ($umbrellasResult as $umbrella) {
         $umbrellas[$i]['umbrella_id'] = $umbrella->getOrgSyncId();
         $umbrellas[$i]['umbrella_name'] = $umbrella->getName();
         $i++;
     }
     // Echo the json encoded array back to the front end.
     echo json_encode($umbrellas);
     exit;
 }
Beispiel #14
0
 public function getController(\Request $request)
 {
     $cmd = $request->shiftCommand();
     if ($cmd == 'admin' && \Current_User::isDeity()) {
         $admin = new \pulse\PulseAdminController($this);
         return $admin;
     } else {
         if (!\Settings::get('pulse', 'allow_web_access')) {
             exit('Web access to pulse is not allowed.');
         }
         try {
             PulseController::runSchedules($request);
         } catch (Exception\PulseException $e) {
             PulseFactory::logError($e->getMessage() . "\n" . $e->getFile() . ':' . $e->getLine());
             exit('Error: ' . $e->getMessage());
         } catch (\Exception $e) {
             PulseFactory::logError($e->getMessage() . "\n" . $e->getFile() . ':' . $e->getLine());
             exit('An error occurred outside the scope of Pulse.');
         }
         exit;
     }
 }
 public static function plug()
 {
     $tpl = array();
     $tpl['HOME_LINK'] = PHPWS_Text::moduleLink('Menu', 'intern');
     $tpl['ADD_LINK'] = PHPWS_Text::moduleLink('Add Student', 'intern', array('action' => 'edit_internship'));
     $tpl['SEARCH_LINK'] = PHPWS_Text::moduleLink('Search', 'intern', array('action' => 'search'));
     $auth = Current_User::getAuthorization();
     $tpl['USER_FULL_NAME'] = Current_User::getDisplayName();
     $tpl['LOGOUT_URI'] = $auth->logout_link;
     $adminOptions = array();
     // Edit list of majors
     if (Current_User::allow('intern', 'edit_major')) {
         $adminOptions['EDIT_MAJORS_LINK'] = PHPWS_Text::secureLink('Edit Undergraduate Majors', 'intern', array('action' => MAJOR_EDIT));
     }
     // Edit list grad programs
     if (Current_User::allow('intern', 'edit_grad_prog')) {
         $adminOptions['EDIT_GRAD_LINK'] = PHPWS_Text::secureLink('Edit Graduate Programs', 'intern', array('action' => GRAD_PROG_EDIT));
     }
     // Edit departments
     if (Current_User::allow('intern', 'edit_dept')) {
         $adminOptions['EDIT_DEPARTMENTS_LINK'] = PHPWS_Text::secureLink('Edit Departments', 'intern', array('action' => DEPT_EDIT));
     }
     // Edit list of states
     if (Current_User::allow('intern', 'edit_states')) {
         $adminOptions['EDIT_STATES_LINK'] = PHPWS_Text::secureLink('Edit States', 'intern', array('action' => STATE_EDIT));
     }
     if (Current_User::isDeity()) {
         $adminOptions['CONTROL_PANEL'] = PHPWS_Text::secureLink('Control Panel', 'controlpanel');
         $adminOptions['EDIT_ADMINS_LINK'] = PHPWS_Text::secureLink('Edit Administrators', 'intern', array('action' => 'edit_admins'));
     }
     // If any admin options were added, them show the dropdown and merge those
     // links into the main set of template tags
     if (sizeof($adminOptions) > 0) {
         $tpl['ADMIN_OPTIONS'] = '';
         // dummy var to show dropdown menu in template
         $tpl = array_merge($tpl, $adminOptions);
     }
     Layout::plug(PHPWS_Template::process($tpl, 'intern', 'top.tpl'), 'NAV_LINKS');
 }
 public function execute()
 {
     // Get list of departments for the current user
     // If user is a Deity, then get all departments
     if (\Current_User::isDeity()) {
         $departments = \Intern\Department::getDepartmentsAssoc();
     } else {
         $departments = \Intern\Department::getDepartmentsAssocForUsername(\Current_User::getUsername());
     }
     $departments = array('-1' => 'Select a Department') + $departments;
     /*
      * NB: Javascript objects are unordered. When the JSON data is
      * decoded, numeric keys may be re-arraged. Making the keys into strings
      * (by pre-pending an underscore) will prevent the re-ordering.
      */
     $newDepts = array();
     foreach ($departments as $key => $value) {
         $newDepts['_' . $key] = $value;
     }
     echo json_encode($newDepts);
     exit;
 }
Beispiel #17
0
 private function addSettings()
 {
     //$this->tpl['DROPDOWN'] = '';
     //$this->tpl['SETTINGS'][] = array('LINK' => $ctrlPanel->getLink('Control Panel'));
     if (\Current_User::allow('hms', 'edit_terms')) {
         $termCmd = \CommandFactory::getCommand('ShowEditTerm');
         $this->tpl['EDIT_TERM_URI'] = $termCmd->getURI();
     }
     if (\Current_User::allow('hms', 'view_activity_log')) {
         $termCmd = \CommandFactory::getCommand('ShowActivityLog');
         $this->tpl['ACTIVITY_LOG_URI'] = $termCmd->getURI();
     }
     if (\Current_User::isDeity()) {
         $ctrlPanel = \CommandFactory::getCommand('ShowControlPanel');
         $this->tpl['CTRL_PANEL_URI'] = $ctrlPanel->getURI();
         $pulse = \CommandFactory::getCommand('ShowPulseOption');
         $this->tpl['PULSE_URI'] = $pulse->getURI();
     }
 }
 /**
  * Builds the body of the internship form.
  */
 public function buildInternshipForm()
 {
     javascript('jquery');
     javascript('jquery_ui');
     javascriptMod('intern', 'spinner');
     javascriptMod('intern', 'formGoodies');
     // Form Submission setup
     $this->form->setAction('index.php?module=intern&action=add_internship');
     $this->form->addSubmit('submit', 'Save');
     /*********************
      * Workflow / Status *
      */
     PHPWS_Core::initModClass('intern', 'WorkflowStateFactory.php');
     PHPWS_Core::initModClass('intern', 'WorkflowTransitionView.php');
     // Check the Internship's state, and set a default state if it's a new internship
     $workflowState = $this->intern->getWorkflowState();
     if (is_null($workflowState)) {
         $state = WorkflowStateFactory::getState('CreationState');
         $this->intern->setState($state);
         // Set this initial value
     }
     // Workflow Transitions View, adds fields to the form by reference
     $transView = new WorkflowTransitionView($this->intern, $this->form);
     $transView->show();
     /*****************
      * OIED Approval *
      */
     $this->form->addCheck('oied_certified');
     $this->form->setLabel('oied_certified', 'Certified by Office of International Education and Development');
     // If the user is not allowed to do OIED certification, disable the checkbox
     if (!Current_User::allow('intern', 'oied_certify') || $this->intern->isDomestic()) {
         $this->form->setExtra('oied_certified', 'disabled');
     }
     // Hidden field that shadows the real field, to ensure a value is always submitted,
     // because disabled fields are not submitted
     $this->form->addHidden('oied_certified_hidden');
     /******************
      * Student fields *
      */
     $this->form->addText('student_first_name');
     $this->form->setLabel('student_first_name', 'First Name');
     $this->form->addCssClass('student_first_name', 'form-control');
     $this->form->addText('student_middle_name');
     $this->form->setLabel('student_middle_name', 'Middle Name/Initial');
     $this->form->addCssClass('student_middle_name', 'form-control');
     $this->form->addText('student_last_name');
     $this->form->setLabel('student_last_name', 'Last Name');
     $this->form->addCssClass('student_last_name', 'form-control');
     $this->form->addText('banner');
     $this->form->setLabel('banner', 'Banner ID');
     // Digits only
     $this->form->addCssClass('banner', 'form-control');
     $this->form->addText('student_phone');
     $this->form->setLabel('student_phone', 'Phone');
     $this->form->addCssClass('student_phone', 'form-control');
     $this->form->addText('student_email');
     $this->form->setLabel('student_email', 'ASU Email');
     $this->form->addCssClass('student_email', 'form-control');
     /* Student Address */
     $this->form->addText('student_address');
     $this->form->setLabel('student_address', 'Address');
     $this->form->addCssClass('student_address', 'form-control');
     $this->form->addText('student_city');
     $this->form->setLabel('student_city', 'City');
     $this->form->addCssClass('student_city', 'form-control');
     $this->form->addDropBox('student_state', State::$UNITED_STATES);
     $this->form->setLabel('student_state', 'State');
     $this->form->addCssClass('student_state', 'form-control');
     $this->form->addText('student_zip');
     $this->form->setLabel('student_zip', 'Zip Code');
     $this->form->addCssClass('student_zip', 'form-control');
     // GPA
     $this->form->addText('student_gpa');
     $this->form->setLabel('student_gpa', 'GPA');
     $this->form->addCssClass('student_gpa', 'form-control');
     // Campus
     $this->form->addRadioAssoc('campus', array('main_campus' => 'Main Campus', 'distance_ed' => 'Distance Ed'));
     $this->form->setMatch('campus', 'main_campus');
     // Student level
     $levels = array('-1' => 'Choose level', 'ugrad' => 'Undergraduate', 'grad' => 'Graduate');
     $this->form->addDropBox('student_level', $levels);
     $this->form->setLabel('student_level', 'Level');
     $this->form->addCssClass('student_level', 'form-control');
     // Student Major dummy box (gets replaced by dropdowns below using JS when student_level is selected)
     $levels = array('-1' => 'Choose student level first');
     $this->form->addDropBox('student_major', $levels);
     $this->form->setLabel('student_major', 'Major / Program');
     $this->form->addCssClass('student_major', 'form-control');
     /*****************************
      * Undergrad Major Drop Down *
      */
     if (isset($this->intern)) {
         $majors = Major::getMajorsAssoc($this->intern->ugrad_major);
     } else {
         $majors = Major::getMajorsAssoc();
     }
     $this->form->addSelect('ugrad_major', $majors);
     $this->form->setLabel('ugrad_major', 'Undergraduate Majors &amp; Certificate Programs');
     $this->form->addCssClass('ugrad_major', 'form-control');
     /****************************
      * Graduate Major Drop Down *
      */
     if (isset($this->intern)) {
         $progs = GradProgram::getGradProgsAssoc($this->intern->grad_prog);
     } else {
         $progs = GradProgram::getGradProgsAssoc();
     }
     $this->form->addSelect('grad_prog', $progs);
     $this->form->setLabel('grad_prog', 'Graduate Majors &amp; Certificate Programs');
     $this->form->addCssClass('grad_prog', 'form-control');
     /************************
      * Department Drop Down *
      */
     if (Current_User::isDeity()) {
         if (!is_null($this->intern)) {
             $depts = Department::getDepartmentsAssoc($this->intern->department_id);
         } else {
             $depts = Department::getDepartmentsAssoc();
         }
     } else {
         if (!is_null($this->intern)) {
             $depts = Department::getDepartmentsAssocForUsername(Current_User::getUsername(), $this->intern->department_id);
         } else {
             $depts = Department::getDepartmentsAssocForUsername(Current_User::getUsername());
         }
     }
     $this->form->addSelect('department', $depts);
     $this->form->setLabel('department', 'Department');
     $this->form->addCssClass('department', 'form-control');
     // If the user only has one department, select it for them
     // sizeof($depts) == 2 because of the 'Select Deparmtnet' option
     if (sizeof($depts) == 2) {
         $keys = array_keys($depts);
         $this->form->setMatch('department', $keys[1]);
     }
     /********************
      * Faculty Member Dropdown
      *
      * The options for this drop down are provided through AJAX on page-load and
      * when the user changes the department dropdown above.
      */
     $this->form->addSelect('faculty', array(-1 => 'Select Faculty Advisor'));
     $this->form->setExtra('faculty', 'disabled');
     $this->form->setLabel('faculty', 'Faculty Advisor / Instructor of Record');
     $this->form->addCssClass('faculty', 'form-control');
     // Hidden field for selected faculty member
     $this->form->addHidden('faculty_id');
     /***************
      * Agency info *
      */
     $this->form->addText('agency_name');
     $this->form->setLabel('agency_name', 'Agency Name');
     $this->form->addCssClass('agency_name', 'form-control');
     $this->form->addCheck('copy_address_agency');
     $this->form->setLabel('copy_address_agency', "Agency's address is same as Internship's");
     $this->form->addText('agency_address');
     $this->form->setLabel('agency_address', 'Address');
     $this->form->addCssClass('agency_address', 'form-control');
     $this->form->addText('agency_city');
     $this->form->setLabel('agency_city', 'City');
     $this->form->addCssClass('agency_city', 'form-control');
     $this->form->addSelect('agency_state', State::$UNITED_STATES);
     $this->form->setLabel('agency_state', 'State');
     $this->form->addCssClass('agency_state', 'form-control');
     $this->form->addText('agency_zip');
     $this->form->setLabel('agency_zip', 'Zip Code');
     $this->form->addCssClass('agency_zip', 'form-control');
     $this->form->addText('agency_province');
     $this->form->setLabel('agency_province', 'Province/Territory');
     $this->form->addCssClass('agency_province', 'form-control');
     $this->form->addText('agency_country');
     $this->form->setLabel('agency_country', 'Country');
     $this->form->addCssClass('agency_country', 'form-control');
     $this->form->addText('agency_phone');
     $this->form->setLabel('agency_phone', 'Phone');
     $this->form->addCssClass('agency_phone', 'form-control');
     /***
      * Agency supervisor info
      */
     $this->form->addText('agency_sup_first_name');
     $this->form->setLabel('agency_sup_first_name', 'First Name');
     $this->form->addCssClass('agency_sup_first_name', 'form-control');
     $this->form->addText('agency_sup_last_name');
     $this->form->setLabel('agency_sup_last_name', 'Last Name');
     $this->form->addCssClass('agency_sup_last_name', 'form-control');
     $this->form->addText('agency_sup_title');
     $this->form->setLabel('agency_sup_title', 'Title');
     $this->form->addCssClass('agency_sup_title', 'form-control');
     $this->form->addText('agency_sup_phone');
     $this->form->setLabel('agency_sup_phone', 'Phone');
     $this->form->addCssClass('agency_sup_phone', 'form-control');
     $this->form->addText('agency_sup_email');
     $this->form->setLabel('agency_sup_email', 'Email');
     $this->form->addCssClass('agency_sup_email', 'form-control');
     $this->form->addCheck('copy_address');
     $this->form->setLabel('copy_address', "Supervisor's address is same as agency's");
     $this->form->addText('agency_sup_address');
     $this->form->setLabel('agency_sup_address', 'Address');
     $this->form->addCssClass('agency_sup_address', 'form-control');
     $this->form->addText('agency_sup_city');
     $this->form->setLabel('agency_sup_city', 'City');
     $this->form->addCssClass('agency_sup_city', 'form-control');
     $this->form->addSelect('agency_sup_state', State::$UNITED_STATES);
     $this->form->setLabel('agency_sup_state', 'State');
     $this->form->addCssClass('agency_sup_state', 'form-control');
     $this->form->addText('agency_sup_zip');
     $this->form->setLabel('agency_sup_zip', 'Zip Code');
     $this->form->addCssClass('agency_sup_zip', 'form-control');
     $this->form->addText('agency_sup_province');
     $this->form->setLabel('agency_sup_province', 'Province');
     $this->form->addCssClass('agency_sup_province', 'form-control');
     $this->form->addText('agency_sup_country');
     $this->form->setLabel('agency_sup_country', 'Country');
     $this->form->addCssClass('agency_sup_country', 'form-control');
     $this->form->addText('agency_sup_fax');
     $this->form->setLabel('agency_sup_fax', 'Fax');
     $this->form->addCssClass('agency_sup_fax', 'form-control');
     /**********************
      * Internship details *
      */
     /***********************
      * Internship location *
      */
     $loc = array('domestic' => 'Domestic', 'internat' => 'International');
     $this->form->addRadioAssoc('location', $loc);
     //$this->form->setMatch('location', 'domestic'); // Default to domestic
     //$this->form->setRequired('location');
     // Domestic fields
     $this->form->addText('loc_address');
     $this->form->setLabel('loc_address', 'Address');
     $this->form->addCssClass('loc_address', 'form-control');
     $this->form->addText('loc_city');
     $this->form->setLabel('loc_city', 'City');
     $this->form->addCssClass('loc_city', 'form-control');
     $this->form->addSelect('loc_state', State::getAllowedStates());
     $this->form->setLabel('loc_state', 'State');
     $this->form->addCssClass('loc_state', 'form-control');
     $this->form->addText('loc_zip');
     $this->form->setLabel('loc_zip', 'Zip');
     $this->form->addCssClass('loc_zip', 'form-control');
     // Itn'l location fields
     $this->form->addText('loc_province');
     $this->form->setLabel('loc_province', 'Province/Territory');
     $this->form->addCssClass('loc_province', 'form-control');
     $this->form->addText('loc_country');
     $this->form->setLabel('loc_country', 'Country');
     $this->form->addCssClass('loc_country', 'form-control');
     /*************
      * Term Info *
      */
     $terms = Term::getFutureTermsAssoc();
     $terms[-1] = 'Select Term';
     $this->form->addSelect('term', $terms);
     $this->form->setLabel('term', 'Select Term');
     $this->form->addCssClass('term', 'form-control');
     $this->form->addText('start_date');
     $this->form->setLabel('start_date', 'Start Date');
     $this->form->addCssClass('start_date', 'form-control');
     $this->form->addText('end_date');
     $this->form->setLabel('end_date', 'End Date');
     $this->form->addCssClass('end_date', 'form-control');
     $this->form->addText('credits');
     $this->form->setLabel('credits', 'Credit Hours');
     $this->form->addCssClass('credits', 'form-control');
     $this->form->addText('avg_hours_week');
     $this->form->setLabel('avg_hours_week', 'Average Hours per Week');
     $this->form->addCssClass('avg_hours_week', 'form-control');
     $this->form->addCheck('multipart');
     $this->form->setLabel('multipart', 'This internship is part of a multi-part experience.');
     $this->form->addCheck('secondary_part');
     $this->form->setLabel('secondary_part', 'This is a secondary part (enrollment complete through primary part).');
     /***************
      * Course Info *
      */
     $subjects = Subject::getSubjects();
     $this->form->addSelect('course_subj', $subjects);
     $this->form->setLabel('course_subj', 'Subject');
     $this->form->addCssClass('course_subj', 'form-control');
     $this->form->addText('course_no');
     $this->form->setLabel('course_no', 'Number');
     $this->form->addCssClass('course_no', 'form-control');
     $this->form->addText('course_sect');
     $this->form->setLabel('course_sect', 'Section');
     $this->form->addCssClass('course_sect', 'form-control');
     $this->form->addText('course_title');
     $this->form->setLabel('course_title', 'Title');
     $this->form->setMaxSize('course_title', 28);
     // Limit to 28 chars, per Banner
     $this->form->addCssClass('course_title', 'form-control');
     // Corequisite
     if (!is_null($this->intern)) {
         $dept = $this->intern->getDepartment();
         if ($dept->hasCorequisite()) {
             $this->form->addText('corequisite_course_num');
             $this->form->addCssClass('corequisite_course_num', 'form-control');
             $this->form->addText('corequisite_course_sect');
             $this->form->addCssClass('corequisite_course_sect', 'form-control');
         }
     }
     /************
      * Pay Info *
      */
     $pay = array('unpaid' => 'Unpaid', 'paid' => 'Paid');
     $this->form->addRadioAssoc('payment', $pay);
     $this->form->setMatch('payment', 'unpaid');
     // Default to unpaid
     $this->form->addCheck('stipend');
     $this->form->setLabel('stipend', 'Stipend');
     $this->form->addText('pay_rate');
     $this->form->setLabel('pay_rate', 'Pay Rate');
     $this->form->addCssClass('pay_rate', 'form-control');
     /*******************
      * Internship Type *
      */
     $this->form->addRadioAssoc('experience_type', Internship::getTypesAssoc());
     $this->form->setMatch('experience_type', 'internship');
     /*********
      * Notes *
      */
     $this->form->addTextArea('notes');
     $this->form->setLabel('notes', 'Notes');
     $this->form->addCssClass('notes', 'form-control');
 }
 /**
  * Return an associative array {id => dept. name} for all the departments
  * that the user with $username is allowed to see.
  * @param $includeHiddenDept - Include the department with this ID, even if it's hidden. Used for internships
  *                  with a hidden department. We still want to see it in the select box. 
  */
 public static function getDepartmentsAssocForUsername($username, $includeHiddenDept = null)
 {
     $db = self::getDb();
     $db->addOrder('name');
     $db->addColumn('id');
     $db->addColumn('name');
     $db->addWhere('hidden', 0, '=', 'OR', 'grp');
     if (!is_null($includeHiddenDept)) {
         $db->addWhere('id', $except, '=', 'OR', 'grp');
     }
     // If the user doesn't have the 'all_departments' permission,
     // then add a join to limit to specific departments
     if (!Current_User::allow('intern', 'all_departments') && !Current_User::isDeity()) {
         $db->addJoin('LEFT', 'intern_department', 'intern_admin', 'id', 'department_id');
         $db->addWhere('intern_admin.username', $username);
     }
     $db->setIndexBy('id');
     $depts[-1] = 'Select Department';
     $depts += $db->select('col');
     return $depts;
 }
 public static function moveBoxMenu()
 {
     $box = new Layout_Box($_GET['box']);
     $vars['action'] = 'admin';
     $vars['command'] = 'moveBox';
     $vars['box_source'] = $box->id;
     $vars['box_dest'] = 'move_box_top';
     $step_links[] = PHPWS_Text::secureLink(dgettext('layout', 'Move to top'), 'layout', $vars);
     $vars['box_dest'] = 'move_box_up';
     $step_links[] = PHPWS_Text::secureLink(dgettext('layout', 'Move up'), 'layout', $vars);
     $vars['box_dest'] = 'move_box_down';
     $step_links[] = PHPWS_Text::secureLink(dgettext('layout', 'Move down'), 'layout', $vars);
     $vars['box_dest'] = 'move_box_bottom';
     $step_links[] = PHPWS_Text::secureLink(dgettext('layout', 'Move to bottom'), 'layout', $vars);
     if (Current_User::isDeity() && !$_SESSION['Layout_Settings']->deity_reload) {
         $_SESSION['Layout_Settings']->loadSettings();
     }
     $themeVars = $_SESSION['Layout_Settings']->getAllowedVariables();
     foreach ($themeVars as $var) {
         if ($box->theme_var == $var) {
             continue;
         }
         $vars['box_dest'] = $var;
         $theme_links[] = PHPWS_Text::secureLink(sprintf(dgettext('layout', 'Send to %s'), $var), 'layout', $vars);
     }
     $vars['box_dest'] = 'restore';
     $template['RESTORE'] = PHPWS_Text::secureLink(dgettext('layout', 'Restore to default'), 'layout', $vars);
     $template['STEP_LINKS'] = implode('<br>', $step_links);
     $template['THEME_LINKS'] = implode('<br>', $theme_links);
     $template['CANCEL'] = sprintf('<a href="." onclick="window.close()">%s</a>', dgettext('layout', 'Cancel'));
     $template['TITLE'] = sprintf(dgettext('layout', 'Move box: %s'), $box->content_var);
     $content = PHPWS_Template::process($template, 'layout', 'move_box_select.tpl');
     Layout::nakedDisplay($content);
 }
Beispiel #21
0
 public function loadPanel()
 {
     PHPWS_Core::initModClass('controlpanel', 'Panel.php');
     $link = 'index.php?module=filecabinet';
     $image_command = array('title' => dgettext('filecabinet', 'Image folders'), 'link' => $link);
     $document_command = array('title' => dgettext('filecabinet', 'Document folders'), 'link' => $link);
     $multimedia_command = array('title' => dgettext('filecabinet', 'Multimedia folders'), 'link' => $link);
     $tabs['image'] = $image_command;
     $tabs['document'] = $document_command;
     $tabs['multimedia'] = $multimedia_command;
     if (Current_User::isDeity()) {
         $tabs['classify'] = array('title' => dgettext('filecabinet', 'Classify'), 'link' => $link);
         $tabs['settings'] = array('title' => dgettext('filecabinet', 'Settings'), 'link' => $link);
         $tabs['file_types'] = array('title' => dgettext('filecabinet', 'File types'), 'link' => $link);
     }
     $this->panel = new PHPWS_Panel('filecabinet');
     $this->panel->quickSetTabs($tabs);
     $this->panel->setModule('filecabinet');
 }
Beispiel #22
0
 /**
  * This function adds links to the navigation bar at the top of the page.
  * This function assumes that there is a NAV_LINKS tag in the main theme template.
  */
 private function addNavLinks()
 {
     // Link to the pages. One nav button for each link.
     $viewStats = array("LINK" => "index.php?module=faxmaster&op=show_stats", "TEXT" => "View Statistics");
     $viewArchive = array("LINK" => "index.php?module=faxmaster&op=show_archive", "TEXT" => "View Archive");
     $settings = array("LINK" => "index.php?module=faxmaster&op=settings", "TEXT" => "Settings");
     $actionLog = array("LINK" => "index.php?module=faxmaster&op=showActionLog", "TEXT" => "Action Log");
     // Fill the links array
     $links = array();
     $links['repeat_nav_links'][] = $viewStats;
     // view stats button
     // Only show 'View Archive' button if user has permission to view the archive
     if (Current_User::allow('faxmaster', 'viewArchive')) {
         $links['repeat_nav_links'][] = $viewArchive;
         // view archive button
     }
     // Only show 'Settings' button if user has proper permissions
     if (Current_User::allow('faxmaster', 'settings')) {
         $links['repeat_nav_links'][] = $settings;
         // settings button
     }
     $links['repeat_nav_links'][] = $actionLog;
     $links['BRAND'] = 'Fax Server';
     $links['BRAND_LINK'] = 'index.php';
     if (Current_User::isDeity()) {
         $links['CONTROL_PANEL'] = PHPWS_Text::secureLink('Control Panel', 'controlpanel');
         $links['ADMIN_OPTIONS'] = '';
         //dummy tag to show dropdown menu in template
     }
     $links['USER_FULL_NAME'] = Current_User::getDisplayName();
     $auth = Current_User::getAuthorization();
     $links['LOGOUT_URI'] = $auth->logout_link;
     // Plug the navlinks into the navbar
     $navLinks = PHPWS_Template::process($links, 'faxmaster', 'navLinks.tpl');
     Layout::plug($navLinks, 'NAV_LINKS');
 }
 /**
  * Get the DBPager object.
  * Search strings can be passed in too.
  */
 private static function getPager($name = null, $deptId = null, $term = null, $ugradMajor = null, $gradProg = null, $level = null, $type = null, $campus = null, $loc = null, $state = null, $country = null, $workflowState = null, $courseSubject = null, $courseNum = null, $courseSect = null)
 {
     $pager = new SubselectPager('intern_internship', '\\Intern\\InternshipRestored');
     // Pager Settings
     $pager->setModule('intern');
     $pager->setTemplate('results.tpl');
     $pager->addRowTags('getRowTags');
     $pager->setReportRow('getCSV');
     $pager->setEmptyMessage('No matching internships found.');
     $pager->db->tables = array();
     $pager->db->addTable('intern_internship', 'fuzzy');
     // If the current user is not a deity and doesn't have the 'all_departments' permission,
     // then add a join to limit the results to just the allowed departments
     if (!\Current_User::isDeity() && !\Current_User::allow('intern', 'all_departments')) {
         $pager->db->addJoin('', 'fuzzy', 'intern_admin', 'department_id', 'department_id');
         $pager->addWhere('intern_admin.username', \Current_User::getUsername());
     }
     // Limit to requested department
     if (!is_null($deptId) && $deptId != -1) {
         $pager->addWhere('department_id', $deptId);
     }
     // Limit to requested term
     if (!is_null($term) && $term != -1) {
         $pager->addWhere('fuzzy.term', $term);
     }
     // Trim text input, if any
     if (!is_null($name)) {
         $name = trim($name);
     }
     // Check to see if name is set and looks like a valid Banner ID
     if (!is_null($name) && preg_match("/\\d{8}/", $name)) {
         $pager->addWhere('fuzzy.banner', $name);
         // Else, check to see if name is set
     } else {
         if (!is_null($name) && $name != '') {
             // Prevent SQL Injection and syntax errors, since we're going to be using the addColumnRaw() method.
             $name = addslashes($name);
             /**
              * *
              * Fuzzy Search Settings
              */
             $tokenLimit = 2;
             // Max number of tokens
             // The fields (db column names) to fuzzy match against, in decreasing order of importance
             $fuzzyFields = array('last_name', 'first_name', 'middle_name');
             $fuzzyTolerance = 3;
             // Levenshtein distance allowed between the metaphones of a token and a $fuzzyField
             // Initalization
             $orderByList = array();
             $whereSet = array();
             // Tokenize the passed in string
             $tokenCount = 0;
             $tokens = array();
             $token = strtok($name, "\n\t, ");
             // tokenize on newline, tab, comma, space
             while ($token !== false && $tokenCount < $tokenLimit) {
                 $tokenCount++;
                 $tokens[] = trim(strtolower($token));
                 // NB: must be lowercase!
                 // tokenize on newline, tab, comma, space
                 // NB: Don't pass in the string to strtok after the first call above
                 $token = strtok("\n\t, ");
             }
             $fuzzyDb = new SubselectDatabase('intern_internship');
             $fuzzyDb->addColumnRaw('intern_internship.*');
             // Foreach token
             for ($i = 0; $i < $tokenCount; $i++) {
                 $fuzzyDb->addColumnRaw("LEAST(levenshtein('{$tokens[$i]}', lower(last_name)),levenshtein('{$tokens[$i]}', lower(first_name))) as t{$i}_lev");
                 $fuzzyDb->addColumnRaw("LEAST(levenshtein(metaphone('{$tokens[$i]}', 10), last_name_meta),levenshtein(metaphone('{$tokens[$i]}', 10), first_name_meta)) as t{$i}_metalev");
                 $pager->db->addWhere("fuzzy.t{$i}_lev", 3, '<', 'OR', 'lev_where');
                 $pager->db->addWhere("fuzzy.t{$i}_metalev", $fuzzyTolerance, '<', 'OR', 'metaphone_where');
                 // Add order for this token's *_metalev fields
                 $orderByList[] = "fuzzy.t{$i}_lev";
                 $orderByList[] = "fuzzy.t{$i}_metalev";
             }
             $pager->db->addOrder($orderByList);
             $pager->db->addColumnRaw('fuzzy.*');
             $pager->db->addSubSelect($fuzzyDb, 'fuzzy');
         }
     }
     $pager->db->addJoin('LEFT OUTER', 'fuzzy', 'intern_faculty', 'faculty_id', 'id');
     $pager->db->addJOIN('LEFT OUTER', 'fuzzy', 'intern_department', 'department_id', 'id');
     // Student level
     if (isset($level)) {
         if ($level == Student::UNDERGRAD) {
             $pager->addWhere('level', Student::UNDERGRAD);
         } else {
             if ($level == Student::GRADUATE || $level == Student::DOCTORAL || $level == Student::POSTDOC) {
                 $pager->addWhere('level', Student::GRADUATE, null, 'OR', 'grad_level');
                 $pager->addWhere('level', Student::DOCTORAL, null, 'OR', 'grad_level');
                 $pager->addWhere('level', Student::POSTDOC, null, 'OR', 'grad_level');
             }
         }
         // Major
         if ($level == 'ugrad' && isset($ugradMajor) && $ugradMajor != -1) {
             // Undergrad major
             $pager->addWhere('major_code', $ugradMajor);
         } else {
             if ($level == 'grad' && isset($gradProg) && $gradProg != -1) {
                 // Graduate program
                 $pager->addWhere('major_code', $gradProg);
             }
         }
     }
     // Experience type
     if (!is_null($type)) {
         $pager->addWhere('experience_type', $type);
     }
     // Course Info
     if (!is_null($courseSubject) && $courseSubject != '-1') {
         $pager->addWhere('course_subj', $courseSubject);
     }
     if (!is_null($courseNum) && $courseNum != '') {
         $pager->addWhere('course_no', $courseNum);
     }
     if (!is_null($courseSect) && $courseSect != '') {
         $pager->addWhere('course_sect', $courseSect);
     }
     // Location
     if (!is_null($loc)) {
         if ($loc == 'domestic') {
             $pager->addWhere('domestic', 1);
         } else {
             if ($loc == 'internat') {
                 $pager->addWhere('international', 1);
             }
         }
     }
     // Campus
     if (isset($campus) && $campus != '-1') {
         $pager->addWhere('campus', $campus);
     }
     // Domestic state
     if (!is_null($state) && $state != '-1') {
         $pager->addWhere('loc_state', "%{$state}%", 'ILIKE');
     }
     // International
     if (!is_null($country) && $country != '-1') {
         $pager->addWhere('loc_country', $country);
     }
     // Workflow state/status
     if (isset($workflowState)) {
         foreach ($workflowState as $s) {
             $path = explode('\\', $s);
             $pager->db->addWhere('state', $path[2], '=', 'OR', 'workflow_group');
         }
     }
     //var_dump($pager);exit;
     //$pager->db->setTestMode();
     //$pager->db->select();
     /**
      * * Sort Headers **
      */
     $pager->setAutoSort(false);
     $pager->addSortHeader('term', 'Term');
     // $pager->joinResult('student_id', 'intern_student', 'id', 'last_name', 'student_last_name');
     $pager->addSortHeader('last_name', 'Student\'s Name');
     // $pager->joinResult('student_id', 'intern_student', 'id', 'banner');
     $pager->addSortHeader('banner', 'Banner ID');
     $pager->joinResult('department_id', 'intern_department', 'id', 'name');
     $pager->addSortHeader('intern_department.name', 'Department Name');
     //$pager->joinResult('faculty_id', 'intern_faculty', 'id', 'last_name', 'faculty_last_name');
     $pager->addSortHeader('intern_faculty.last_name', 'Instructor');
     $pager->addSortHeader('state', 'Status');
     /**
      * *** Other Page Tags *****
      */
     $pageTags = array();
     $pageTags['BACK_LINK_URI'] = \PHPWS_Text::linkAddress('intern', array('action' => 'search'));
     $pager->addPageTags($pageTags);
     return $pager;
 }
Beispiel #24
0
 /**
  * Constructs a view of this form and returns it in a string.
  *
  * This function will construct a view of this form whether in edit mode
  * or submission mode and return it in a string for display.
  *
  * @param  boolean $edit Whether the view is in edit mode or not.
  * @return mixed   A templated string on success, or a FALSE on failure.
  * @access public
  */
 function view($edit = FALSE, $error = null)
 {
     if ($this->isHidden() && !$edit || !$this->isSaved() && !Current_User::allow('phatform', 'edit_forms')) {
         return dgettext('phatform', 'This form is not available for viewing at this time.');
     }
     $GLOBALS['CNT_phatform']['title'] = $this->getLabel();
     /* Do some basic checks if we're not in edit mode */
     if (!$edit) {
         /* If this form is not anonymous and the user is not logged in, print message and bail */
         if (($this->_editData || !$this->_anonymous) && !Current_User::isLogged()) {
             return dgettext('phatform', 'You must be logged in to view this form!');
         }
         /* If this form is not multi submit and the user has filled out this for before,
            print message and bail */
         if (!$this->_editData && !$this->_multiSubmit && $this->hasSubmission()) {
             return dgettext('phatform', 'You have already filled out this form!');
         }
         if (!Current_User::isDeity() && Current_User::allow('phatform', 'user_forms_only')) {
             if (Current_User::getUsername() != $this->getOwner()) {
                 return dgettext('phatform', 'You only have permission to edit your own forms!');
             }
         }
     }
     /* Assume the PHAT position :) */
     if (!isset($this->_position)) {
         $this->_position = 0;
     }
     /* Setup limit for loop */
     if ($this->_position + $this->_pageLimit > sizeof($this->_elements)) {
         $limit = $this->_position + (sizeof($this->_elements) - $this->_position);
     } else {
         $limit = $this->_position + $this->_pageLimit;
     }
     /* Begin view template array */
     if ($this->currentPage() == 1) {
         $viewTags['BLURB0'] = PHPWS_Text::parseOutput($this->_blurb0, ENCODE_PARSED_TEXT, false, true);
         if (!$this->_saved) {
             $viewTags['WARNING'] = dgettext('phatform', 'The form must be saved before it is available to the public.');
         }
     }
     $formTags = array();
     /* If this form has elements, loop and add them to the form template array */
     if (is_array($this->_elements) && sizeof($this->_elements) > 0) {
         for ($i = $this->_position; $i < $limit; $i++) {
             $sectionTags = array();
             $elementInfo = explode(':', $this->_elements[$i]);
             $this->element = new $elementInfo[0]($elementInfo[1]);
             /* If user can edit data, populate for element with it */
             if (!$edit && $this->_editData && is_array($this->_userData)) {
                 if (isset($this->_userData[$this->element->getLabel()]) && $this->isSerialized($this->_userData[$this->element->getLabel()])) {
                     $value = unserialize(stripslashes($this->_userData[$this->element->getLabel()]));
                     $this->element->setValue($value);
                 } else {
                     $this->element->setValue($this->_userData[$this->element->getLabel()]);
                 }
             }
             /* Setup color for alternating rows in the section template */
             if (isset($flag) && $flag) {
                 $flag = FALSE;
             } else {
                 $sectionTags['BGCOLOR'] = ' class="bgcolor1" ';
                 $flag = TRUE;
             }
             /* Get view of the current element */
             $sectionTags['ELEMENT'] = $this->element->view();
             if ($this->_showElementNumbers) {
                 $sectionTags['ELEMENT'] = $i + 1 . '. ' . $sectionTags['ELEMENT'];
             }
             /* If in edit mode, show the element editor for the current element */
             if ($edit) {
                 $sectionTags['ELEMENT_NAME'] = PHPWS_Text::parseOutput($this->element->getLabel(), ENCODE_PARSED_TEXT, false, true);
                 $sectionTags['ELEMENT_EDITOR'] = $this->_elementEditor($i);
             }
             if (!isset($formTags['ELEMENTS'])) {
                 $formTags['ELEMENTS'] = PHPWS_Template::processTemplate($sectionTags, 'phatform', 'form/section.tpl');
             } else {
                 $formTags['ELEMENTS'] .= PHPWS_Template::processTemplate($sectionTags, 'phatform', 'form/section.tpl');
             }
         }
         /* If we are on last page...show the submit button */
         if (!$edit) {
             if ($this->currentPage() == $this->numPages()) {
                 if ($this->_editData && $this->currentPage() > 1) {
                     $formTags['BACK_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Back'), 'PHAT_Back');
                 }
                 if (PHATFORM_CAPTCHA && $this->_anonymous && !Current_User::isLogged()) {
                     PHPWS_Core::initCoreClass('Captcha.php');
                     $formTags['CAPTCHA'] = Captcha::get();
                 }
                 $formTags['SUBMIT_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Finish'), 'PHAT_Submit');
             } else {
                 if ($this->_editData && $this->currentPage() > 1) {
                     $formTags['BACK_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Back'), 'PHAT_Back');
                 }
                 $formTags['NEXT_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Next'), 'PHAT_Next');
             }
         }
         /* Check if we're in edit mode and set the phat man accordingly */
         if ($edit) {
             $hiddens['PHAT_FORM_OP'] = 'EditAction';
         } else {
             $hiddens['PHAT_FORM_OP'] = 'Action';
         }
         /* Actually load hidden variables into the elements array */
         $hiddens['module'] = 'phatform';
         foreach ($hiddens as $key => $value) {
             $eles[] = PHPWS_Form::formHidden($key, $value);
         }
         $elements[] = implode("\n", $eles);
         $elements[0] .= PHPWS_Template::processTemplate($formTags, 'phatform', 'form/form.tpl');
         $viewTags['FORM'] = PHPWS_Form::makeForm('PHAT_Form', 'index.php', $elements);
     }
     /* Check to see if we should show page numbers or not */
     if ($this->_showPageNumbers) {
         $viewTags['PAGE_NUMBER'] = sprintf(dgettext('phatform', 'Page %1$s of %2$s'), $this->currentPage(), $this->numPages());
     }
     /* If in edit mode, display the toolbar */
     if ($edit) {
         $viewTags['TOOLBAR'] = $this->_toolbar();
     }
     $key = new Key($this->_key_id);
     $key->flag();
     if ($error) {
         $viewTags['WARNING'] = $error->getMessage();
     }
     return PHPWS_Template::processTemplate($viewTags, 'phatform', 'form/view.tpl');
 }
Beispiel #25
0
 public static function allowChange($electionId)
 {
     if (!$electionId) {
         throw new \Exception('Election id was empty');
     }
     if (\Current_User::isDeity()) {
         return true;
     }
     $currentElection = self::getCurrent();
     return !($currentElection && (int) $currentElection['id'] == (int) $electionId);
 }
Beispiel #26
0
 /**
  * Adds limits to a db select query to only pull items the user
  * has permissions to view
  *
  * Note that BEFORE this is called, the developer should check whether
  * the user has ANY rights to edit items in the first place.
  * In other words, if Current_User::allow('module', 'edit_permission') == false
  * then they shouldn't even use this function. If it is used anyway, a forced negative
  * will be added (i.e. where 1 = 0);
  * If you wish to add other qualifications, use the $db->addWhere() group 'key_id'
  * in your module code.
  *
  * @modified Eloi George
  * @param  object   db : Database object to modify
  * @param  string   module : Calling module
  * @param  string   edit_permission : Name of the editing permission
  * @param  string   source_table : (optional) Name of the main table being searched
  * @param  string   key_id_column : (optional) Usually "key_id".  Only use this if you allow edits where "key_id=0"
  * @param  string   owner_id_column : (optional) Only use this if you allow edits on content created by the user
  */
 public static function restrictEdit($db, $module, $edit_permission = null, $source_table = null, $key_id_column = null, $owner_id_column = null)
 {
     if (Current_User::isDeity()) {
         return;
     }
     // if the user doesn't have rights for the module or subpermissions,
     // then we just stymie the whole query
     if (!Current_User::allow($module, $edit_permission)) {
         $db->setQWhere('1=0');
         return;
     }
     // If the current user has unrestricted rights to edit the item
     // linked to this key, no further restrictions are necessary
     if (Current_User::isUnrestricted($module)) {
         return;
     } else {
         $db->setDistinct(1);
         if (empty($source_table)) {
             $source_table = $db->tables[0];
         }
         if (!empty($key_id_column)) {
             $db->addWhere($source_table . '.' . $key_id_column, 0, null, 'or', 'key_1');
         }
         if (!empty($owner_id_column)) {
             $db->addWhere($source_table . '.' . $owner_id_column, Current_User::getId(), null, 'or', 'key_1');
         }
         $groups = Current_User::getGroups();
         if (!empty($groups)) {
             $db->addJoin('left', $source_table, 'phpws_key_edit', 'key_id', 'key_id');
             $db->addWhere('phpws_key_edit.group_id', $groups, 'in', 'or', 'key_1');
         }
         return;
     }
 }
Beispiel #27
0
 public static function cpanel()
 {
     PHPWS_Core::initModClass('controlpanel', 'Panel.php');
     $link['link'] = 'index.php?module=access';
     if (MOD_REWRITE_ENABLED) {
         $link['title'] = dgettext('access', 'Shortcuts');
         $tabs['shortcuts'] = $link;
     }
     if (Current_User::allow('access', 'admin_options')) {
         $link['title'] = dgettext('access', 'Allow/Deny');
         $tabs['deny_allow'] = $link;
     }
     if (Current_User::isDeity()) {
         $link['title'] = dgettext('access', '.htaccess');
         $tabs['htaccess'] = $link;
     }
     $panel = new PHPWS_Panel('access_panel');
     $panel->enableSecure();
     if (!empty($tabs)) {
         $panel->quickSetTabs($tabs);
     }
     $panel->setModule('access');
     return $panel;
 }
 public function display()
 {
     // Set up search fields
     $form = new \PHPWS_Form();
     $form->setMethod('get');
     $form->addHidden('module', 'intern');
     $form->addHidden('action', 'results');
     $form->useRowRepeat();
     // Student name or Banner ID
     $form->addText('name');
     $form->setLabel('name', "Name or Banner ID");
     /***************
      * Course Info *
      ***************/
     $terms = Term::getTermsAssoc();
     $form->addSelect('term_select', $terms);
     $form->setLabel('term_select', 'Term');
     $form->setClass('term_select', 'form-control');
     $subjects = array('-1' => 'Select subject ') + Subject::getSubjects();
     $form->addSelect('course_subj', $subjects);
     $form->setLabel('course_subj', 'Subject');
     $form->setClass('course_subj', 'form-control');
     $form->addText('course_no');
     $form->setLabel('course_no', 'Course Number');
     $form->setSize('course_no', 6);
     $form->setMaxSize('course_no', 4);
     $form->setClass('course_no', 'form-control');
     $form->addText('course_sect');
     $form->setLabel('course_sect', 'Section');
     $form->setSize('course_sect', 6);
     $form->setMaxSize('course_sect', 4);
     $form->setClass('course_sect', 'form-control');
     /****************
      * Faculty Info *
      ****************/
     // Deity can search for any department. Other users are restricted.
     if (\Current_User::isDeity()) {
         $depts = Department::getDepartmentsAssoc();
     } else {
         $depts = Department::getDepartmentsAssocForUsername(\Current_User::getUsername());
     }
     $depts = array('-1' => 'Select Department') + $depts;
     $form->addSelect('dept', $depts);
     $form->setLabel('dept', 'Department');
     //$form->setClass('', 'form-control');
     $form->setClass('dept', 'form-control');
     // If the user only has one department, select it for them
     // sizeof($depts) == 2 because of the 'Select Deparmtnet' option
     if (sizeof($depts) == 2) {
         $keys = array_keys($depts);
         $form->setMatch('dept', $keys[1]);
     }
     // Student level radio button
     javascript('jquery');
     javascriptMod('intern', 'majorSelector', array('form_id' => $form->id));
     // Student Major dummy box (gets replaced by dropdowns below using JS when student_level is selected)
     $levels = array('-1' => 'Choose student level first');
     $form->addDropBox('student_major', $levels);
     $form->setLabel('student_major', 'Major / Program');
     $form->addCssClass('student_major', 'form-control');
     // Get the majors list
     $majorsList = MajorsProviderFactory::getProvider()->getMajors(Term::timeToTerm(time()));
     // Undergrad major drop down
     $undergradMajors = array('-1' => 'Select Undergraduate Major') + $majorsList->getUndergradMajorsAssoc();
     $form->addSelect('undergrad_major', $undergradMajors);
     $form->setMatch('undergrad_major', '-1');
     $form->setClass('undergrad_major', 'form-control');
     // Graduate major drop down
     $graduateMajors = array('-1' => 'Select Graduate Major') + $majorsList->getGraduateMajorsAssoc();
     $form->addSelect('graduate_major', $graduateMajors);
     $form->setMatch('graduate_major', '-1');
     $form->setClass('graduate_major', 'form-control');
     /*******************
      * Internship Type *
      *******************/
     // Handeled directly in the html template
     /************
      * Location *
      ************/
     // Campus Handeled directly in the html template
     // International vs Domestic - Handeled directly in the html template
     // State search
     /*******************
      * Workflow States *
      *******************/
     $workflowStates = WorkflowStateFactory::getStatesAssoc();
     unset($workflowStates['Intern\\WorkflowState\\CreationState']);
     // Remove this state, since it's not valid (internal only state for initial creation)
     $form->addCheckAssoc('workflow_state', $workflowStates);
     $form->addSubmit('submit', 'Search');
     // Javascript...
     javascriptMod('intern', 'resetSearch');
     return \PHPWS_Template::process($form->getTemplate(), 'intern', 'search.tpl');
 }
Beispiel #29
0
 public static function listModules($type)
 {
     Layout::addStyle('boost');
     $allow_update = true;
     $core_update_needed = false;
     $dir_content = array();
     if (!PHPWS_Boost::checkDirectories($dir_content)) {
         $tpl['DIRECTORIES'] = implode('<br />', $dir_content);
         $allow_update = false;
     }
     $core_mods = PHPWS_Core::coreModList();
     $installed_mods = PHPWS_Core::installModList();
     $dir_mods = PHPWS_Boost::getAllMods();
     if ($type == 'core_mods') {
         $allowUninstall = false;
         $modList = $core_mods;
         $core_file = new PHPWS_Module('core');
         $core_db = new PHPWS_Module('core', false);
         $template['TITLE'] = $core_db->proper_name;
         $template['VERSION'] = $core_db->version;
         if (isset($_SESSION['Boost_Needs_Update']['core'])) {
             $link_title = $_SESSION['Boost_Needs_Update']['core'];
             if (version_compare($core_file->version, $_SESSION['Boost_Needs_Update']['core'], '<')) {
                 $link_title = sprintf(dgettext('boost', '%s - New'), $link_title);
             }
         } else {
             $link_title = dgettext('boost', 'Check');
         }
         if ($core_file->isAbout()) {
             $address = PHPWS_Text::linkAddress('boost', array('action' => 'aboutView', 'aboutmod' => $core_file->title), true);
             $aboutView = array('label' => dgettext('boost', 'About'), 'address' => $address);
             $template['ABOUT'] = Layout::getJavascript('open_window', $aboutView);
         }
         $link_command['opmod'] = 'core';
         $link_command['action'] = 'check';
         if (ini_get('allow_url_fopen')) {
             $template['LATEST'] = PHPWS_Text::secureLink($link_title, 'boost', $link_command);
         } else {
             $template['LATEST'] = dgettext('boost', 'Check disabled');
         }
         if (version_compare($core_db->version, $core_file->version, '<')) {
             if ($core_file->checkDependency()) {
                 if ($allow_update) {
                     $link_command['action'] = 'update_core';
                     $core_links[] = PHPWS_Text::secureLink(dgettext('boost', 'Update'), 'boost', $link_command);
                 } else {
                     $core_links[] = dgettext('boost', 'Update');
                 }
                 $tpl['WARNING'] = dgettext('boost', 'The Core requires updating! You should do so before any modules.');
                 $core_update_needed = true;
             } else {
                 $link_command['action'] = 'show_dependency';
                 $core_links[] = PHPWS_Text::secureLink(dgettext('boost', 'Missing dependency'), 'boost', $link_command);
             }
             $template['VERSION'] = sprintf('%s &gt; %s', $core_db->version, $core_file->version);
             $template['COMMAND'] = implode(' | ', $core_links);
         } else {
             $template['COMMAND'] = dgettext('boost', 'None');
         }
         $template['ROW'] = 1;
         $tpl['mod-row'][] = $template;
     } else {
         $allowUninstall = true;
         $modList = array_diff($dir_mods, $core_mods);
     }
     $tpl['TITLE_LABEL'] = dgettext('boost', 'Module Title');
     $tpl['COMMAND_LABEL'] = dgettext('boost', 'Commands');
     $tpl['ABOUT_LABEL'] = dgettext('boost', 'More information');
     $tpl['VERSION_LABEL'] = dgettext('boost', 'Current version');
     if ($type == 'core_mods' && Current_User::isDeity() && DEITIES_CAN_UNINSTALL) {
         $tpl['WARNING'] = dgettext('boost', 'WARNING: Only deities can uninstall core modules. Doing so may corrupt your installation!');
     }
     if (empty($modList)) {
         return dgettext('boost', 'No modules available.');
     }
     sort($modList);
     $count = 1;
     foreach ($modList as $title) {
         $links = array();
         $template = $link_command = NULL;
         $link_command['opmod'] = $title;
         $mod = new PHPWS_Module($title);
         if (!$mod->isFullMod()) {
             continue;
         }
         $proper_name = $mod->getProperName();
         if (!isset($proper_name)) {
             $proper_name = $title;
         }
         $template['VERSION'] = $mod->version;
         $template['TITLE'] = $proper_name;
         $template['ROW'] = $count % 2 + 1;
         $version_check = $mod->getVersionHttp();
         if (isset($version_check)) {
             if (isset($_SESSION['Boost_Needs_Update'][$mod->title])) {
                 $link_title = $_SESSION['Boost_Needs_Update'][$mod->title];
                 if (version_compare($mod->version, $_SESSION['Boost_Needs_Update'][$mod->title], '<')) {
                     $link_title = sprintf(dgettext('boost', '%s - New'), $link_title);
                 }
             } else {
                 $link_title = dgettext('boost', 'Check');
             }
             $link_command['action'] = 'check';
             if (ini_get('allow_url_fopen')) {
                 $template['LATEST'] = PHPWS_Text::secureLink($link_title, 'boost', $link_command);
             } else {
                 $template['LATEST'] = dgettext('boost', 'Check disabled');
             }
         }
         if (!$mod->isInstalled()) {
             if ($mod->checkDependency()) {
                 $link_title = dgettext('boost', 'Install');
                 $link_command['action'] = 'install';
             } else {
                 $link_title = dgettext('boost', 'Missing dependency');
                 $link_command['action'] = 'show_dependency';
             }
             if ($GLOBALS['Boost_Ready']) {
                 if (javascriptEnabled()) {
                     $js['width'] = 640;
                     $js['height'] = 480;
                     $js['address'] = PHPWS_Text::linkAddress('boost', $link_command, true);
                     $js['label'] = $link_title;
                     $links[] = javascript('open_window', $js);
                     unset($js);
                 } else {
                     $links[] = PHPWS_Text::secureLink($link_title, 'boost', $link_command);
                 }
             } else {
                 $links[] =& $link_title;
             }
         } else {
             if ($mod->needsUpdate()) {
                 $db_mod = new PHPWS_Module($mod->title, false);
                 $template['VERSION'] = $db_mod->version . ' &gt; ' . $mod->version;
                 if ($mod->checkDependency()) {
                     if ($title == 'boost' && !$core_update_needed) {
                         $tpl['WARNING'] = dgettext('boost', 'Boost requires updating! You should do so before any other module!');
                     }
                     $link_title = dgettext('boost', 'Update');
                     $link_command['action'] = 'update';
                 } else {
                     $link_title = dgettext('boost', 'Missing dependency');
                     $link_command['action'] = 'show_dependency';
                 }
                 if ($allow_update) {
                     $js['width'] = 640;
                     $js['height'] = 480;
                     $js['address'] = PHPWS_Text::linkAddress('boost', $link_command, true);
                     $js['label'] = $link_title;
                     $links[] = javascript('open_window', $js);
                     unset($js);
                 } else {
                     $links[] =& $link_title;
                 }
             }
             if ($type != 'core_mods' || Current_User::isDeity() && DEITIES_CAN_UNINSTALL) {
                 if ($dependents = $mod->isDependedUpon()) {
                     $link_command['action'] = 'show_depended_upon';
                     $depend_warning = sprintf(dgettext('boost', 'This module is depended upon by: %s'), implode(', ', $dependents));
                     $links[] = PHPWS_Text::secureLink(dgettext('boost', 'Depended upon'), 'boost', $link_command, NULL, $depend_warning);
                 } else {
                     $links[] = PHPWS_Boost::uninstallLink($title);
                 }
             }
         }
         if ($mod->isAbout()) {
             $address = PHPWS_Text::linkAddress('boost', array('action' => 'aboutView', 'aboutmod' => $mod->title), true);
             $aboutView = array('label' => dgettext('boost', 'About'), 'address' => $address);
             $template['ABOUT'] = Layout::getJavascript('open_window', $aboutView);
         }
         if (!empty($links)) {
             $template['COMMAND'] = implode(' | ', $links);
         } else {
             $template['COMMAND'] = dgettext('boost', 'None');
         }
         $tpl['mod-row'][] = $template;
         $count++;
     }
     $tpl['OLD_MODS'] = Boost_Form::oldModList();
     if (ini_get('allow_url_fopen')) {
         $tpl['CHECK_FOR_UPDATES'] = PHPWS_Text::secureLink(dgettext('boost', 'Check all'), 'boost', array('action' => 'check_all', 'tab' => $type));
     } else {
         $tpl['CHECK_FOR_UPDATES'] = dgettext('boost', 'Server configuration prevents version checking.');
     }
     $tpl['LATEST_LABEL'] = dgettext('boost', 'Latest version');
     $release_version = PHPWS_Core::releaseVersion();
     $tpl['PHPWS_VERSION'] = $release_version;
     $result = PHPWS_Template::process($tpl, 'boost', 'module_list.tpl');
     return $result;
 }
 public static function settings()
 {
     $content = array();
     $form = new PHPWS_Form('user_settings');
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'admin');
     $form->addHidden('command', 'update_settings');
     $form->addSubmit('submit', dgettext('users', 'Update Settings'));
     $form->addText('site_contact', PHPWS_User::getUserSetting('site_contact'));
     $form->setLabel('site_contact', dgettext('users', 'Site contact email'));
     $form->setSize('site_contact', 40);
     if (Current_User::isDeity()) {
         $signup_modes = array(0, AUTO_SIGNUP, CONFIRM_SIGNUP);
         $signup_labels = array(dgettext('users', 'Not allowed'), dgettext('users', 'Immediate'), dgettext('users', 'Email Verification'));
         $form->addRadio('user_signup', $signup_modes);
         $form->setLabel('user_signup', $signup_labels);
         $form->addTplTag('USER_SIGNUP_LABEL', dgettext('users', 'User Signup Mode'));
         $form->setMatch('user_signup', PHPWS_User::getUserSetting('new_user_method'));
         if (extension_loaded('gd')) {
             $form->addCheckbox('graphic_confirm');
             $form->setLabel('graphic_confirm', dgettext('users', 'New user CAPTCHA confirmation'));
             $form->setMatch('graphic_confirm', PHPWS_User::getUserSetting('graphic_confirm'));
         }
         $included_usermenu = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . 'mod/users/templates/usermenus/', FALSE, TRUE, FALSE, array('tpl'));
         $theme_usermenu = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . Layout::getThemeDir() . 'templates/users/usermenus/', FALSE, TRUE, FALSE, array('tpl'));
         if ($theme_usermenu) {
             $options = array_unique(array_merge($included_usermenu, $theme_usermenu));
         } else {
             $options = $included_usermenu;
         }
         $menu_options = array_combine($options, $options);
         // Replace below with a directory read
         $menu_options['none'] = dgettext('users', 'None');
         $menu_options['css.tpl'] = 'css.tpl';
         $menu_options['Default.tpl'] = 'Default.tpl';
         $menu_options['top.tpl'] = 'top.tpl';
         $form->addSelect('user_menu', $menu_options);
         $form->setMatch('user_menu', PHPWS_User::getUserSetting('user_menu'));
         $form->setLabel('user_menu', dgettext('users', 'User Menu'));
         $form->addCheckBox('show_login', 1);
         $form->setMatch('show_login', PHPWS_Settings::get('users', 'show_login'));
         $form->setLabel('show_login', dgettext('users', 'Show login box'));
         $form->addTplTag('AFFIRM', dgettext('users', 'Yes'));
         $form->addCheckBox('allow_remember', 1);
         $form->setMatch('allow_remember', PHPWS_Settings::get('users', 'allow_remember'));
         $form->setLabel('allow_remember', dgettext('users', 'Allow Remember Me'));
         $form->addRadioAssoc('allow_new_users', array(1 => 'Yes', 0 => 'No'));
         $form->setMatch('allow_new_users', PHPWS_Settings::get('users', 'allow_new_users'));
         $form->addTplTag('ALLOW_NEW_USERS_LABEL', dgettext('users', 'Allow new user creation?'));
     }
     $form->addTextArea('forbidden_usernames', PHPWS_Settings::get('users', 'forbidden_usernames'));
     $form->setLabel('forbidden_usernames', dgettext('users', 'Forbidden usernames (one per line)'));
     $form->addCheckbox('session_warning', 1);
     $form->setMatch('session_warning', PHPWS_Settings::get('users', 'session_warning'));
     $form->setlabel('session_warning', 'Show session warning');
     $template = $form->getTemplate();
     if (Current_User::isDeity()) {
         $vars['action'] = 'admin';
         $vars['command'] = 'check_permission_tables';
         $template['VERIFY_PERMISSIONS'] = PHPWS_Text::secureLink(dgettext('users', 'Register user permissions'), 'users', $vars);
         $template['VERIFY_EXPLAIN'] = dgettext('users', 'Users module will re-register each module\'s permissions.');
     }
     return PHPWS_Template::process($template, 'users', 'forms/settings.tpl');
 }