Skip to content

Commit

Permalink
refs #990, different search mehtod for OC 13 and 14
Browse files Browse the repository at this point in the history
  • Loading branch information
tgloeggl committed Aug 8, 2024
1 parent 974874c commit 3bd5baa
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions classes/OCRestClient/ApiEventsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,29 @@ public function getBySeries($series_id, $course_id)

if (version_compare($this->getOcVersion(), '16', '<'))
{
/* * * * * * * * * * * * * * * * * * * * * * * * */
/* * * * O P E N C A S T 1 5 * * */
/* * * * * * * * * * * * * * * * * * * * * * * * */
// first, get list of events ids from search service
$search_query = '';
if ($search) {
$search_query = " AND ( *:(dc_title_:($search)^6.0 dc_creator_:($search)^4.0 dc_subject_:($search)^4.0 dc_publisher_:($search)^2.0 dc_contributor_:($search)^2.0 dc_abstract_:($search)^4.0 dc_description_:($search)^4.0 fulltext:($search) fulltext:(*$search*) ) OR (id:$search) )";
}

$lucene_query = '(dc_is_part_of:' . $series_id . ')' . $search_query
. ' AND oc_acl_read:' . $course_id . '_' . $type;
// special treatment for Opencast 14 and below
if (version_compare($this->getOcVersion(), '15', '<')) {
$search_events = $search_service->getJSON(
"/episode.json?sid=$series_id&q=". urlencode($search)
. "&sort=". urlencode($sort) ."&limit=$limit&offset=$offset"
);
} else {
$search_query = '';
if ($search) {
$search_query = " AND ( *:(dc_title_:($search)^6.0 dc_creator_:($search)^4.0 dc_subject_:($search)^4.0 dc_publisher_:($search)^2.0 dc_contributor_:($search)^2.0 dc_abstract_:($search)^4.0 dc_description_:($search)^4.0 fulltext:($search) fulltext:(*$search*) ) OR (id:$search) )";
}

$lucene_query = '(dc_is_part_of:' . $series_id . ')' . $search_query
. ' AND oc_acl_read:' . $course_id . '_' . $type;

$search_events = $search_service->getJSON('/lucene.json?q=' . urlencode($lucene_query)
. "&sort=$sort&limit=$limit&offset=$offset");
$search_events = $search_service->getJSON('/lucene.json?q=' . urlencode($lucene_query)
. "&sort=$sort&limit=$limit&offset=$offset");
}

Pager::setLength($search_events->{'search-results'}->total);

Expand Down

0 comments on commit 3bd5baa

Please sign in to comment.