notifications.rb 701 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class FormUpdater::Updater::User::Notifications < FormUpdater::Updater
  3. def authorized?
  4. current_user.permissions?('user_preferences.notifications')
  5. end
  6. def object_type
  7. ::User
  8. end
  9. def resolve
  10. if meta[:initial]
  11. prepare_initial_data
  12. end
  13. super
  14. end
  15. private
  16. def prepare_initial_data
  17. result['group_ids'] = initial_group_ids
  18. end
  19. def initial_group_ids
  20. {
  21. options: initial_group_options
  22. }
  23. end
  24. def initial_group_options
  25. FormUpdater::Relation::Group.new(
  26. context:,
  27. current_user:,
  28. filter_ids: current_user.group_ids
  29. ).options
  30. end
  31. end