3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Trait shared with entities attached to the contact record.
21 trait CRM_Contact_AccessTrait
{
24 * @param string $action
25 * @param array $record
26 * @param int|NULL $userID
28 * @see CRM_Core_DAO::checkAccess
30 public static function _checkAccess(string $action, array $record, $userID) {
31 $cid = $record['contact_id'] ??
NULL;
32 if (!$cid && !empty($record['id'])) {
33 $cid = CRM_Core_DAO
::getFieldValue(__CLASS__
, $record['id'], 'contact_id');
36 // With no contact id this must be part of an event locblock
37 return in_array(__CLASS__
, ['CRM_Core_BAO_Phone', 'CRM_Core_BAO_Email', 'CRM_Core_BAO_Address']) &&
38 CRM_Core_Permission
::check('edit all events', $userID);
40 return CRM_Contact_BAO_Contact
::checkAccess($action, ['id' => $cid], $userID);