From: eileen Date: Wed, 24 Oct 2018 02:36:51 +0000 (+1300) Subject: Simplify handling for case checking. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=11b18d9da696922158ed08799706a806828dd823;p=civicrm-core.git 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 --- diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 34996dfe27..423b86a7dd 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -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; }