/** * Gets the summary data. * * @since 0.1 * * @param EPMentor $mentor * * @return array */ protected function getSummaryData(EPDBObject $mentor) { $stats = array(); $orgs = array(); foreach ($mentor->getOrgs('name') as $org) { $orgs[] = Linker::linkKnown(SpecialPage::getTitleFor('Institution', $org->getField('name')), htmlspecialchars($org->getField('name'))); } $stats['orgs'] = $this->getLanguage()->pipeList($orgs); return $stats; }
/** * Gets the summary data. * * @since 0.1 * * @param EPTerm $term * * @return array */ protected function getSummaryData(EPDBObject $term) { $stats = array(); $org = EPOrg::selectFieldsRow('name', array('id' => $term->getField('org_id'))); $stats['org'] = Linker::linkKnown(SpecialPage::getTitleFor('Institution', $org), htmlspecialchars($org)); $course = EPCourse::selectFieldsRow('name', array('id' => $term->getField('course_id'))); $stats['course'] = Linker::linkKnown(SpecialPage::getTitleFor('Course', $course), htmlspecialchars($course)); $stats['year'] = htmlspecialchars($this->getLanguage()->formatNum($term->getField('year'), true)); $stats['start'] = htmlspecialchars($this->getLanguage()->timeanddate($term->getField('start'), true)); $stats['end'] = htmlspecialchars($this->getLanguage()->timeanddate($term->getField('end'), true)); if ($this->getUser()->isAllowed('ep-token')) { $stats['token'] = Linker::linkKnown(SpecialPage::getTitleFor('Enroll', $term->getId() . '/' . $term->getField('token')), htmlspecialchars($term->getField('token'))); } return $stats; }
/** * Gets the summary data. * * @since 0.1 * * @param EPStudent $student * * @return array */ protected function getSummaryData(EPDBObject $student) { $stats = array(); $id = $student->getUser()->getId(); $stats['user'] = Linker::userLink($id, $student->getName()) . Linker::userToolLinks($id, $student->getName()); $stats['first-enroll'] = htmlspecialchars($this->getLanguage()->timeanddate($student->getField('first_enroll'), true)); $stats['last-active'] = htmlspecialchars($this->getLanguage()->timeanddate($student->getField('last_active'), true)); $stats['active-enroll'] = wfMsgHtml($student->getField('active_enroll') ? 'ep-student-actively-enrolled' : 'ep-student-no-active-enroll'); return $stats; }
/** * Gets the summary data. * * @since 0.1 * * @param EPOrg $org * * @return array */ protected function getSummaryData(EPDBObject $org) { $stats = array(); $stats['name'] = $org->getField('name'); $stats['city'] = $org->getField('city'); $countries = CountryNames::getNames($this->getLanguage()->getCode()); $stats['country'] = $countries[$org->getField('country')]; $stats['status'] = wfMsgHtml($org->getField('active') ? 'ep-institution-active' : 'ep-institution-inactive'); $stats['courses'] = $this->getLanguage()->formatNum($org->getField('courses')); $stats['students'] = $this->getLanguage()->formatNum($org->getField('students')); foreach ($stats as &$stat) { $stat = htmlspecialchars($stat); } if ($org->getField('courses') > 0) { $stats['courses'] = Linker::linkKnown(SpecialPage::getTitleFor('Courses'), $stats['courses'], array(), array('org_id' => $org->getId())); } return $stats; }
/** * (non-PHPdoc) * @see TablePager::formatRow() */ function formatRow($row) { $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> $this->currentObject = $c::newFromDBResult($row); $cells = array(); foreach ($this->getFieldNames() as $field => $name) { if ($field === '_select') { $value = Html::element('input', array('type' => 'checkbox', 'value' => $this->currentObject->getId(), 'id' => 'select-' . $this->getInstanceNumber() . '-' . $this->currentObject->getId(), 'name' => 'epitemsselected', 'class' => 'ep-select-item', 'data-pager-id' => $this->getInstanceNumber())); } elseif ($field === '_controls') { $value = $this->getLanguage()->pipeList($this->getControlLinks($this->currentObject)); } else { $prefixedField = $c::getPrefixedField($field); $value = isset($row->{$prefixedField}) ? $row->{$prefixedField} : null; } $formatted = strval($this->formatValue($field, $value)); if ($formatted == '') { $formatted = ' '; } $cells[] = Html::rawElement('td', $this->getCellAttrs($field, $value), $formatted); } return Html::rawElement('tr', $this->getRowAttrs($row), implode('', $cells)) . "\n"; }
/** * Gets the summary data. * * @since 0.1 * * @param EPCourse $course * * @return array */ protected function getSummaryData(EPDBObject $course) { $stats = array(); $stats['name'] = htmlspecialchars($course->getField('name')); $org = EPOrg::selectFieldsRow('name', array('id' => $course->getField('org_id'))); $stats['org'] = Linker::linkKnown(SpecialPage::getTitleFor('Institution', $org), htmlspecialchars($org)); $stats['status'] = wfMsgHtml($course->getField('active') ? 'ep-course-active' : 'ep-course-inactive'); $lang = $this->getLanguage(); $stats['students'] = htmlspecialchars($lang->formatNum($course->getField('students'))); $termCount = EPTerm::count(array('course_id' => $course->getId())); $stats['terms'] = htmlspecialchars($lang->formatNum($termCount)); if ($termCount > 0) { $stats['terms'] = Linker::linkKnown(SpecialPage::getTitleFor('Terms'), $stats['terms'], array(), array('course_id' => $course->getId())); } $stats['instructors'] = $this->getInstructorsList($course) . $this->getInstructorControls($course); return $stats; }
/** * Gets the summary data. * * @since 0.1 * * @param EPCourse $course * * @return array */ protected function getSummaryData(EPDBObject $course) { $stats = array(); $orgName = EPOrg::selectFieldsRow('name', array('id' => $course->getField('org_id'))); $stats['org'] = EPOrg::getLinkFor($orgName); $lang = $this->getLanguage(); $stats['term'] = htmlspecialchars($course->getField('term')); $stats['start'] = htmlspecialchars($lang->timeanddate($course->getField('start'), true)); $stats['end'] = htmlspecialchars($lang->timeanddate($course->getField('end'), true)); $stats['students'] = htmlspecialchars($lang->formatNum($course->getField('students'))); $stats['status'] = htmlspecialchars(EPCourse::getStatusMessage($course->getStatus())); if ($this->getUser()->isAllowed('ep-token')) { $stats['token'] = Linker::linkKnown(SpecialPage::getTitleFor('Enroll', $course->getId() . '/' . $course->getField('token')), htmlspecialchars($course->getField('token'))); } $stats['instructors'] = $this->getRoleList($course, 'instructor') . $this->getRoleControls($course, 'instructor'); $stats['online'] = $this->getRoleList($course, 'online') . $this->getRoleControls($course, 'online'); $stats['campus'] = $this->getRoleList($course, 'campus') . $this->getRoleControls($course, 'campus'); return $stats; }
/** * @see parent::__construct * * @since 0.1 * * @param array|null $fields * @param bool $loadDefaults */ public function __construct($fields = null, $loadDefaults = false) { parent::__construct($fields, $loadDefaults); }
/** * (non-PHPdoc) * @see EPDBObject::remove() */ public function remove() { $object = clone $this; $object->loadFields(); $success = parent::remove(); if ($success) { $object->onRemoved(); } return $success; }
/** * Gets the default value for a field from the item. * * @since 0.1 * * @param EPDBObject $item * @param string $name * * @return mixed */ protected function getDefaultFromItem(EPDBObject $item, $name) { return $item->getField($name); }
/** * (non-PHPdoc) * @see EPDBObject::updateInDB() */ protected function updateInDB() { if ($this->updateSummaries) { $oldOrgId = $this->hasField('org_id') ? self::selectFieldsRow('org_id', array('id' => $this->getId())) : false; $oldCourseId = $this->hasField('course_id') ? self::selectFieldsRow('course_id', array('id' => $this->getId())) : false; } if ($this->hasField('course_id')) { $oldCourseId = self::selectFieldsRow('course_id', array('id' => $this->getId())); if ($this->getField('course_id') !== $oldCourseId) { $this->setField('org_id', EPCourse::selectFieldsRow('org_id', array('id' => $this->getField('course_id')))); } } $success = parent::updateInDB(); if ($this->updateSummaries && $success) { if ($oldOrgId !== false && $oldOrgId !== $this->getField('org_id')) { $conds = array('id' => array($oldOrgId, $this->getField('org_id'))); EPOrg::updateSummaryFields(array('terms', 'students', 'active'), $conds); } if ($oldCourseId !== false && $oldCourseId !== $this->getField('org_id')) { $conds = array('id' => array($oldCourseId, $this->getField('course_id'))); EPCourse::updateSummaryFields(array('active', 'students'), $conds); } } return $success; }
/** * (non-PHPdoc) * @see EPDBObject::setField() */ public function setField($name, $value) { if ($name === 'instructors') { $this->instructors = false; } elseif ($name === 'org_id') { $this->org = false; } parent::setField($name, $value); }
/** * Set the database type to use for read operations. * * @param integer $db * * @since 0.2 */ public static function setReadDb($db) { self::$readDb = $db; }
/** * (non-PHPdoc) * @see EPDBObject::removeFromDB() */ public function removeFromDB() { $id = $this->getId(); $this->loadFields(array('name')); $success = parent::removeFromDB(); if ($success) { $success = wfGetDB(DB_MASTER)->delete('ep_mentors_per_org', array('mpo_org_id' => $id)) && $success; foreach (EPCourse::select('id', array('org_id' => $id)) as $course) { $success = $course->removeFromDB() && $success; } } return $success; }