Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-19256 4.6 #8915

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion CRM/Core/Permission.php
Expand Up @@ -134,8 +134,12 @@ public static function check($permissions) {
return FALSE;
}
else {
// This is an individual permission
$granted = CRM_Core_Config::singleton()->userPermissionClass->check($permission);
// Call the permission_check hook to permit dynamic escalation (CRM-19256)
CRM_Utils_Hook::permission_check($permission, $granted);
if (
!CRM_Core_Config::singleton()->userPermissionClass->check($permission)
!$granted
&& !($tempPerm && $tempPerm->check($permission))
) {
//one of our 'and' conditions has not been met
Expand Down
19 changes: 19 additions & 0 deletions CRM/Utils/Hook.php
Expand Up @@ -1630,6 +1630,25 @@ public static function permission(&$permissions) {
);
}

/**
* This hook is called when checking permissions; use this hook to dynamically
* escalate user permissions in certain use cases (cf. CRM-19256).
*
* @param string $permission
* 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.
*
* @return null
* The return value is ignored
*/
public static function permission_check($permission, &$granted) {
return self::singleton()->invoke(2, $permission, $granted,
self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
'civicrm_permission_check'
);
}

/**
* @param CRM_Core_Exception Exception $exception
* @param mixed $request
Expand Down