diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index c81470510e..432a9221b7 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -1460,6 +1460,7 @@ class API_V1_adapter extends API_V1_Abstract return null; } + if ($this->app['authentication']->isAuthenticated()) { if ($media->get_name() !== 'document' && false === $this->app['authentication']->getUser()->ACL()->has_access_to_subdef($record, $media->get_name())) { return null; @@ -1470,6 +1471,17 @@ class API_V1_adapter extends API_V1_Abstract } } + $databox = $record->get_databox(); + try { + $subDefDefinition = $databox->get_subdef_structure()->get_subdef($record->get_type(), $media->get_name()); + } catch (Exception_Databox_SubdefNotFound $e) { + return null; + } + + if (false === $subDefDefinition->is_downloadable()) { + return null; + } + if ($media->get_permalink() instanceof media_Permalink_Adapter) { $permalink = $this->list_permalink($media->get_permalink(), $registry); } else { diff --git a/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php b/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php index 05308b48d1..9eba7fc22f 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php +++ b/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php @@ -1067,7 +1067,6 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $embedTypes = array_flip(array_map(function($subdef) {return $subdef['name'];},$content['response']['embed'])); //access to all subdefs - $this->assertArrayHasKey('document', $embedTypes); $this->assertArrayHasKey('preview', $embedTypes); $this->assertArrayHasKey('thumbnail', $embedTypes);