channel_policy.rb 448 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ChannelPolicy < ApplicationPolicy
  3. def create?
  4. access?
  5. end
  6. def destroy?
  7. access?
  8. end
  9. def update?
  10. access?
  11. end
  12. def show?
  13. access?
  14. end
  15. private
  16. def permission_name
  17. area_provider = record.area.split('::').first.downcase
  18. "admin.channel_#{area_provider}"
  19. end
  20. def access?
  21. user.permissions?(permission_name)
  22. end
  23. end