Pass contactId to hook_civicrm_permission_check
authorColeman Watts <coleman@civicrm.org>
Thu, 26 Jul 2018 21:01:34 +0000 (17:01 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 26 Jul 2018 21:20:34 +0000 (17:20 -0400)
CRM/Core/Permission.php
CRM/Utils/Hook.php

index bd73266fca7a56faedc806d5cae823addfa1076f..49d003dd62c4ddddd00f70c8bdf1862b210629f7 100644 (file)
@@ -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))
index 81b322cb5e9aacfc21e233d887ee9d04c02d2ea8..92989a902534cb7c4a605b9482377d6cb7a95cf8 100644 (file)
@@ -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'
     );
   }