upload_caches_controller_policy.rb 602 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Controllers::UploadCachesControllerPolicy < Controllers::ApplicationControllerPolicy
  3. def update?
  4. permission?
  5. end
  6. def destroy?
  7. permission?
  8. end
  9. def remove_item?
  10. permission?(record.params[:store_id])
  11. end
  12. private
  13. def permission?(attachment_id = nil)
  14. attachments = UploadCache.new(record.params[:id]).attachments
  15. return true if attachments.blank?
  16. attachment = attachment_id ? attachments.find(attachment_id) : attachments.first
  17. attachment.created_by_id == user.id
  18. end
  19. end