PluginProbe
Tutor LMS – eLearning and online course solution / 3.4.2
Tutor LMS – eLearning and online course solution v3.4.2
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
← All changes | models/LessonModel.php +4 -59 4.0.33.4.2 View file →
@@ -9,10 +9,8 @@
9 9 */
10 10
11 11 namespace Tutor\Models;
12 12
13 -use Tutor\Helpers\QueryHelper;
14 -
15 13 /**
16 14 * LessonModel Class
17 15 *
18 16 * @since 2.0.10
@@ -23,41 +21,25 @@
23 21 * Get total number of lesson
24 22 *
25 23 * @since 2.0.2
26 24 *
27 - * @since 3.7.1 Course ids param added
28 - *
29 - * @param array $course_ids Array of course ids.
30 - *
31 25 * @return int
32 26 */
33 - public static function get_total_lesson( array $course_ids = array() ) {
27 + public static function get_total_lesson() {
34 28 global $wpdb;
35 29 $lesson_type = tutor()->lesson_post_type;
36 30
37 - $course_in_clause = '';
38 - if ( count( $course_ids ) ) {
39 - $prepare_ids = QueryHelper::prepare_in_clause( $course_ids );
40 - $course_in_clause = "AND course.ID IN ({$prepare_ids})";
41 - }
42 -
43 - $post_status = QueryHelper::prepare_in_clause( array( 'publish', 'future', 'draft', 'private', 'pending' ) );
44 - $post_status_in_clause = "AND course.post_status IN ({$post_status})";
45 -
46 31 $sql = "SELECT COUNT(DISTINCT lesson.ID)
47 32 FROM {$wpdb->posts} lesson
48 33 INNER JOIN {$wpdb->posts} topic ON lesson.post_parent=topic.ID
49 34 INNER JOIN {$wpdb->posts} course ON topic.post_parent=course.ID
50 - WHERE 1 = 1
51 - {$course_in_clause}
52 - AND lesson.post_type = %s
35 + WHERE lesson.post_type = %s
53 36 AND lesson.post_status = %s
54 - {$post_status_in_clause}
37 + AND course.post_status = %s
55 38 AND topic.post_status = %s";
56 39
57 40 //phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
58 - $result = $wpdb->get_var( $wpdb->prepare( $sql, $lesson_type, 'publish', 'publish' ) );
59 - return $result;
41 + return $wpdb->get_var( $wpdb->prepare( $sql, $lesson_type, 'publish', 'publish', 'publish' ) );
60 42 }
61 43
62 44 /**
63 45 * Get total lesson count by a course
@@ -148,43 +130,6 @@
148 130
149 131 do_action( 'tutor_mark_lesson_complete_before', $post_id, $user_id );
150 132 update_user_meta( $user_id, '_tutor_completed_lesson_id_' . $post_id, tutor_time() );
151 133 do_action( 'tutor_mark_lesson_complete_after', $post_id, $user_id );
152 - }
153 -
154 - /**
155 - * Get lesson details.
156 - *
157 - * @since 3.7.0
158 - *
159 - * @param int $lesson_id lesson id.
160 - *
161 - * @return array
162 - */
163 - public static function get_lesson_details( $lesson_id ) {
164 - $post = get_post( $lesson_id, ARRAY_A );
165 -
166 - if ( $post ) {
167 - $post['thumbnail_id'] = get_post_meta( $lesson_id, '_thumbnail_id', true );
168 - $post['thumbnail'] = get_the_post_thumbnail_url( $lesson_id );
169 - $post['attachments'] = tutor_utils()->get_attachments( $lesson_id );
170 -
171 - $video = maybe_unserialize( get_post_meta( $lesson_id, '_video', true ) );
172 - if ( $video ) {
173 - $source = $video['source'] ?? '';
174 - if ( 'html5' === $source ) {
175 - $poster_url = wp_get_attachment_url( $video['poster'] ?? 0 );
176 - $source_html5 = wp_get_attachment_url( $video['source_video_id'] ?? 0 );
177 - $video['poster_url'] = $poster_url;
178 - $video['source_html5'] = $source_html5;
179 - }
180 - }
181 - $post['video'] = $video;
182 - } else {
183 - $post = array();
184 - }
185 -
186 - $data = apply_filters( 'tutor_lesson_details_response', $post, $lesson_id );
187 -
188 - return $data;
189 134 }
190 135 }