Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 3b174de

Browse files
committed
do not use new categoryAccess Api methods because category values are not instances AbstractCategoryAssignment, so revert old method to use old tech.
1 parent fb2cfe1 commit 3b174de

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/lib/legacy/util/CategoryUtil.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,31 @@ public static function rebuildPaths($pathField = 'path', $sourceField = 'name',
687687
public static function hasCategoryAccess($categories, $module, $permLevel = ACCESS_OVERVIEW)
688688
{
689689
@trigger_error('CategoryUtil is deprecated. please use the new category permission api instead.', E_USER_DEPRECATED);
690-
691-
return ServiceUtil::get('zikula_categories_module.api.category_permission')->hasCategoryAccess($categories, $permLevel);
690+
// Always allow access to content with no categories associated
691+
if (count($categories) == 0) {
692+
return true;
693+
}
694+
695+
// Check if access is required for all categories or for at least one category
696+
$requireAccessForAll = \ModUtil::getVar('ZikulaCategoriesModule', 'permissionsall', 0);
697+
698+
$accessGranted = true;
699+
foreach ($categories as $propertyName => $cats) {
700+
$categoriesForProperty = is_array($cats) ? $cats : [$cats];
701+
foreach ($categoriesForProperty as $cat) {
702+
$hasAccess = \SecurityUtil::checkPermission("ZikulaCategoriesModule:$propertyName:Category", "$cat[id]:$cat[path]:$cat[ipath]", $permLevel);
703+
if ($requireAccessForAll && !$hasAccess) {
704+
return false;
705+
}
706+
if (!$requireAccessForAll) {
707+
if ($hasAccess) {
708+
return true;
709+
}
710+
$accessGranted = false;
711+
}
712+
}
713+
}
714+
715+
return $accessGranted;
692716
}
693717
}

0 commit comments

Comments
 (0)