A configurable option to inform the user about notifications recipients added

This commit is contained in:
Karel Picman 2014-03-14 08:04:46 +01:00
parent 57d16928cb
commit 2662c1f9ac
16 changed files with 124 additions and 19 deletions

View File

@ -117,9 +117,17 @@ class DmsfFilesController < ApplicationController
flash[:notice] = (flash[:notice].nil? ? '' : flash[:notice]) + l(:notice_file_revision_created)
log_activity('new revision')
begin
DmsfMailer.get_notify_users(User.current, [@file]).each do |u|
begin
recipients = DmsfMailer.get_notify_users(User.current, [@file])
recipients.each do |u|
DmsfMailer.files_updated(u, @project, [@file]).deliver
end
if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1'
unless recipients.empty?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
flash[:warning] = l(:warning_email_notifications, :to => to)
end
end
rescue Exception => e
logger.error "Could not send email notifications: #{e.message}"

View File

@ -174,8 +174,16 @@ class DmsfUploadController < ApplicationController
unless files.empty?
files.each { |file| log_activity(file, 'uploaded') if file }
begin
DmsfMailer.get_notify_users(User.current, files).each do |u|
recipients = DmsfMailer.get_notify_users(User.current, files)
recipients.each do |u|
DmsfMailer.files_updated(u, @project, files).deliver
end
if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1'
unless recipients.empty?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
flash[:warning] = l(:warning_email_notifications, :to => to)
end
end
rescue Exception => e
Rails.logger.error "Could not send email notifications: #{e.message}"

View File

@ -67,6 +67,14 @@ class DmsfWorkflowsController < ApplicationController
l(:text_email_finished_approved, :name => @dmsf_workflow.name, :filename => revision.file.name),
l(:text_email_to_see_history)).deliver if member.user
end
if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1'
recipients = revision.file.project.members.collect{ |m| m.user }
unless recipients.empty?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
flash[:warning] = l(:warning_email_notifications, :to => to)
end
end
else
# Just rejected
recipients = @dmsf_workflow.participiants
@ -80,18 +88,30 @@ class DmsfWorkflowsController < ApplicationController
l(:text_email_finished_rejected, :name => @dmsf_workflow.name, :filename => revision.file.name, :notice => action.note),
l(:text_email_to_see_history)).deliver if user
end
if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1'
unless recipients.empty?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
flash[:warning] = l(:warning_email_notifications, :to => to)
end
end
end
else
if action.action == DmsfWorkflowStepAction::ACTION_DELEGATE
# Delegation
delegate = User.find_by_id params[:step_action].to_i / 10
DmsfMailer.workflow_notification(
delegate,
@dmsf_workflow,
revision,
l(:text_email_subject_delegated, :name => @dmsf_workflow.name),
l(:text_email_finished_delegated, :name => @dmsf_workflow.name, :filename => revision.file.name, :notice => action.note),
l(:text_email_to_proceed)).deliver if delegate
delegate = User.find_by_id params[:step_action].to_i / 10
if delegate
DmsfMailer.workflow_notification(
delegate,
@dmsf_workflow,
revision,
l(:text_email_subject_delegated, :name => @dmsf_workflow.name),
l(:text_email_finished_delegated, :name => @dmsf_workflow.name, :filename => revision.file.name, :notice => action.note),
l(:text_email_to_proceed)).deliver
if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1'
flash[:warning] = l(:warning_email_notifications, :to => delegate.name)
end
end
else
# Next step
assignments = @dmsf_workflow.next_assignments revision.id
@ -115,7 +135,16 @@ class DmsfWorkflowsController < ApplicationController
l(:text_email_subject_updated, :name => @dmsf_workflow.name),
l(:text_email_finished_step_short, :name => @dmsf_workflow.name, :filename => revision.file.name),
l(:text_email_to_see_status)).deliver if to
end
if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1'
recipients = assignments.collect{ |a| a.user }
recipients << to if to && !recipients.include?(to)
unless recipients.empty?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
flash[:warning] = l(:warning_email_notifications, :to => to)
end
end
end
end
end
end
@ -283,6 +312,14 @@ class DmsfWorkflowsController < ApplicationController
l(:text_email_started, :name => @dmsf_workflow.name, :filename => revision.file.name),
l(:text_email_to_proceed)).deliver if assignment.user
end
if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1'
recipients = assignments.collect { |a| a.user }
unless recipients.empty?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
flash[:warning] = l(:warning_email_notifications, :to => to)
end
end
flash[:notice] = l(:notice_workflow_started)
else
flash[:error] = l(:notice_cannot_start_workflow)

View File

@ -110,7 +110,7 @@ class DmsfWorkflow < ActiveRecord::Base
sql = '1=1'
end
unless q.nil? || q.empty?
if q.present?
User.active.sorted.where(sql).like(q)
else
User.active.sorted.where(sql)

View File

