time_accounting_policy.rb 500 B

123456789101112131415161718192021
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Ticket::TimeAccountingPolicy < ApplicationPolicy
  3. def create?
  4. if !Setting.get 'time_accounting'
  5. return not_authorized __('Time Accounting is not enabled')
  6. end
  7. ticket_create_access? || ticket_update_access?
  8. end
  9. private
  10. def ticket_create_access?
  11. TicketPolicy.new(user, record.ticket).create?
  12. end
  13. def ticket_update_access?
  14. TicketPolicy.new(user, record.ticket).update?
  15. end
  16. end