diff --git a/app/controllers/dmsf_context_menus_controller.rb b/app/controllers/dmsf_context_menus_controller.rb index 72d33bed..fe923a85 100644 --- a/app/controllers/dmsf_context_menus_controller.rb +++ b/app/controllers/dmsf_context_menus_controller.rb @@ -57,6 +57,7 @@ class DmsfContextMenusController < ApplicationController User.current.allowed_to?(:folder_manipulation, @project) @email_allowed = User.current.allowed_to?(:email_documents, @project) end + @notifications = Setting.notified_events.include?('dmsf_legacy_notifications') @back_url = dmsf_folder_path(id: @project, folder_id: @folder) render layout: false rescue ActiveRecord::RecordNotFound diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index ed90e598..d0811a46 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -80,6 +80,7 @@ class DmsfController < ApplicationController @folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project) @file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project) @trash_enabled = @folder_manipulation_allowed && @file_manipulation_allowed + @notifications = Setting.notified_events.include?('dmsf_legacy_notifications') @query.dmsf_folder_id = @folder ? @folder.id : nil @query.deleted = false @query.sub_projects |= Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders'].present? diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index b9881510..85a57131 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -85,6 +85,7 @@ class DmsfFilesController < ApplicationController @file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project) @revision_count = @file.dmsf_file_revisions.visible.all.size @revision_pages = Paginator.new @revision_count, params['per_page'] ? params['per_page'].to_i : 25, params['page'] + @notifications = Setting.notified_events.include?('dmsf_legacy_notifications') respond_to do |format| format.html { diff --git a/app/views/dmsf/_main.html.erb b/app/views/dmsf/_main.html.erb index 32e03d4c..dde8d48b 100644 --- a/app/views/dmsf/_main.html.erb +++ b/app/views/dmsf/_main.html.erb @@ -42,7 +42,8 @@ project: @project, locked_for_user: @locked_for_user, file_manipulation_allowed: @file_manipulation_allowed, - trash_enabled: @trash_enabled } %> + trash_enabled: @trash_enabled, + notifications: @notifications } %> <% else %> <%= actions_dropdown do %> <%= render partial: 'dmsf_context_menus/main', locals: { @@ -52,7 +53,8 @@ project: @project, locked_for_user: @locked_for_user, file_manipulation_allowed: @file_manipulation_allowed, - trash_enabled: @trash_enabled } %> + trash_enabled: @trash_enabled, + notifications: @notifications} %> <% end %> <% end %> diff --git a/app/views/dmsf_context_menus/_file.html.erb b/app/views/dmsf_context_menus/_file.html.erb index b73f28fe..46e55a86 100644 --- a/app/views/dmsf_context_menus/_file.html.erb +++ b/app/views/dmsf_context_menus/_file.html.erb @@ -46,15 +46,17 @@ class: 'icon icon-lock', disabled: !allowed %> <% end %> -
  • - <% if dmsf_file.notification %> - <%= context_menu_link l(:label_notifications_off), notify_deactivate_dmsf_files_path(id: dmsf_file, - back_url: back_url), class: 'icon icon-email', disabled: !allowed || locked %> - <% else %> - <%= context_menu_link l(:label_notifications_on), notify_activate_dmsf_files_path(id: dmsf_file, - back_url: back_url), class: 'icon icon-email-add', disabled: !allowed || locked %> - <% end %> -
  • +<% if notifications %> +
  • + <% if dmsf_file.notification %> + <%= context_menu_link l(:label_notifications_off), notify_deactivate_dmsf_files_path(id: dmsf_file, + back_url: back_url), class: 'icon icon-email', disabled: !allowed || locked %> + <% else %> + <%= context_menu_link l(:label_notifications_on), notify_activate_dmsf_files_path(id: dmsf_file, + back_url: back_url), class: 'icon icon-email-add', disabled: !allowed || locked %> + <% end %> +
  • +<% end %>
  • <%= render partial: 'approval_workflow', locals: { dmsf_file: dmsf_file, project: project, locked: locked, back_url: back_url } %> diff --git a/app/views/dmsf_context_menus/_folder.html.erb b/app/views/dmsf_context_menus/_folder.html.erb index 9325a2a7..43873cbc 100644 --- a/app/views/dmsf_context_menus/_folder.html.erb +++ b/app/views/dmsf_context_menus/_folder.html.erb @@ -49,17 +49,19 @@ <% end %>
  • <% end %> -
  • - <% if dmsf_folder.notification %> - <%= context_menu_link l(:label_notifications_off), notify_deactivate_dmsf_path(id: dmsf_folder.project, - folder_id: dmsf_folder, back_url: back_url), class: 'icon icon-email', - disabled: !allowed || locked || !dmsf_folder.notification? %> - <% else %> - <%= context_menu_link l(:label_notifications_on), notify_activate_dmsf_path(id: dmsf_folder.project, - folder_id: dmsf_folder, back_url: back_url), class: 'icon icon-email-add', - disabled: !allowed || locked || dmsf_folder.notification? %> - <% end %> -
  • +<% if notifications %> +
  • + <% if dmsf_folder.notification %> + <%= context_menu_link l(:label_notifications_off), notify_deactivate_dmsf_path(id: dmsf_folder.project, + folder_id: dmsf_folder, back_url: back_url), class: 'icon icon-email', + disabled: !allowed || locked || !dmsf_folder.notification? %> + <% else %> + <%= context_menu_link l(:label_notifications_on), notify_activate_dmsf_path(id: dmsf_folder.project, + folder_id: dmsf_folder, back_url: back_url), class: 'icon icon-email-add', + disabled: !allowed || locked || dmsf_folder.notification? %> + <% end %> +
  • +<% end %> <% unless edit %>
  • <%= context_menu_link l(:button_download), entries_operations_dmsf_path(id: project, folder_id: folder, diff --git a/app/views/dmsf_context_menus/_main.html.erb b/app/views/dmsf_context_menus/_main.html.erb index 8496a9f0..376ee294 100644 --- a/app/views/dmsf_context_menus/_main.html.erb +++ b/app/views/dmsf_context_menus/_main.html.erb @@ -42,16 +42,18 @@ title: l(:title_lock_folder), class: 'icon icon-lock') %> <% end %> <% end %> - <% if !locked_for_user && ((folder && folder.notification) || (!folder && project.dmsf_notification)) %> - <%= link_to l(:label_notifications_off), - notify_deactivate_dmsf_path(id: project, folder_id: folder), - title: l(:title_notifications_active_deactivate), - class: 'icon icon-email' %> - <% else %> - <%= link_to l(:label_notifications_on), - notify_activate_dmsf_path(id: project, folder_id: folder), - title: l(:title_notifications_not_active_activate), - class: 'icon icon-email-add' %> + <% if notifications %> + <% if !locked_for_user && ((folder && folder.notification) || (!folder && project.dmsf_notification)) %> + <%= link_to l(:label_notifications_off), + notify_deactivate_dmsf_path(id: project, folder_id: folder), + title: l(:title_notifications_active_deactivate), + class: 'icon icon-email' %> + <% else %> + <%= link_to l(:label_notifications_on), + notify_activate_dmsf_path(id: project, folder_id: folder), + title: l(:title_notifications_not_active_activate), + class: 'icon icon-email-add' %> + <% end %> <% end %> <% if file_manipulation_allowed && !locked_for_user %> <%= link_to l(:label_link_from), diff --git a/app/views/dmsf_context_menus/_revisions.html.erb b/app/views/dmsf_context_menus/_revisions.html.erb index f6c728a1..e14043d4 100644 --- a/app/views/dmsf_context_menus/_revisions.html.erb +++ b/app/views/dmsf_context_menus/_revisions.html.erb @@ -20,16 +20,18 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. %> -<% if file.notification %> - <%= link_to l(:label_notifications_off), - notify_deactivate_dmsf_files_path(id: file, back_url: back_url), - title: l(:title_notifications_active_deactivate), - class: 'icon icon-email' %> -<% else %> - <%= link_to l(:label_notifications_on), - notify_activate_dmsf_files_path(id: file, back_url: back_url), - title: l(:title_notifications_not_active_activate), - class: 'icon icon-email-add' %> +<% if notifications %> + <% if file.notification %> + <%= link_to l(:label_notifications_off), + notify_deactivate_dmsf_files_path(id: file, back_url: back_url), + title: l(:title_notifications_active_deactivate), + class: 'icon icon-email' %> + <% else %> + <%= link_to l(:label_notifications_on), + notify_activate_dmsf_files_path(id: file, back_url: back_url), + title: l(:title_notifications_not_active_activate), + class: 'icon icon-email-add' %> + <% end %> <% end %> <%= link_to l(:label_link_to), new_dmsf_link_path(project_id: project.id, dmsf_folder_id: file.dmsf_folder ? file.dmsf_folder.id : nil, diff --git a/app/views/dmsf_context_menus/dmsf.html.erb b/app/views/dmsf_context_menus/dmsf.html.erb index b1e92f3d..9c6eabc0 100644 --- a/app/views/dmsf_context_menus/dmsf.html.erb +++ b/app/views/dmsf_context_menus/dmsf.html.erb @@ -24,12 +24,13 @@ <% if @dmsf_file %> <%= render partial: 'file', locals: { project: @project, folder: @folder, dmsf_file: @dmsf_file, dmsf_link: @dmsf_link, locked: @locked, unlockable: @unlockable, - allowed: @allowed, email_allowed: @email_allowed, back_url: @back_url } %> + allowed: @allowed, email_allowed: @email_allowed, + notifications: @notifications, back_url: @back_url } %> <% elsif @dmsf_folder %> <%= render partial: 'folder', locals: { project: @project, folder: @folder, dmsf_folder: @dmsf_folder, dmsf_link: @dmsf_link, locked: @locked, unlockable: @unlockable, allowed: @allowed, email_allowed: @email_allowed, edit: false, - back_url: @back_url } %> + notifications: @notifications, back_url: @back_url } %> <% elsif @dmsf_link %> <%= render partial: 'url', locals: { dmsf_link: @dmsf_link, allowed: @allowed, back_url: @back_url } %> <% else %> diff --git a/app/views/dmsf_files/show.html.erb b/app/views/dmsf_files/show.html.erb index 767579e1..c6609b00 100644 --- a/app/views/dmsf_files/show.html.erb +++ b/app/views/dmsf_files/show.html.erb @@ -44,12 +44,12 @@ <% if defined?(EasyExtensions) %> <%= render partial: 'dmsf_context_menus/revisions', locals: { project: @project, file: @file, file_delete_allowed: @file_delete_allowed, - back_url: dmsf_file_path(id: @file)} %> + notifications: @notifications, back_url: dmsf_file_path(id: @file)} %> <% else %> <%= actions_dropdown do %> <%= render partial: 'dmsf_context_menus/revisions', locals: { project: @project, file: @file, file_delete_allowed: @file_delete_allowed, - back_url: dmsf_file_path(id: @file) } %> + notifications: @notifications, back_url: dmsf_file_path(id: @file) } %> <% end %> <% end %> <% end %> diff --git a/app/views/dmsf_state/_user_pref.html.erb b/app/views/dmsf_state/_user_pref.html.erb index 51ad1133..41f41a1a 100644 --- a/app/views/dmsf_state/_user_pref.html.erb +++ b/app/views/dmsf_state/_user_pref.html.erb @@ -23,13 +23,15 @@ <% if member %>
    <%= l(:link_user_preferences) %> -

    - <%= content_tag :label, l(:label_notifications) %> - <%= select_tag 'email_notify', - options_for_select([[l(:select_option_default), nil], - [l(:select_option_activated), true], [l(:select_option_deactivated), false]], - selected: member.dmsf_mail_notification) %> -

    + <% if Setting.notified_events.include?('dmsf_legacy_notifications') %> +

    + <%= content_tag :label, l(:label_notifications) %> + <%= select_tag 'email_notify', + options_for_select([[l(:select_option_default), nil], + [l(:select_option_activated), true], [l(:select_option_deactivated), false]], + selected: member.dmsf_mail_notification) %> +

    + <% end %>

    <%= content_tag :label, l(:label_title_format) %> <%= text_field_tag 'title_format', member.dmsf_title_format, size: 10 %>