From: Coleman Watts Date: Thu, 26 Jul 2018 21:01:34 +0000 (-0400) Subject: Pass contactId to hook_civicrm_permission_check X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fa4dac9c1d834f7e49e835bfe96d9391b3315c42;p=civicrm-core.git Pass contactId to hook_civicrm_permission_check --- diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index bd73266fca..49d003dd62 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -144,7 +144,7 @@ class CRM_Core_Permission { // This is an individual permission $granted = CRM_Core_Config::singleton()->userPermissionClass->check($permission, $userId); // Call the permission_check hook to permit dynamic escalation (CRM-19256) - CRM_Utils_Hook::permission_check($permission, $granted); + CRM_Utils_Hook::permission_check($permission, $granted, $contactId); if ( !$granted && !($tempPerm && $tempPerm->check($permission)) diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 81b322cb5e..92989a9025 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -1820,13 +1820,15 @@ abstract class CRM_Utils_Hook { * The name of an atomic permission, ie. 'access deleted contacts' * @param bool $granted * Whether this permission is currently granted. The hook can change this value. + * @param int $contactId + * Contact whose permissions we are checking (if null, assume current user). * * @return null * The return value is ignored */ - public static function permission_check($permission, &$granted) { - return self::singleton()->invoke(array('permission', 'granted'), $permission, $granted, - self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, + public static function permission_check($permission, &$granted, $contactId) { + return self::singleton()->invoke(array('permission', 'granted', 'contactId'), $permission, $granted, $contactId, + self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_permission_check' ); }