public static function getPermissionClause($force = FALSE) {
static $clause = 1;
static $retrieved = FALSE;
- if ((!$retrieved || $force) && !CRM_Core_Permission::check('view all contacts') && !CRM_Core_Permission::check('edit all contacts')) {
- //get the allowed groups for the current user
- $groups = CRM_ACL_API::group(CRM_ACL_API::VIEW);
- if (!empty($groups)) {
- $groupList = implode(', ', array_values($groups));
- $clause = "groups.id IN ( $groupList ) ";
+ if (!$retrieved || $force) {
+ if (CRM_Core_Permission::check('view all contacts') || CRM_Core_Permission::check('edit all contacts')) {
+ $clause = 1;
}
else {
- $clause = '1 = 0';
+ //get the allowed groups for the current user
+ $groups = CRM_ACL_API::group(CRM_ACL_API::VIEW);
+ if (!empty($groups)) {
+ $groupList = implode(', ', array_values($groups));
+ $clause = "groups.id IN ( $groupList ) ";
+ }
+ else {
+ $clause = '1 = 0';
+ }
}
}
$retrieved = TRUE;