Пример #1
0
 /**
  * get the full enrollment report from Rave
  * @param which date do you want, defaults to today
  */
 public static function getEnrollmentReport($report_date = 'today')
 {
     $config = \PSU\Config\Factory::get_config();
     $username = $config->get('rave', 'webdav_user');
     $password = $config->get('rave', 'webdav_passwd');
     $report = 'enrollment_report_' . date('Ymd', strtotime($report_date)) . '_plymouth.csv';
     $file = 'https://' . $username . ':' . $password . '@' . static::$path . $report;
     $accounts = array();
     $indexes = array();
     $i = -1;
     // negative one because the first row is the field names
     if (($handle = fopen($file, 'rb')) !== false) {
         while (($data = fgetcsv($handle)) !== false) {
             if ($i == -1) {
                 $indexes = $data;
             } else {
                 $accounts[$i] = array();
                 foreach ($data as $k => $value) {
                     $accounts[$i][$indexes[$k]] = $value;
                 }
                 // end foreach
             }
             // end else
             $i++;
         }
         // end while
         fclose($handle);
         return $accounts;
     }
     // end if
     return false;
 }
Пример #2
0
 /**
  * Returns the unique API key needed to make calls to OrgSync for PSU
  *
  * @return 		Returns the unique OrgSync API key for PSU
  */
 function api_key()
 {
     static $key = null;
     if ($key === null) {
         // TODO dependency injection
         $config = \PSU\Config\Factory::get_config();
         $key = $config->get('orgsync', 'api_key');
     }
     return $key;
 }
Пример #3
0
 /**
  * general wrapper for handling Rave REST calls
  *
  */
 protected static function callFunction($function, $method = 'get', $params = false)
 {
     // we need to be able to set curl options, so intentionally not using PSU::curl
     $url = static::$rest_endpoint . $function;
     $config = \PSU\Config\Factory::get_config();
     $username = $config->get('rave', 'rest_user');
     $password = $config->get('rave', 'rest_passwd');
     $options = array(CURLOPT_USERPWD => $username . ':' . $password, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $url);
     switch ($method) {
         case 'head':
             $options[CURLOPT_CUSTOMREQUEST] = 'HEAD';
             break;
         case 'post':
             $options[CURLOPT_CUSTOMREQUEST] = 'POST';
             // explicitly setting the CURLOPT_POST is neither positive, nor negative, with CUSTOMREQUEST set, so... not doing it
             //$options[CURLOPT_POST] = true;
             break;
         case 'put':
             // DO NOT use the following curlopt, it will cause a "premature end of file error"
             //$options[CURLOPT_PUT] = true;
             $options[CURLOPT_CUSTOMREQUEST] = 'PUT';
             break;
         case 'delete':
             $options[CURLOPT_CUSTOMREQUEST] = 'DELETE';
             break;
     }
     // end switch
     $headers = static::$headers;
     $headers[] = 'Content-Length: ' . strlen($params);
     $options[CURLOPT_HTTPHEADER] = $headers;
     if ($params) {
         $options[CURLOPT_POSTFIELDS] = $params;
     }
     // end if
     $ch = curl_init($url);
     curl_setopt_array($ch, $options);
     static::$last_xml_response = curl_exec($ch);
     curl_close($ch);
     $obj = simplexml_load_string(static::$last_xml_response);
     if ($obj->errorMessage) {
         Error::handle($obj->errorMessage);
     }
     // end if
     // if the call is a delete and we don't get anything back, it is successful
     if ($method == 'delete') {
         return true;
     }
     //end if
     return $obj;
 }
 public function get_email_override($username)
 {
     static $overrides = null;
     if ($overrides === null) {
         $config = \PSU\Config\Factory::get_config();
         $overrides = $config->get_json('psuperson', 'overrides');
         $overrides = array_flip((array) $overrides);
     }
     if (isset($overrides[$username])) {
         return $overrides[$username] . '@plymouth.edu';
     }
     return null;
 }
