ticket.rb 976 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ObjectManager::Element::Ticket < ObjectManager::Element::Backend
  3. private
  4. def authorized?(permission)
  5. return true if skip_permission
  6. return false if skip?(permission)
  7. super
  8. end
  9. def skip?(permission)
  10. return true if agent_in_general_view?(permission)
  11. return true if agent_access_missing?(permission)
  12. authorized_customer_and_agent?(permission)
  13. end
  14. def agent_in_general_view?(permission)
  15. record.blank? && permission == 'ticket.customer' && agent?
  16. end
  17. def agent_access_missing?(permission)
  18. record.present? && permission == 'ticket.agent' && agent? && !read_access?
  19. end
  20. def authorized_customer_and_agent?(permission)
  21. record.present? && permission == 'ticket.customer' && agent? && read_access?
  22. end
  23. def agent?
  24. user.permissions?('ticket.agent')
  25. end
  26. def read_access?
  27. user.group_access?(record.group_id, 'read')
  28. end
  29. end