/** * constructor * * @param $row array Array of row elements */ public function __construct($row = null) { parent::__construct($row); $this->detail_desc = $this->detail_desc(); $this->entry_date = $this->activity_date = date('Y-m-d H:i:s'); $this->trans_date = $this->effective_date = date('Y-m-d'); \PSU::add_filter('transaction_term_types', array(&$this, 'apply_to_terms'), 10, 2); \PSU::add_filter('transaction_term_skip', array(&$this, 'apply_skip_terms'), 10, 3); }
function testFilter() { PSU::add_filter('testFilter_1', array($this, 'method_filter')); $this->assertEquals(PSU::apply_filters('testFilter_1', 'foobar'), 'method_filter_foobar', 'Filter via object method'); PSU::add_filter('testFilter_2', 'global_function_filter'); $this->assertEquals(PSU::apply_filters('testFilter_2', 'foobar'), 'global_function_filter_foobar', 'Filter via global function'); PSU::add_filter('testFilter_3', array($this, 'multifilter1')); PSU::add_filter('testFilter_3', array($this, 'multifilter2')); $this->assertEquals(PSU::apply_filters('testFilter_3', 'foobar'), 'multifilter2_multifilter1_foobar', 'Chaining filters'); PSU::add_filter('testFilter_4', array($this, 'multifilter3'), 11); PSU::add_filter('testFilter_4', array($this, 'multifilter2')); PSU::add_filter('testFilter_4', array($this, 'multifilter1'), 9); $this->assertEquals(PSU::apply_filters('testFilter_4', 'foobar'), 'multifilter3_multifilter2_multifilter1_foobar', 'Chaining filters with priority #1'); PSU::add_filter('testFilter_5', array($this, 'multifilter1'), 9); PSU::add_filter('testFilter_5', array($this, 'multifilter3'), 11); PSU::add_filter('testFilter_5', array($this, 'multifilter2')); $this->assertEquals(PSU::apply_filters('testFilter_5', 'foobar'), 'multifilter3_multifilter2_multifilter1_foobar', 'Chaining filters with priority #2'); }
/** * constructor. Impressed? */ public function __construct($params = false, $prod = false) { parent::__construct($params, $prod); PSU::add_filter('transaction_split_pre_apply', array(&$this, 'pre_apply'), 10, 2); }
public function __construct($id, $report, $drill = array()) { $this->id = $id; $this->_chart_data = array(); $args = PSU::params($args); $args['id'] = $args['id'] ? $args['id'] : $this->id; if ($this->bind) { $args['bind'] = $this->bind; } //end if if ($this->bind_registry) { $args['bind_registry'] = $this->bind_registry; } //end if if ($this->params) { $args['params'] = $this->params; if (!$args['bind_registry']) { $args['bind_registry'] = array_keys((array) $args['params']); } //end if } //end if if ($this->bind_registry) { $args['bind_registry'] = $this->bind_registry; } //end if if ($this->database) { $args['database'] = $this->database; } //end if $this->format_exclude = array('date' => array(), 'decimal' => array(), 'money' => array(), 'percent' => array(), 'pre' => array(), 'number' => array('pidm', 'pidmcrn', 'crn', 'course_number', 'course_num', 'course_numb', 'crse_num', 'crse_numb', 'crse_number', 'fund_year', 'id', 'term_code', 'term_code_eff', 'term', 'zip', 'zip_code')); // this will hold the fields that the generic filter has already set. // filters customized with the generic set take precedence over the default settings $filter_fields = array(); // set up generic filters for ($i = 1; $i < 5; $i++) { $field = $_GET['psufilter_' . $i]['field']; $value = $_GET['psufilter_' . $i]['value']; $operator = $_GET['psufilter_' . $i]['operator']; // was an operater specified in the UI? if (!$operator) { // nope! default to an = sign $operator = '='; } //end if $filter_fields[] = $field; $this->filters['psufilter_' . $i] = new PSUReportFilter($field, $value, $operator); if ($field) { $this->filters['psureportfilter_' . $field] = new PSUReportFilter($field, $value, $operator); } //end if } //end for // load GET filters foreach ((array) $_GET as $key => $value) { if (strpos($key, 'psufilter_') === false && $key != 'page' && $key != 'graph_type' && $key != 'summary_field') { if ($this->filters[$key]) { if (in_array($this->filters[$key]->field, $filter_fields)) { $this->filters[$key]->value = $this->filters['psureportfilter_' . $key]->value; } else { $this->filters[$key]->value = $value; } //end else } else { $this->original_get[$key] = new PSUReportFilter($key, $value); } //end else } //end if } //end foreach // merge GET and other filters $this->filters = array_merge((array) $this->filters, (array) $this->original_get); foreach ($this->filters as $key => $filter) { $args['bind_registry'][] = str_replace('psureportfilter_', '', $key); $values = $filter->values(); foreach ($values as $key => $value) { $args['bind_registry'][] = $key; } //end foreach } //end foreach $args['bind_registry'] = array_unique((array) $args['bind_registry']); if ($this->nocache) { $args['nocache'] = true; } //end if // set up the sql object if (is_array($report)) { $this->data = (array) $report; if (count($this->data)) { $cols = array_keys(current($this->data)); $this->cols = array(); foreach ($cols as $col) { if ('class' == $col) { $col = 'class_'; } //end if $this->cols[$col] = (object) array('name' => $col); } //end foreach } //end if } elseif ($report instanceof PSUSQL) { $this->sql = $report; } else { $this->sql = new PSUSQL($report, $args); } //end else // apply set filters to the SQL statement if ($this->cols && $this->filters) { foreach ((array) $this->filters as $key => $filter) { if (array_key_exists($filter->field, $this->cols)) { $values = $filter->values(); $value_exists = false; foreach ($values as $key => $value) { // is there actually a value? if ($value !== null && $value != '') { $value_exists = true; } //end if $this->sql->_add_parameters(array($key => $value)); } //end foreach // only add the where if the value is not null if ($value_exists) { $this->sql->addWhere($filter->where()); } //end if } //end if } //end foreach } //end if $this->drill = $drill; self::$time = time(); // set up default colors $this->default_colors = array('rgb(120,90,59)', 'rgb(53,115,53)', 'rgb(178,87,56)', 'rgb(203,143,71)', 'rgb(55,106,155)', 'rgb(205,197,51)', 'rgb(209,130,139)', 'rgb(159,153,57)', 'rgb(206,173,136)', 'rgb(191,132,72)', 'rgb(151,135,169)', 'rgb(140,48,51)', 'rgb(59,144,187)', 'rgb(197,190,104)', 'rgb(109,136,79)', 'rgb(144,100,144)', 'rgb(181,94,94)', 'rgb(59,144,144)', 'rgb(204,136,92)', 'rgb(139,167,55)', 'rgb(205,171,66)', 'rgb(150,184,211)'); PSU::add_filter('psusql_' . $this->id . '_parse_results', array(&$this, 'parse_row')); }
<?php use Guzzle\Service\Client; use PSU\TeacherCert; require_once 'guzzle.phar'; /** * Old /me/ path redirects to /student/ */ respond('/me/?[*]?', function ($request, $response, $app) { $base_url = $app->config->get('teacher-cert', 'base_url'); $response->redirect($base_url . '/student/'); }); respond('/student/?[*]?', function ($request, $response, $app) { PSU::add_filter('student_view', 'PSU\\TeacherCert::__return_true'); }); respond(function ($request, $response, $app) { PSU::session_start(); $GLOBALS['BASE_URL'] = $app->config->get('teacher-cert', 'base_url'); $GLOBALS['TITLE'] = 'Teacher Certification'; $GLOBALS['TEMPLATES'] = PSU_BASE_DIR . '/app/teacher-cert/templates'; $domain = PSU::isdev() ? 'dev.plymouth.edu' : 'plymouth.edu'; $GLOBALS['PSUAPI'] = "https://api.{$domain}/0.1/?appid={{appid}}&appkey={{appkey}}"; unset($domain); if (file_exists(PSU_BASE_DIR . '/debug/teacher-cert-debug.php')) { include PSU_BASE_DIR . '/debug/teacher-cert-debug.php'; } IDMObject::authN(); $app->client = new Client($GLOBALS['PSUAPI']); $app->client->setConfig(array('appid' => $app->config->get('teacher-cert', 'api_appid'), 'appkey' => $app->config->get('teacher-cert', 'api_key'))); $app->readonly = false; $app->student_view = false;
/** * parses payment plan data and inserts/updates memos for UG */ public static function parsePaymentPlanUG($term_code, $record, $data) { if ($data['funds_not_disbursed'] == 0 && $data['contract_balance'] == 0) { return true; } //end if $current_term_code = \PSU\AR::bursar_term('ug'); $record['expiration_date'] = strtotime('+5 days', $record['entry_date']); \PSU::add_filter('transaction_term_skip', __CLASS__ . '::payment_plan_ug_skip_term_filter', 10, 3); // are there funds not disbursed? if ($data['funds_not_disbursed'] > 0) { $record['term_code'] = $current_term_code; $record['amount'] = $data['funds_not_disbursed']; $record['billing_ind'] = 'Y'; $max_tran_number = \PSU\AR\Memos::max_tran_number($record['pidm']); $record['tran_number'] = $max_tran_number + 1; if (!self::updateMemo($record)) { return false; } //end if } //end if $transaction = new \PSU\AR\Transaction\Memo($record['pidm'], $data['contract_balance']); $transaction->billable(FALSE); $transaction->level = 'UG'; $transaction->split($record); if (!$transaction->save()) { return false; } //end if return true; }