예제 #1
0
 /**
  * Return an array of EfrontLesson objects, based on the specified constraints. If any of the lessons
  * is part of the course, then it has an extra field 'has_lesson' set to 1
  *
  * @param array $constraints Database constraints
  * @return array All the lessons, with course lessons having has_lesson=1
  * @since 3.6.3
  * @access public
  */
 public function getCourseLessonsIncludingUnassigned($constraints = array())
 {
     !empty($constraints) or $constraints = array('archive' => false, 'active' => true);
     list($where, $limit, $orderby) = EfrontCourse::convertLessonConstraintsToSqlParameters($constraints);
     $from = "lessons l left outer join (select lessons_ID from lessons_to_courses where courses_ID='" . $this->course['id'] . "') r on l.id=r.lessons_ID ";
     $select = "l.*, r.lessons_ID is not null as has_lesson";
     $where[] = "l.course_only=1";
     $result = eF_getTableData($from, $select, implode(" and ", $where), $orderby, false, $limit);
     if (!isset($constraints['return_objects']) || $constraints['return_objects'] == true) {
         return EfrontCourse::convertDatabaseResultToLessonObjects($result);
     } else {
         return EfrontCourse::convertDatabaseResultToLessonArray($result);
     }
 }