Skip to content

Commit

Permalink
LPD-2249 portal-search: If groupIds list is empty, check resourcePerm…
Browse files Browse the repository at this point in the history
…ission for all available groups

https://liferay.atlassian.net/browse/LPD-2249
  • Loading branch information
AlmirFe authored and brianchandotcom committed May 14, 2024
1 parent 0d79f97 commit 4a25d76
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.liferay.portal.kernel.security.permission.PermissionCheckerFactory;
import com.liferay.portal.kernel.security.permission.PermissionThreadLocal;
import com.liferay.portal.kernel.security.permission.UserBag;
import com.liferay.portal.kernel.service.GroupLocalService;
import com.liferay.portal.kernel.service.ResourcePermissionLocalService;
import com.liferay.portal.kernel.service.RoleLocalService;
import com.liferay.portal.kernel.service.UserLocalService;
Expand Down Expand Up @@ -519,16 +520,18 @@ private BooleanFilter _getPermissionFilter(
}
}

if (ArrayUtil.isNotEmpty(groupIds)) {
for (long searchGroupId : groupIds) {
if (!searchPermissionContext.containsGroupId(searchGroupId) &&
_resourcePermissionLocalService.hasResourcePermission(
companyId, className, ResourceConstants.SCOPE_GROUP,
String.valueOf(searchGroupId), roleIds,
ActionKeys.VIEW)) {
if (ArrayUtil.isEmpty(groupIds)) {
groupIds = ArrayUtil.toLongArray(
_groupLocalService.getGroupIds(companyId, true));
}

groupsTermsFilter.addValue(String.valueOf(searchGroupId));
}
for (long searchGroupId : groupIds) {
if (!searchPermissionContext.containsGroupId(searchGroupId) &&
_resourcePermissionLocalService.hasResourcePermission(
companyId, className, ResourceConstants.SCOPE_GROUP,
String.valueOf(searchGroupId), roleIds, ActionKeys.VIEW)) {

groupsTermsFilter.addValue(String.valueOf(searchGroupId));
}
}

Expand Down Expand Up @@ -564,6 +567,9 @@ private String _getPermissionName(
private static final Log _log = LogFactoryUtil.getLog(
SearchPermissionCheckerImpl.class);

@Reference
private GroupLocalService _groupLocalService;

@Reference
private IndexerRegistry _indexerRegistry;

Expand Down

0 comments on commit 4a25d76

Please sign in to comment.