Role-based issue custom field visibility (#5037).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12012 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
a74d55edd9
commit
628d05629b
41 files changed
+953
-121
No files matched your search
+58
-30
@@ -27,34 +27,35 @@ class Mailer < ActionMailer::Base
|
||||
{ :host => Setting.host_name, :protocol => Setting.protocol }
|
||||
end
|
||||
|
||||
# Builds a Mail::Message object used to email recipients of the added issue.
|
||||
#
|
||||
# Example:
|
||||
# issue_add(issue) => Mail::Message object
|
||||
# Mailer.issue_add(issue).deliver => sends an email to issue recipients
|
||||
def issue_add(issue)
|
||||
# Builds a mail for notifying to_users and cc_users about a new issue
|
||||
def issue_add(issue, to_users, cc_users)
|
||||
redmine_headers 'Project' => issue.project.identifier,
|
||||
'Issue-Id' => issue.id,
|
||||
'Issue-Author' => issue.author.login
|
||||
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
|
||||
message_id issue
|
||||
references issue
|
||||
@author = issue.author
|
||||
@issue = issue
|
||||
@users = to_users + cc_users
|
||||
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
|
||||
recipients = issue.recipients
|
||||
cc = issue.watcher_recipients - recipients
|
||||
mail :to => recipients,
|
||||
:cc => cc,
|
||||
mail :to => to_users.map(&:mail),
|
||||
:cc => cc_users.map(&:mail),
|
||||
:subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
|
||||
end
|
||||
|
||||
# Builds a Mail::Message object used to email recipients of the edited issue.
|
||||
#
|
||||
# Example:
|
||||
# issue_edit(journal) => Mail::Message object
|
||||
# Mailer.issue_edit(journal).deliver => sends an email to issue recipients
|
||||
def issue_edit(journal)
|
||||
issue = journal.journalized.reload
|
||||
# Notifies users about a new issue
|
||||
def self.deliver_issue_add(issue)
|
||||
to = issue.notified_users
|
||||
cc = issue.notified_watchers - to
|
||||
issue.each_notification(to + cc) do |users|
|
||||
Mailer.issue_add(issue, to & users, cc & users).deliver
|
||||
end
|
||||
end
|
||||
|
||||
# Builds a mail for notifying to_users and cc_users about an issue update
|
||||
def issue_edit(journal, to_users, cc_users)
|
||||
issue = journal.journalized
|
||||
redmine_headers 'Project' => issue.project.identifier,
|
||||
'Issue-Id' => issue.id,
|
||||
'Issue-Author' => issue.author.login
|
||||
@@ -62,20 +63,30 @@ class Mailer < ActionMailer::Base
|
||||
message_id journal
|
||||
references issue
|
||||
@author = journal.user
|
||||
recipients = journal.recipients
|
||||
# Watchers in cc
|
||||
cc = journal.watcher_recipients - recipients
|
||||
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
|
||||
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
|
||||
s << issue.subject
|
||||
@issue = issue
|
||||
@users = to_users + cc_users
|
||||
@journal = journal
|
||||
@journal_details = journal.visible_details(@users.first)
|
||||
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
|
||||
mail :to => recipients,
|
||||
:cc => cc,
|
||||
mail :to => to_users.map(&:mail),
|
||||
:cc => cc_users.map(&:mail),
|
||||
:subject => s
|
||||
end
|
||||
|
||||
# Notifies users about an issue update
|
||||
def self.deliver_issue_edit(journal)
|
||||
issue = journal.journalized.reload
|
||||
to = journal.notified_users
|
||||
cc = journal.notified_watchers
|
||||
issue.each_notification(to + cc) do |users|
|
||||
next unless journal.notes? || journal.visible_details(users.first).any?
|
||||
Mailer.issue_edit(journal, to & users, cc & users).deliver
|
||||
end
|
||||
end
|
||||
|
||||
def reminder(user, issues, days)
|
||||
set_language_if_valid user.language
|
||||
@issues = issues
|
||||
@@ -142,6 +153,7 @@ class Mailer < ActionMailer::Base
|
||||
redmine_headers 'Project' => news.project.identifier
|
||||
@author = news.author
|
||||
message_id news
|
||||
references news
|
||||
@news = news
|
||||
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
||||
mail :to => news.recipients,
|
||||
@@ -158,6 +170,7 @@ class Mailer < ActionMailer::Base
|
||||
redmine_headers 'Project' => news.project.identifier
|
||||
@author = comment.author
|
||||
message_id comment
|
||||
references news
|
||||
@news = news
|
||||
@comment = comment
|
||||
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
||||
@@ -176,7 +189,7 @@ class Mailer < ActionMailer::Base
|
||||
'Topic-Id' => (message.parent_id || message.id)
|
||||
@author = message.author
|
||||
message_id message
|
||||
references message.parent unless message.parent.nil?
|
||||
references message.root
|
||||
recipients = message.recipients
|
||||
cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
|
||||
@message = message
|
||||
@@ -386,7 +399,7 @@ class Mailer < ActionMailer::Base
|
||||
headers[:message_id] = "<#{self.class.message_id_for(@message_id_object)}>"
|
||||
end
|
||||
if @references_objects
|
||||
headers[:references] = @references_objects.collect {|o| "<#{self.class.message_id_for(o)}>"}.join(' ')
|
||||
headers[:references] = @references_objects.collect {|o| "<#{self.class.references_for(o)}>"}.join(' ')
|
||||
end
|
||||
|
||||
super headers do |format|
|
||||
@@ -434,15 +447,30 @@ class Mailer < ActionMailer::Base
|
||||
h.each { |k,v| headers["X-Redmine-#{k}"] = v.to_s }
|
||||
end
|
||||
|
||||
# Returns a predictable Message-Id for the given object
|
||||
def self.message_id_for(object)
|
||||
# id + timestamp should reduce the odds of a collision
|
||||
# as far as we don't send multiple emails for the same object
|
||||
def self.token_for(object, rand=true)
|
||||
timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on)
|
||||
hash = "redmine.#{object.class.name.demodulize.underscore}-#{object.id}.#{timestamp.strftime("%Y%m%d%H%M%S")}"
|
||||
hash = [
|
||||
"redmine",
|
||||
"#{object.class.name.demodulize.underscore}-#{object.id}",
|
||||
timestamp.strftime("%Y%m%d%H%M%S")
|
||||
]
|
||||
if rand
|
||||
hash << Redmine::Utils.random_hex(8)
|
||||
end
|
||||
host = Setting.mail_from.to_s.gsub(%r{^.*@}, '')
|
||||
host = "#{::Socket.gethostname}.redmine" if host.empty?
|
||||
"#{hash}@#{host}"
|
||||
"#{hash.join('.')}@#{host}"
|
||||
end
|
||||
|
||||
# Returns a Message-Id for the given object
|
||||
def self.message_id_for(object)
|
||||
token_for(object, true)
|
||||
end
|
||||
|
||||
# Returns a uniq token for a given object referenced by all notifications
|
||||
# related to this object
|
||||
def self.references_for(object)
|
||||
token_for(object, false)
|
||||
end
|
||||
|
||||
def message_id(object)
|
||||
|
||||
Reference in new issue
Block a user