From e50d3340ffcc35b4d9dd3ca1bf991d0a7b462c0d Mon Sep 17 00:00:00 2001 From: Dennis Benz Date: Tue, 7 Nov 2023 11:13:09 +0100 Subject: [PATCH] Fix sql syntax error in get courses of playlist, ref #664 This error occurs for non-dozent users. --- lib/Models/PlaylistSeminars.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Models/PlaylistSeminars.php b/lib/Models/PlaylistSeminars.php index 58c0339c0..ddc706fc9 100644 --- a/lib/Models/PlaylistSeminars.php +++ b/lib/Models/PlaylistSeminars.php @@ -95,20 +95,20 @@ public static function getPlaylistVideosCourses($playlist_id, $cid) { global $perm; $query = 'SELECT DISTINCT ops.seminar_id FROM oc_playlist_seminar AS ops'. - ' INNER JOIN oc_playlist_video AS opv ON (opv.playlist_id = ops.playlist_id)'. - ' WHERE opv.video_id IN (SELECT opv_i.video_id FROM oc_playlist_video AS opv_i WHERE opv_i.playlist_id = :playlist_id)'; + ' INNER JOIN oc_playlist_video AS opv ON (opv.playlist_id = ops.playlist_id)'; + $where = ' WHERE opv.video_id IN (SELECT opv_i.video_id FROM oc_playlist_video AS opv_i WHERE opv_i.playlist_id = :playlist_id)'; $params = [':playlist_id' => $playlist_id]; if (!(empty($cid) || $perm->have_perm('dozent'))) { - $query .= ' LEFT JOIN oc_playlist_seminar_video AS opsv ON (opsv.playlist_seminar_id = ops.id AND opsv.video_id = opv.video_id)'. - ' WHERE (ops.seminar_id = :cid '. + $query .= ' LEFT JOIN oc_playlist_seminar_video AS opsv ON (opsv.playlist_seminar_id = ops.id AND opsv.video_id = opv.video_id)'; + $where .= ' AND (ops.seminar_id = :cid '. ' AND (opsv.visibility IS NULL AND opsv.visible_timestamp IS NULL AND ops.visibility = "visible"'. ' OR opsv.visibility = "visible" AND opsv.visible_timestamp IS NULL'. ' OR opsv.visible_timestamp < NOW()))'; - $params[':cid'] = $cid; } + $query .= $where; $stmt = \DBManager::get()->prepare($query); $stmt->execute($params); return $stmt->fetchAll(\PDO::FETCH_COLUMN);