##// END OF EJS Templates
mail notifications added when:...
Jean-Philippe Lang -
r193:2d47a6d71c09
parent child
Show More
@@ -0,0 +1,6
1 <%= @added_to %>
2 <%= @attachments.size %> files(s) added.
3 <% @attachments.each do |attachment | %>
4 - <%= attachment.filename %><% end %>
5
6 <%= @url %> No newline at end of file
@@ -0,0 +1,6
1 <%= @added_to %>
2 <%= @attachments.size %> files(s) added.
3 <% @attachments.each do |attachment | %>
4 - <%= attachment.filename %><% end %>
5
6 <%= @url %> No newline at end of file
@@ -0,0 +1,6
1 <%= @added_to %>
2 <%= @attachments.size %> files(s) added.
3 <% @attachments.each do |attachment | %>
4 - <%= attachment.filename %><% end %>
5
6 <%= @url %> No newline at end of file
@@ -0,0 +1,6
1 <%= @added_to %>
2 <%= @attachments.size %> fichier(s) ajouté(s).
3 <% @attachments.each do |attachment | %>
4 - <%= attachment.filename %><% end %>
5
6 <%= @url %> No newline at end of file
@@ -0,0 +1,4
1 A document has been added to <%= @document.project.name %> (<%= @document.category.name %>):
2 <%= l(:field_title) %>: <%= @document.title %>
3
4 http://<%= Setting.host_name %>/documents/show/<%= @document.id %> No newline at end of file
@@ -0,0 +1,4
1 A document has been added to <%= @document.project.name %> (<%= @document.category.name %>):
2 <%= l(:field_title) %>: <%= @document.title %>
3
4 http://<%= Setting.host_name %>/documents/show/<%= @document.id %> No newline at end of file
@@ -0,0 +1,4
1 A document has been added to <%= @document.project.name %> (<%= @document.category.name %>):
2 <%= l(:field_title) %>: <%= @document.title %>
3
4 http://<%= Setting.host_name %>/documents/show/<%= @document.id %> No newline at end of file
@@ -0,0 +1,4
1 Un document a été ajouté à <%= @document.project.name %> (<%= @document.category.name %>):
2 <%= l(:field_title) %>: <%= @document.title %>
3
4 http://<%= Setting.host_name %>/documents/show/<%= @document.id %> No newline at end of file
@@ -0,0 +1,15
1 class SetDocAndFilesNotifications < ActiveRecord::Migration
2 def self.up
3 Permission.find_by_controller_and_action("projects", "add_file").update_attribute(:mail_option, true)
4 Permission.find_by_controller_and_action("projects", "add_document").update_attribute(:mail_option, true)
5 Permission.find_by_controller_and_action("documents", "add_attachment").update_attribute(:mail_option, true)
6 Permission.find_by_controller_and_action("issues", "add_attachment").update_attribute(:mail_option, true)
7 end
8
9 def self.down
10 Permission.find_by_controller_and_action("projects", "add_file").update_attribute(:mail_option, false)
11 Permission.find_by_controller_and_action("projects", "add_document").update_attribute(:mail_option, false)
12 Permission.find_by_controller_and_action("documents", "add_attachment").update_attribute(:mail_option, false)
13 Permission.find_by_controller_and_action("issues", "add_attachment").update_attribute(:mail_option, false)
14 end
15 end
@@ -1,5 +1,5
1 1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
@@ -46,9 +46,13 class DocumentsController < ApplicationController
46 46
47 47 def add_attachment
48 48 # Save the attachments
49 params[:attachments].each { |a|
50 Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
49 @attachments = []
50 params[:attachments].each { |file|
51 next unless file.size > 0
52 a = Attachment.create(:container => @document, :file => file, :author => logged_in_user)
53 @attachments << a unless a.new_record?
51 54 } if params[:attachments] and params[:attachments].is_a? Array
55 Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
52 56 redirect_to :action => 'show', :id => @document
53 57 end
54 58
@@ -1,5 +1,5
1 1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
@@ -115,10 +115,13 class IssuesController < ApplicationController
115 115
116 116 def add_attachment
117 117 # Save the attachments
118 params[:attachments].each { |a|
119 @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
120 @attachment.save
118 @attachments = []
119 params[:attachments].each { |file|
120 next unless file.size > 0
121 a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
122 @attachments << a unless a.new_record?
121 123 } if params[:attachments] and params[:attachments].is_a? Array
124 Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
122 125 redirect_to :action => 'show', :id => @issue
123 126 end
124 127
@@ -184,6 +184,7 class ProjectsController < ApplicationController
184 184 Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
185 185 } if params[:attachments] and params[:attachments].is_a? Array
186 186 flash[:notice] = l(:notice_successful_create)
187 Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
187 188 redirect_to :action => 'list_documents', :id => @project
188 189 end
189 190 end
@@ -385,9 +386,13 class ProjectsController < ApplicationController
385 386 if request.post?
386 387 @version = @project.versions.find_by_id(params[:version_id])
387 388 # Save the attachments
388 params[:attachments].each { |a|
389 Attachment.create(:container => @version, :file => a, :author => logged_in_user) unless a.size == 0
389 @attachments = []
390 params[:attachments].each { |file|
391 next unless file.size > 0
392 a = Attachment.create(:container => @version, :file => file, :author => logged_in_user)
393 @attachments << a unless a.new_record?
390 394 } if params[:attachments] and params[:attachments].is_a? Array
395 Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
391 396 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
392 397 end
393 398 @versions = @project.versions
@@ -36,6 +36,36 class Mailer < ActionMailer::Base
36 36 @body['journal']= journal
37 37 end
38 38
39 def document_add(document)
40 @recipients = document.project.users.collect { |u| u.mail if u.mail_notification }.compact
41 @from = Setting.mail_from
42 @subject = "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
43 @body['document'] = document
44 end
45
46 def attachments_add(attachments)
47 container = attachments.first.container
48 url = "http://#{Setting.host_name}/"
49 added_to = ""
50 case container.class.to_s
51 when 'Version'
52 url << "projects/list_files/#{container.project_id}"
53 added_to = "#{l(:label_version)}: #{container.name}"
54 when 'Document'
55 url << "documents/show/#{container.id}"
56 added_to = "#{l(:label_document)}: #{container.title}"
57 when 'Issue'
58 url << "issues/show/#{container.id}"
59 added_to = "#{container.tracker.name} ##{container.id}: #{container.subject}"
60 end
61 @recipients = container.project.users.collect { |u| u.mail if u.mail_notification }.compact
62 @from = Setting.mail_from
63 @subject = "[#{container.project.name}] #{l(:label_attachment_new)}"
64 @body['attachments'] = attachments
65 @body['url'] = url
66 @body['added_to'] = added_to
67 end
68
39 69 def lost_password(token)
40 70 @recipients = token.user.mail
41 71 @from = Setting.mail_from
General Comments 0
You need to be logged in to leave comments. Login now