4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
12 namespace Civi\Api4\Event
;
14 use Civi\API\Event\AuthorizedTrait
;
15 use Civi\API\Event\RequestTrait
;
16 use Civi\Core\Event\GenericHookEvent
;
19 * Determine if the a user has access to a given record.
21 * Event name: 'civi.api4.authorizeRecord'
23 class AuthorizeRecordEvent
extends GenericHookEvent
{
30 * All (known/loaded) values of individual record being accessed.
31 * The record should provide an 'id' but may otherwise be incomplete; guard accordingly.
38 * CheckAccessEvent constructor.
40 * @param \Civi\Api4\Generic\AbstractAction $apiRequest
41 * @param array $record
42 * All (known/loaded) values of individual record being accessed.
43 * The record should provide an 'id' but may otherwise be incomplete; guard accordingly.
45 * Contact ID of the active/target user (whose access we must check).
48 public function __construct($apiRequest, array $record, int $userID) {
49 $this->setApiRequest($apiRequest);
50 $this->record
= $record;
51 $this->setUser($userID);
57 public function getHookValues() {
58 return [$this->getApiRequest(), $this->record
, &$this->authorized
];
64 public function getRecord(): array {