Select Git revision
GlobalSearchCourseware.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
GlobalSearchCourseware.php 7.39 KiB
<?php
use Courseware\StructuralElement;
use Courseware\Block;
use Courseware\Container;
use Courseware\Unit;
/**
* Global search module for files
*
* @author Ron Lucke <lucke@elan-ev.de>
* @category Stud.IP
* @since 5.2
*/
class GlobalSearchCourseware extends GlobalSearchModule implements GlobalSearchFulltext
{
/**
* Returns the displayname for this module
*
* @return string
*/
public static function getName()
{
return _('Courseware');
}
/**
* Returns the filters that are displayed in the sidebar of the global search.
*
* @return array Filters for this class.
*/
public static function getFilters()
{
return [];
}
public static function getSQL($search, $filter, $limit)
{
if (!$search) {
return null;
}
$query = DBManager::get()->quote("%{$search}%");
if (!empty($filter['rangeId'])) {
$range_id = $filter['rangeId'];
$sql = "(SELECT `cw_structural_elements` . `id` AS id, CONCAT('', 'cw_structural_elements') AS type
FROM `cw_structural_elements`
WHERE (`title` LIKE {$query} OR `payload` LIKE {$query})
AND `range_id` = '{$range_id}'
ORDER BY `cw_structural_elements`.`mkdate` DESC)
UNION (
SELECT se . `id` AS id, CONCAT('', 'cw_containers') AS type
FROM `cw_containers` c
JOIN cw_structural_elements se
ON se . `id` = c . `structural_element_id`
WHERE c. `payload` LIKE {$query}
AND `container_type` != 'list'
AND se . `range_id` = '{$range_id}'
ORDER BY c . `mkdate` DESC)
UNION (
SELECT se . `id` AS id, CONCAT('', 'cw_blocks') AS type
FROM `cw_blocks` b
JOIN cw_containers c
ON c.id = b.container_id
JOIN cw_structural_elements se
ON se . `id` = c . `structural_element_id`
WHERE b.payload LIKE {$query}
AND se . `range_id` = '{$range_id}'
ORDER BY b . `mkdate` DESC
) LIMIT {$limit}";