コード例 #1
0
ファイル: EPOrg.php プロジェクト: schwarer2006/wikia
 /**
  * (non-PHPdoc)
  * @see EPDBObject::loadSummaryFields()
  */
 public function loadSummaryFields($summaryFields = null)
 {
     if (is_null($summaryFields)) {
         $summaryFields = array('courses', 'students', 'active', 'instructors', 'oas', 'cas');
     } else {
         $summaryFields = (array) $summaryFields;
     }
     $fields = array();
     if (in_array('courses', $summaryFields)) {
         $fields['courses'] = EPCourse::count(array('org_id' => $this->getId()));
     }
     $dbr = wfGetDB(DB_SLAVE);
     if (in_array('students', $summaryFields)) {
         $courseIds = EPCourse::selectFields('id', array('org_id' => $this->getId()));
         if (count($courseIds) > 0) {
             $fields['students'] = $dbr->select('ep_students_per_course', 'COUNT(*) AS rowcount', array('spc_course_id' => $courseIds));
             $fields['students'] = $fields['students']->fetchObject()->rowcount;
         } else {
             $fields['students'] = 0;
         }
     }
     if (in_array('active', $summaryFields)) {
         $now = wfGetDB(DB_SLAVE)->addQuotes(wfTimestampNow());
         $fields['active'] = EPCourse::has(array('org_id' => $this->getId(), 'end >= ' . $now, 'start <= ' . $now));
     }
     $courseFields = array();
     $upInstructors = in_array('instructors', $summaryFields);
     $upOas = in_array('oas', $summaryFields);
     if ($upInstructors) {
         $courseFields[] = 'instructors';
         $fields['instructors'] = 0;
     }
     if ($upOas) {
         $courseFields[] = 'online_ambs';
         $fields['online_ambs'] = 0;
     }
     if (count($courseFields) > 0) {
         $courses = EPCourse::select($courseFields, array('org_id' => $this->getId()));
         foreach ($courses as $course) {
             // TODO: foreach set field: count and add to fields[name]
         }
     }
     $this->setFields($fields);
 }
コード例 #2
0
 /**
  * Adds a control to add a new term to the provided context
  * or show a message if this is not possible for some reason.
  *
  * @since 0.1
  *
  * @param IContextSource $context
  * @param array $args
  */
 public static function displayAddNewRegion(IContextSource $context, array $args = array())
 {
     if (EPCourse::has()) {
         EPTerm::displayAddNewControl($context, $args);
     } elseif ($context->getUser()->isAllowed('ep-course')) {
         $context->getOutput()->addWikiMsg('ep-terms-addcoursefirst');
     }
 }