コード例 #1
0
  public static boolean contains(
      PermissionChecker permissionChecker, ShoppingCategory category, String actionId)
      throws PortalException {

    if (actionId.equals(ActionKeys.ADD_CATEGORY)) {
      actionId = ActionKeys.ADD_SUBCATEGORY;
    }

    if (actionId.equals(ActionKeys.VIEW) && PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {

      long categoryId = category.getCategoryId();

      while (categoryId != ShoppingCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

        category = ShoppingCategoryLocalServiceUtil.getCategory(categoryId);

        if (!_hasPermission(permissionChecker, category, actionId)) {
          return false;
        }

        categoryId = category.getParentCategoryId();
      }

      return ShoppingPermission.contains(permissionChecker, category.getGroupId(), actionId);
    }

    return _hasPermission(permissionChecker, category, actionId);
  }
コード例 #2
0
  public static boolean contains(
      PermissionChecker permissionChecker, long groupId, long categoryId, String actionId)
      throws PortalException {

    if (categoryId == ShoppingCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

      return ShoppingPermission.contains(permissionChecker, groupId, actionId);
    } else {
      ShoppingCategory category = ShoppingCategoryLocalServiceUtil.getCategory(categoryId);

      return contains(permissionChecker, category, actionId);
    }
  }