From: Tim Otten Date: Mon, 9 Feb 2015 13:21:18 +0000 (-0800) Subject: DynamicFKAuthorization - Add comment X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2e37a19feb9f5ae77e90e7f669358d565f57f016;p=civicrm-core.git DynamicFKAuthorization - Add comment --- diff --git a/Civi/API/Subscriber/DynamicFKAuthorization.php b/Civi/API/Subscriber/DynamicFKAuthorization.php index 4aeef4c314..3b7b83b239 100644 --- a/Civi/API/Subscriber/DynamicFKAuthorization.php +++ b/Civi/API/Subscriber/DynamicFKAuthorization.php @@ -73,7 +73,7 @@ class DynamicFKAuthorization implements EventSubscriberInterface { protected $actions; /** - * @var string, SQL; a query which looks up the related entity + * @var string, SQL. Given a file ID, determine the entity+table it's attached to. * * ex: "SELECT if(cf.id,1,0) as is_valid, cef.entity_table, cef.entity_id * FROM civicrm_file cf diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 7de921c889..182737e712 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -162,6 +162,7 @@ class Container { $kernel, 'Attachment', array('create', 'get', 'delete'), + // Given a file ID, determine the entity+table it's attached to. 'SELECT if(cf.id,1,0) as is_valid, cef.entity_table, cef.entity_id FROM civicrm_file cf LEFT JOIN civicrm_entity_file cef ON cf.id = cef.file_id diff --git a/api/v3/Attachment.php b/api/v3/Attachment.php index 258c4525d2..5bc789282b 100644 --- a/api/v3/Attachment.php +++ b/api/v3/Attachment.php @@ -103,6 +103,7 @@ function _civicrm_api3_attachment_create_spec(&$spec) { * @return array * Array of newly created file property values. * @throws API_Exception validation errors + * @see Civi\API\Subscriber\DynamicFKAuthorization */ function civicrm_api3_attachment_create($params) { diff --git a/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php b/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php index 355193688c..c6ca9ea4e2 100644 --- a/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php +++ b/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php @@ -77,6 +77,7 @@ class DynamicFKAuthorizationTest extends \CiviUnitTestCase { $this->kernel, 'FakeFile', array('create', 'get'), + // Given a file ID, determine the entity+table it's attached to. "select case %1 when " . self::FILE_WIDGET_ID . " then 1