Exemplo n.º 1
0
 /**
  * Returns the courses this student is enrolled in.
  *
  * @since 0.1
  *
  * @param string|array|null $fields
  * @param array $conditions
  *
  * @return array of EPCourse
  */
 protected function doGetCourses($fields, array $conditions)
 {
     $conditions[] = array(array('ep_students', 'id'), $this->getId());
     return EPCourse::select($fields, $conditions, array(), array('ep_students_per_course' => array('INNER JOIN', array(array(array('ep_students_per_course', 'course_id'), array('ep_courses', 'id')))), 'ep_students' => array('INNER JOIN', array(array(array('ep_students_per_course', 'student_id'), array('ep_students', 'id'))))));
 }
Exemplo n.º 2
0
 /**
  * Returns the courses this student is linked to (via terms).
  *
  * @since 0.1
  *
  * @param string|null|array $fields
  * @param array $conditions
  * @param array $termConditions
  *
  * @return array of EPCourse
  */
 public function getCourses($fields = null, array $conditions = array(), array $termConditions = array())
 {
     $courseIds = array_reduce($this->getTerms('course_id', $termConditions), function (array $ids, EPTerm $term) {
         $ids[] = $term->getField('course_id');
         return $ids;
     }, array());
     if (count($courseIds) < 1) {
         return array();
     }
     $conditions['id'] = array_unique($courseIds);
     return EPCourse::select($fields, $conditions);
 }
Exemplo n.º 3
0
 /**
  * Returns a list of courses in an array that can be fed to select inputs.
  *
  * @since 0.1
  *
  * @param array|null $courses
  *
  * @return array
  */
 public static function getCourseOptions(array $courses = null)
 {
     $options = array();
     if (is_null($courses)) {
         $courses = EPCourse::select(array('name', 'id'));
     }
     foreach ($courses as $course) {
         $options[$course->getField('name')] = $course->getId();
     }
     return $options;
 }
Exemplo n.º 4
0
 /**
  * Returns the courses this online ambassdor is associated with.
  *
  * @since 0.1
  *
  * @param string|array|null $fields
  * @param array $conditions
  *
  * @return array of EPCourse
  */
 protected function doGetCourses($fields, array $conditions)
 {
     $conditions[] = array(array('ep_oas_per_course', 'user_id'), $this->getField('user_id'));
     return EPCourse::select($fields, $conditions, array(), array('ep_oas_per_course' => array('INNER JOIN', array(array(array('ep_oas_per_course', 'course_id'), array('ep_courses', 'id'))))));
 }
Exemplo n.º 5
0
 /**
  * (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;
 }
Exemplo n.º 6
0
 /**
  * Retruns the courses linked to this org.
  *
  * @since 0.1
  *
  * @param array|null $fields
  *
  * @return array of EPCourse
  */
 public function getCourses(array $fields = null)
 {
     if ($this->courses === false) {
         $this->courses = EPCourse::select($fields, array('org_id' => $this->getId()));
     }
     return $this->courses;
 }