Commit 1a43b4ed authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review

Merge "Elasticsearch not finding unattached group artefacts (bug #1237177)"

parents 954c08d4 4d7e5861
......@@ -188,6 +188,15 @@ class ElasticsearchType_artefact extends ElasticsearchType
// Access: get all the views where the artefact is included
$access = self::view_access_records($id);
$accessObj = self::access_process($access);
if (!$access) {
// File access: get viewable group media not attached to a view
$groupaccess = self::group_artefact_access_records($id);
if ($groupaccess) {
foreach ($groupaccess as $access) {
$accessObj['groups'][$access->role][] = $access->can_view;
}
}
}
$record->access = $accessObj;
// set 'mainfacetterm' & 'artefactgroup'
......@@ -366,6 +375,18 @@ class ElasticsearchType_artefact extends ElasticsearchType
return $records;
}
/**
* Get all access records of the group artefacts (called if not attached to view)
*/
public static function group_artefact_access_records($artefactid) {
$records = get_records_sql_array('
SELECT role, can_view FROM {artefact_access_role} WHERE artefact = ?
',
array($artefactid)
);
return $records;
}
/**
* Get views linked to a particular artefact, applying ACL
* This is used to display the list of views in an artefact result, because it's faster to retrieve the info
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment