checklist_items_controller_policy.rb 714 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Controllers::ChecklistItemsControllerPolicy < Controllers::ApplicationControllerPolicy
  3. def create?
  4. update_access_via_ticket?
  5. end
  6. def update?
  7. update_access_via_ticket?
  8. end
  9. def destroy?
  10. update_access_via_ticket?
  11. end
  12. private
  13. def ticket_policy
  14. ticket = Checklist.lookup(id: record.params[:checklist_id])&.ticket || Checklist::Item.lookup(id: record.params[:id])&.checklist&.ticket
  15. @ticket_policy ||= TicketPolicy.new(user, ticket)
  16. end
  17. def update_access_via_ticket?
  18. user.permissions?(['ticket.agent']) && ticket_policy.agent_update_access?
  19. end
  20. default_permit!(['ticket.agent'])
  21. end