return $values;
}
+ /**
+ * @inheritDoc
+ */
+ public function addSelectWhereClause() {
+ $clauses = parent::addSelectWhereClause();
+ if (!CRM_Core_Permission::check('view all activities')) {
+ $permittedActivityTypeIDs = self::getPermittedActivityTypes();
+ if (empty($permittedActivityTypeIDs)) {
+ // This just prevents a mysql fail if they have no access - should be extremely edge case.
+ $permittedActivityTypeIDs = [0];
+ }
+ $clauses['activity_type_id'] = ('IN (' . implode(', ', $permittedActivityTypeIDs) . ')');
+ }
+ return $clauses;
+ }
+
/**
* Get an array of components that are accessible by the currenct user.
*
}
if (!self::hasPermissionForActivityType($activity->activity_type_id)) {
+ // this check is redundant for api access / anything that calls the selectWhereClause
+ // to determine ACLs.
return FALSE;
}
// Return early when it is case activity.
*
* @return array
*/
- public static function getPermittedActivityTypes() {
+ protected static function getPermittedActivityTypes() {
$userID = (int) CRM_Core_Session::getLoggedInContactID();
if (!isset(Civi::$statics[__CLASS__]['permitted_activity_types'][$userID])) {
$permittedActivityTypes = [];
INNER JOIN civicrm_option_group grp ON (grp.id = option_group_id AND grp.name = 'activity_type')
WHERE component_id IS NULL $componentClause")->fetchAll();
foreach ($types as $type) {
- $permittedActivityTypes[$type['activity_type_id']] = $type['activity_type_id'];
+ $permittedActivityTypes[$type['activity_type_id']] = (int) $type['activity_type_id'];
}
Civi::$statics[__CLASS__]['permitted_activity_types'][$userID] = $permittedActivityTypes;
}
$this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookAllResults'));
$this->setPermissions(['access CiviCRM', 'access CiviContribute']);
$this->callAPISuccessGetSingle('Activity', ['check_permissions' => 1, 'id' => ['IN' => [$activity['id'], $activity2['id']]]]);
+ $this->callAPISuccessGetCount('Activity', ['check_permissions' => 1, 'id' => ['IN' => [$activity['id'], $activity2['id']]]], 1);
+
}
/**
$this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookAllResults'));
$this->setPermissions(['access CiviCRM', 'access CiviContribute', 'access all cases and activities']);
$this->callAPISuccessGetSingle('Activity', ['check_permissions' => 1, 'id' => ['IN' => [$activity['id'], $activity2['id']]]]);
+ $this->callAPISuccessGetCount('Activity', ['check_permissions' => 1, 'id' => ['IN' => [$activity['id'], $activity2['id']]]], 1);
}
/**