Patch #222 ยป autowatch_issues.patch
| app/controllers/issues_controller.rb (working copy) | ||
|---|---|---|
|
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x, :customized => @issue) }
|
||
|
else
|
||
|
begin
|
||
|
@issue.init_journal(self.logged_in_user)
|
||
|
journal = @issue.init_journal(self.logged_in_user)
|
||
|
# Retrieve custom fields and values
|
||
|
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
|
||
|
@issue.custom_values = @custom_values
|
||
|
@issue.attributes = params[:issue]
|
||
|
if @issue.save
|
||
|
@issue.add_watcher(@issue.author) if @issue.author
|
||
|
@issue.add_watcher(@issue.assigned_to) if @issue.assigned_to
|
||
|
flash[:notice] = l(:notice_successful_update)
|
||
|
Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||
|
redirect_to :action => 'show', :id => @issue
|
||
|
end
|
||
|
rescue ActiveRecord::StaleObjectError
|
||
| ... | ... | |
|
:prop_key => a.id,
|
||
|
:value => a.filename) unless a.new_record?
|
||
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||
|
|
||
|
@issue.add_watcher(@issue.author) if @issue.author
|
||
|
@issue.add_watcher(@issue.assigned_to) if @issue.assigned_to
|
||
|
flash[:notice] = l(:notice_successful_update)
|
||
|
Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||
|
redirect_to :action => 'show', :id => @issue
|
||
| app/controllers/projects_controller.rb (working copy) | ||
|---|---|---|
|
@issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
|
||
|
|
||
|
@issue.author_id = self.logged_in_user.id if self.logged_in_user
|
||
|
@issue.add_watcher(self.logged_in_user) if self.logged_in_user
|
||
|
@issue.add_watcher(@issue.assigned_to) if @issue.assigned_to
|
||
|
# Multiple file upload
|
||
|
@attachments = []
|
||
|
params[:attachments].each { |a|
|
||
| app/models/mailer.rb (working copy) | ||
|---|---|---|
|
def issue_add(issue)
|
||
|
set_language_if_valid(Setting.default_language)
|
||
|
# Sends to all project members
|
||
|
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
|
||
|
@recipients = issue.watcher_recipients
|
||
|
@recipients.push issue.assigned_to.mail if issue.assigned_to
|
||
|
@recipients.uniq!
|
||
|
# Managers in cc
|
||
|
#@cc = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification && m.role.name =~ /manager/i }.compact - @recipients
|
||
|
@from = Setting.mail_from
|
||
|
@subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
|
||
|
@body['issue'] = issue
|
||
| ... | ... | |
|
set_language_if_valid(Setting.default_language)
|
||
|
# Sends to all project members
|
||
|
issue = journal.journalized
|
||
|
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
|
||
|
# Watchers in cc
|
||
|
@cc = issue.watcher_recipients - @recipients
|
||
|
@recipients = issue.watcher_recipients
|
||
|
@recipients.push issue.assigned_to.mail if issue.assigned_to
|
||
|
@recipients.uniq!
|
||
|
# Managers in cc
|
||
|
#@cc = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification && m.role.name =~ /manager/i }.compact - @recipients
|
||
|
@from = Setting.mail_from
|
||
|
@subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
|
||
|
@body['issue'] = issue
|
||
| db/migrate/059_set_issue_edit_notifications.rb (revision 0) | ||
|---|---|---|
|
class SetIssueEditNotifications < ActiveRecord::Migration
|
||
|
def self.up
|
||
|
Permission.find_by_controller_and_action("issues", "edit").update_attribute(:mail_option, true)
|
||
|
end
|
||
|
def self.down
|
||
|
Permission.find_by_controller_and_action("issues", "edit").update_attribute(:mail_option, false)
|
||
|
end
|
||
|
end
|
||
| lib/redmine/acts_as_watchable/lib/acts_as_watchable.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
|
||
|
def add_watcher(user)
|
||
|
self.watchers << Watcher.new(:user => user)
|
||
|
self.watchers << Watcher.new(:user => user) unless self.watchers.member?(user)
|
||
|
end
|
||
|
|
||
|
def remove_watcher(user)
|
||