-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Simplify handling for case checking. #13372
Conversation
We already check if the contact has generic case permissions in the component checking section. We can remove that check from the case check & also early return from there since a NO at that point can't be overriden
(Standard links)
|
@seamuslee001 @colemanw this is a minor follow on for things you have reviewed |
@@ -2768,25 +2766,14 @@ public static function checkPermission($activityId, $action) { | |||
* @return bool | |||
*/ | |||
protected static function isContactPermittedAccessToCaseActivity($activityId, $action, $activityTypeID) { | |||
$allow = FALSE; | |||
foreach (['access my cases and activities', 'access all cases and activities'] as $per) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton is this taken care of in the hasPermissionForActivityType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seamuslee001 yep - it retrieves a list of permissable components & then checks types are associated with them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can see it looks for components
$components = self::activityComponents(FALSE);
which filters with
if ($compObj->info['name'] == 'CiviCase') {
if (CRM_Case_BAO_Case::accessCiviCase()) {
$components[$compObj->componentID] = $compObj->info['name'];
}
}
which calls
/**
* Since we drop 'access CiviCase', allow access
* if user has 'access my cases and activities'
* or 'access all cases and activities'
*/
public static function accessCiviCase() {
if (!self::enabled()) {
return FALSE;
}
if (CRM_Core_Permission::check('access my cases and activities') ||
CRM_Core_Permission::check('access all cases and activities')
) {
return TRUE;
}
return FALSE;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seamuslee001 somewhat ironically I have a follow up that will make this kinda redundant for api calls but this allow() function is still called from a bunch of places. I added testGetActivityCheckPermissionsByCaseComponent as part of this refactoring effort - but it got added in advance of some of these changes so the link isn't obvious
Looks fine to me and with the clarification i'm happy to merge this |
Overview
Minor code simplification
Before
Slightly more expensive method used for civicase checking
After
The hasPermissionForActivityType check is run before the civicase check and an early return is done if the contact does not have permission to 'access my cases and activities', or 'access all cases and activities'
Technical Details
We already check if the contact has generic case permissions in the component checking section, we can do that first & remove it from the case check.
Comments
Test coverage in testGetActivityCheckPermissionsByCaseComponent