scope.rb 563 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class MacroPolicy < ApplicationPolicy
  3. class Scope < ApplicationPolicy::Scope
  4. def resolve(include_admin: true)
  5. if include_admin && user.permissions?('admin.macro')
  6. scope.all
  7. elsif user.permissions?('ticket.agent')
  8. agent_macros
  9. else
  10. scope.none
  11. end
  12. end
  13. private
  14. def agent_macros
  15. accessible_group_ids = user.group_ids_access(%i[change create])
  16. scope.available_in_groups accessible_group_ids
  17. end
  18. end
  19. end