Commit 11b18d9d authored by eileen's avatar eileen

Simplify handling for case checking.

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
parent 0e35e2aa
......@@ -2693,17 +2693,15 @@ AND cl.modified_id = c.id
return FALSE;
}
if (!self::hasPermissionForActivityType($activity->activity_type_id)) {
return FALSE;
}
// Return early when it is case activity.
// Check for CiviCase related permission.
if (CRM_Case_BAO_Case::isCaseActivity($activityId)) {
return self::isContactPermittedAccessToCaseActivity($activityId, $action, $activity->activity_type_id);
}
// Component related permissions.
if (!self::hasPermissionForActivityType($activity->activity_type_id)) {
return FALSE;
}
// Check for this permission related to contact.
$permission = CRM_Core_Permission::VIEW;
if ($action == CRM_Core_Action::UPDATE) {
......@@ -2768,25 +2766,14 @@ AND cl.modified_id = c.id
* @return bool
*/
protected static function isContactPermittedAccessToCaseActivity($activityId, $action, $activityTypeID) {
$allow = FALSE;
foreach (['access my cases and activities', 'access all cases and activities'] as $per) {
if (CRM_Core_Permission::check($per)) {
$allow = TRUE;
break;
}
}
// Check for case specific permissions.
if ($allow) {
$oper = 'view';
if ($action == CRM_Core_Action::UPDATE) {
$oper = 'edit';
}
$allow = CRM_Case_BAO_Case::checkPermission($activityId,
$oper,
$activityTypeID
);
$oper = 'view';
if ($action == CRM_Core_Action::UPDATE) {
$oper = 'edit';
}
$allow = CRM_Case_BAO_Case::checkPermission($activityId,
$oper,
$activityTypeID
);
return $allow;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment