Commit 4d7e5861 authored by Robert Lyon's avatar Robert Lyon
Browse files

Elasticsearch not finding unattached group artefacts (bug #1237177)

- items in group -> files not being found if they are not attached to
a view

- added code so that unattached group artefacts can be checked against
the artefact_access_role table (currently only used for group
artefacts) to see what roles they can be viewed by

Change-Id: I17eb03241e10e44460c0596c3d982c00dd39f336
Signed-off-by: Robert Lyon's avatarRobert Lyon <>
parent 730f8b27
......@@ -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 = ?
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