/** * (non-PHPdoc) * @see EPDBObject::loadSummaryFields() */ public function loadSummaryFields($summaryFields = null) { if (is_null($summaryFields)) { $summaryFields = array('courses', 'terms', 'students', 'active'); } else { $summaryFields = (array) $summaryFields; } $fields = array(); if (in_array('courses', $summaryFields)) { $fields['courses'] = EPCourse::count(array('org_id' => $this->getId())); } if (in_array('terms', $summaryFields)) { $fields['terms'] = EPTerm::count(array('org_id' => $this->getId())); } $dbr = wfGetDB(DB_SLAVE); if (in_array('students', $summaryFields)) { $termIds = EPTerm::selectFields('id', array('org_id' => $this->getId())); if (count($termIds) > 0) { $fields['students'] = $dbr->select('ep_students_per_term', 'COUNT(*) AS rowcount', array('spt_term_id' => $termIds)); $fields['students'] = $fields['students']->fetchObject()->rowcount; } else { $fields['students'] = 0; } } if (in_array('active', $summaryFields)) { $now = wfGetDB(DB_SLAVE)->addQuotes(wfTimestampNow()); $fields['active'] = EPTerm::has(array('org_id' => $this->getId(), 'end >= ' . $now, 'start <= ' . $now)); } $this->setFields($fields); }
/** * (non-PHPdoc) * @see EPPager::getFilterOptions() */ protected function getFilterOptions() { $options = array(); if (!array_key_exists('course_id', $this->conds)) { $options['course_id'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPCourse::getCourseOptions(EPCourse::select(array('name', 'id')))), 'value' => '', 'datatype' => 'int'); $options['org_id'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPOrg::getOrgOptions(EPOrg::select(array('name', 'id')))), 'value' => '', 'datatype' => 'int'); } $years = EPTerm::selectFields('year', array(), array('DISTINCT'), array(), true); asort($years, SORT_NUMERIC); $years = array_merge(array(''), $years); $years = array_combine($years, $years); $options['year'] = array('type' => 'select', 'options' => $years, 'value' => ''); $options['status'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPTerm::getStatuses()), 'value' => 'current'); return $options; }