Пример #5
0
 /**
  * Setup flags for session_start.
  */
 public static function session_start_flags($flags = null)
 {
     $config = \PSU\Config\Factory::get_config();
     // handle old-style boolean flags
     if (is_bool($flags)) {
         // old: $secure = true
         // new: force ssl, don't log
         if ($flags) {
             $flags = self::NOLOG | self::FORCE_SSL;
         } else {
             $flags = self::LOG;
         }
     }
     // default behavior
     if ($flags === null) {
         $flags = self::NOLOG;
         if ($config->get('session', 'force_ssl', true)) {
             $flags |= self::FORCE_SSL;
         }
     }
     // if no special logging settings were defined, use our defaults
     if (!($flags & (self::LOG | self::NOLOG))) {
         // if request isn't forced to ssl, we want to log it
         if ($flags ^ self::FORCE_SSL) {
             $flags |= self::LOG;
         }
     }
     return $flags;
 }
Пример #6
0
<?php

require dirname(dirname(__DIR__)) . '/legacy/git-bootstrap.php';
require_once 'autoload.php';
PSU::session_start();
$GLOBALS['TITLE'] = 'Call Log';
$config = \PSU\Config\Factory::get_config();
define('PSU_API_APPID', $config->get('calllog', 'api_appid'));
define('PSU_API_APPKEY', $config->get('calllog', 'api_key'));
require_once 'PSUWordPress.php';
ini_set('memory_limit', -1);
$start_time = time();
ignore_user_abort(true);
// Call Log Web Home
$HOST = 'https://' . $_SERVER['SERVER_NAME'];
$GLOBALS['BASE_URL'] = $HOST . '/webapp/calllog';
$GLOBALS['BASE_DIR'] = __DIR__;
define('CALL_LOG_WEB_HOME', $GLOBALS['BASE_URL']);
$GLOBALS['DEVELOPMENT'] = PSU::isdev();
$GLOBALS['uploads'] = '/web/uploads/webapp/calllog/attachments';
// Call Log Administrative Web Home
define('TEMPLATE_DIR', __DIR__ . '/templates');
define('TEMPLATE_ADMIN_DIR', TEMPLATE_DIR . '/admin');
$GLOBALS['TEMPLATES'] = TEMPLATE_DIR;
// Absolute Path To Cascading Style Sheet (CSS) Files
define('CSS_DIR', __DIR__ . '/css');
// Web Path To CSS Files
define('CSS_WEB_DIR', PSU::cdn($GLOBALS['BASE_URL'] . '/css'));
$GLOBALS['CSS_WEB_DIR'] = CSS_WEB_DIR;
// Web Path To JS Files
define('JS_WEB_DIR', $GLOBALS['BASE_URL'] . '/js');
Пример #7
0
 /**
  * getCallerData
  *
  * returns caller data.  wewt.
  *
  * @param string $caller Caller username or pidm or wp_id
  * @param array $person Person record
  * @return array
  */
 function getCallerData($caller, $person = false)
 {
     $found_via = null;
     if ($person) {
         $found_via = 'function-args';
     }
     if (!$caller) {
         return array();
     }
     $config = \PSU\Config\Factory::get_config();
     $overrides = $config->get_json('psuperson', 'overrides');
     if (isset($overrides->{$caller})) {
         $caller = $overrides->{$caller};
     }
     //has the caller data already been queried?
     if (is_scalar($caller) && $this->people[$caller]) {
         //aye!  return it
         return $this->people[$caller];
     }
     //end if
     // are we trying to query getCallerData based on an already-populated $caller?
     if (is_array($caller) && isset($caller['wp_id']) && isset($this->people[$caller['wp_id']])) {
         return $this->people[$caller['wp_id']];
     } elseif (is_array($caller) && isset($caller['pidm']) && isset($this->people[$caller['pidm']])) {
         return $this->people[$caller['pidm']];
     }
     //end elseif
     //
     // populate generic data
     //
     $caller_data = array('pidm' => 0, 'wp_id' => null, 'identifier' => 'generic', 'email' => $GLOBALS['HELPDESK_EMAIL'], 'name_first' => 'Generic Caller', 'name_last' => 'Help Desk');
     switch ($caller) {
         case 'generic':
             $found_via = 'fake-user';
             break;
         case 'kiosk':
             $caller_data['identifier'] = 'kiosk';
             $caller_data['name_first'] = 'Kiosk';
             $found_via = 'fake-user';
             break;
         case 'clusteradm':
             $caller_data['identifier'] = 'clusteradm';
             $caller_data['name_first'] = 'Cluster Call';
             $found_via = 'fake-user';
             break;
     }
     //end switch
     $caller_data['name_full'] = $caller_data['name_first'] . ' - ' . $caller_data['name_last'];
     //
     // done with generic user setup; try to populate real user
     //
     if (!$person && !$this->isFakeUser($caller)) {
         // looks like a real user. try and find him.
         $caller_person = new PSUPerson($caller);
         if ($caller_person->is_valid()) {
             $person = array();
             $person['name_full'] = $caller_person->formatName('f l');
             $person['wp_id'] = $caller_person->wp_id;
             $person['email'] = $caller_person->wp_email;
             $person['pidm'] = $caller_person->pidm ? $caller_person->pidm : null;
             $person['identifier'] = $caller_person->wp_email ? $caller_person->wp_id : $caller_person->pidm;
             $person['username'] = $caller_person->username ?: $caller_person->wp_id;
             $found_via = 'psuperson';
         }
     }
     //end if
     //was a person record found?
     if (!empty($person)) {
         //Do some data cleansing
         $person['phone_number'] = $person['phone_of'] ? $person['phone_of'] : $person['phone_vm'];
         if ($person['pidm']) {
             $person['role'] = @implode(', ', PSU::get('idmobject')->getAllBannerRoles($person['identifier']));
         } else {
             $person['role'] = 'No Roles: Family Portal Only';
         }
         //end else
         if ($person['class'] == 'Alumni') {
             $person['class'] = strtolower($person['class']) . '.';
         }
         //end if
         if ($person['pidm']) {
             //get address for location
             if ($addresses = current($GLOBALS['BannerGeneral']->getAddress($person['pidm'], 'RH'))) {
                 $person['location'] = $addresses['r_street_line1'] . ' / ' . $person['msc'];
             } elseif ($addresses = current($GLOBALS['BannerGeneral']->getAddress($person['pidm'], 'OF'))) {
                 $person['location'] = $addresses['r_street_line2'] . ' / ' . $person['msc'];
             }
             //end elseif
             $psu_person = new PSUPerson($person['pidm']);
             $person['phone_number'] = $this->getCallerPhone($psu_person);
         }
         //end if
         //set the caller data to the person record
         $caller_data = $person;
     } elseif (!$this->isFakeUser($caller)) {
         $person = new PSUPerson($caller);
         $caller_data = array('pidm' => $person->pidm, 'wp_id' => $person->wp_id, 'psu_id' => $person->id, 'username' => $person->username, 'identifier' => $person->username ? $person->username : $person->wp_id, 'email' => $person->wp_email ? $person->wp_email : ($person->email ? $person->email['CA'][0] : ''), 'name_last' => $person->last_name, 'name_first' => $person->first_name, 'name_full' => "{$person->first_name} {$person->last_name}", 'phone_number' => $this->getCallerPhone($person));
         if (isset($caller_data['email']['CA']) && strpos($caller_data['email']['CA'], '@') !== false) {
             $caller_data['email'] = $caller_data['email']['CA'][0];
         } elseif (count($caller_data['email'])) {
             if (is_array($caller_data['email'])) {
                 $caller_data['email'] = array_shift(array_shift($caller_data['email']));
             } else {
                 $caller_data['email'] = $caller_data['email'];
             }
         } else {
             $caller_data['email'] = null;
         }
     }
     $caller_data['username'] = $caller_data['username'] ?: $caller_data['identifier'];
     if ($found_via == null) {
         return false;
     }
     //store the caller data so it isn't requeried a crap ton of times
     $this->people[$caller] = $caller_data;
     return $caller_data;
 }
 function __construct(&$db, $prod = false)
 {
     parent::__construct($db);
     $this->activity_date = date('d-M-Y H:i:s');
     $this->entry_date = date('d-M-Y H:i:s');
     $this->effective_date = date('d-M-Y');
     $this->trans_date = date('d-M-Y');
     $config = \PSU\Config\Factory::get_config();
     $this->prod = $prod;
     $this->pass_phrase = $config->get_encoded('ecommerce', 'legacy_passwd');
     $this->directory = $this->base_dir . '/' . ($this->prod ? 'prod' : 'test');
     $this->user = '******';
 }