checklist_template_policy.rb 588 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ChecklistTemplatePolicy < ApplicationPolicy
  3. def show?
  4. checklist_feature_enabled? && (agent? || admin?)
  5. end
  6. def create?
  7. checklist_feature_enabled? && admin?
  8. end
  9. def update?
  10. checklist_feature_enabled? && admin?
  11. end
  12. def destroy?
  13. checklist_feature_enabled? && admin?
  14. end
  15. private
  16. def checklist_feature_enabled?
  17. Setting.get('checklist')
  18. end
  19. def agent?
  20. user.permissions?('ticket.agent')
  21. end
  22. def admin?
  23. user.permissions?('admin.checklist')
  24. end
  25. end