@ -1,7 +1,8 @@
<%# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright (C) 2011-14 Karel Picman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -93,6 +94,18 @@
(<%= l(:label_default) %>: <%= l(:select_option_deactivated) %>)
</p>
<p>
<%= content_tag(:label, "#{l(:label_display_notified_recipients)}:") %>
<%= select_tag('settings[dmsf_display_notified_recipients]',
options_for_select([
[l(:select_option_deactivated), nil],
[l(:select_option_activated), '1']],
:selected => @settings['dmsf_display_notified_recipients'])) %><br/>
(<%= l(:label_default) %>: <%= l(:select_option_deactivated) %>)
<br/>
<%= l(:note_display_notified_recipients).html_safe %>
</p>
<hr />
<p>

View File

@ -294,6 +294,10 @@ cs:
text_email_doc_deleted_subject: "Dokumenty projektu %{project} smazány"
text_email_doc_deleted: právě smazal dokumety projektu
label_links_only: pouze odkazy
label_display_notified_recipients: Zobrazit příjemce notifikací
note_display_notified_recipients: Uživatel bude informován o příjemcích právě odeslané emailové notifikace.
warning_email_notifications: "Notifikační email poslán na uživatele %{to}"
my:
blocks:

View File

@ -295,6 +295,10 @@ de:
text_email_doc_deleted: has just deleted documents of
label_links_only: links only
label_display_notified_recipients: Display notified recipients
note_display_notified_recipients: The user will be informed about all recipients of just sent the email notification.
warning_email_notifications: "Email notifications sent to %{to}"
my:
blocks:
locked_documents: Locked documents

View File

@ -295,6 +295,10 @@ en:
text_email_doc_deleted: has just deleted documents of
label_links_only: links only
label_display_notified_recipients: Display notified recipients
note_display_notified_recipients: The user will be informed about all recipients of just sent the email notification.
warning_email_notifications: "Email notifications sent to %{to}"
my:
blocks:
locked_documents: Locked documents

View File

@ -295,6 +295,10 @@ es:
text_email_doc_deleted: has just deleted documents of
label_links_only: links only
label_display_notified_recipients: Display notified recipients
note_display_notified_recipients: The user will be informed about all recipients of just sent the email notification.
warning_email_notifications: "Email notifications sent to %{to}"
my:
blocks:
locked_documents: Locked documents

View File

@ -294,6 +294,10 @@ fr:
text_email_doc_deleted_subject: "Documents of %{project} deleted"
text_email_doc_deleted: has just deleted documents of
label_links_only: links only
label_display_notified_recipients: Display notified recipients
note_display_notified_recipients: The user will be informed about all recipients of just sent the email notification.
warning_email_notifications: "Email notifications sent to %{to}"
my:
blocks:

View File

@ -295,6 +295,10 @@ ja:
text_email_doc_deleted: has just deleted documents of
label_links_only: links only
label_display_notified_recipients: Display notified recipients
note_display_notified_recipients: The user will be informed about all recipients of just sent the email notification.
warning_email_notifications: "Email notifications sent to %{to}"
my:
blocks:
locked_documents: Locked documents

View File

@ -295,6 +295,10 @@ ru:
text_email_doc_deleted: has just deleted documents of
label_links_only: links only
label_display_notified_recipients: Display notified recipients
note_display_notified_recipients: The user will be informed about all recipients of just sent the email notification.
warning_email_notifications: "Email notifications sent to %{to}"
my:
blocks:
locked_documents: Locked documents

View File

@ -295,6 +295,10 @@ sl:
text_email_doc_deleted: has just deleted documents of
label_links_only: links only
label_display_notified_recipients: Display notified recipients
note_display_notified_recipients: The user will be informed about all recipients of just sent the email notification.
warning_email_notifications: "Email notifications sent to %{to}"
my:
blocks:
locked_documents: Locked documents

View File

@ -295,6 +295,10 @@ zh:
text_email_doc_deleted: has just deleted documents of
label_links_only: links only
label_display_notified_recipients: Display notified recipients
note_display_notified_recipients: The user will be informed about all recipients of just sent the email notification.
warning_email_notifications: "Email notifications sent to %{to}"
my:
blocks:
locked_documents: Locked documents

View File

@ -1,8 +1,8 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright (C) 2014 Karel Picman <karel.picman@kontron.com>
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright (C) 2011-14 Karel Picman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -42,7 +42,8 @@ Redmine::Plugin.register :redmine_dmsf do
'dmsf_index_database' => Rails.root.join('files/dmsf_index').to_s,
'dmsf_stemming_lang' => 'english',
'dmsf_stemming_strategy' => 'STEM_NONE',
'dmsf_webdav' => '1'
'dmsf_webdav' => '1',
'dmsf_display_notified_recipients' => 0
}
menu :project_menu, :dmsf, { :controller => 'dmsf', :action => 'show' }, :caption => :menu_dmsf, :before => :documents, :param => :id

View File

@ -18,6 +18,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
DMSF_MAX_NOTIFICATION_RECEIVERS_INFO = 10
# Vendor
require 'redmine_dmsf/vendored_dav4rack'