diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index c0d954499..405ddb973 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -33,6 +33,10 @@ module UsersHelper
[[l(:label_font_default), '']] + UserPreference::TEXTAREA_FONT_OPTIONS.map {|o| [l("label_font_#{o}"), o]}
end
+ def auto_watch_on_options
+ UserPreference::AUTO_WATCH_ON_OPTIONS.map {|o| [l("label_auto_watch_on_#{o}"), o]}.to_h
+ end
+
def change_status_link(user)
url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
diff --git a/app/models/journal.rb b/app/models/journal.rb
index ce3f9d0b3..f2e34d6fe 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -42,6 +42,7 @@ class Journal < ActiveRecord::Base
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct
before_create :split_private_notes
+ before_create :add_watcher
after_create_commit :send_notification
scope :visible, lambda {|*args|
@@ -301,6 +302,14 @@ class Journal < ActiveRecord::Base
true
end
+ def add_watcher
+ if user.allowed_to?(:add_issue_watchers, project) &&
+ user.pref.auto_watch_on?('add_note') &&
+ Watcher.any_watched?(Array.wrap(journalized), user) == false
+ journalized.set_watcher(user, true)
+ end
+ end
+
def send_notification
if notify? && (Setting.notified_events.include?('issue_updated') ||
(Setting.notified_events.include?('issue_note_added') && notes.present?) ||
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index 7373290c5..7aca092c4 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -30,9 +30,11 @@ class UserPreference < ActiveRecord::Base
'comments_sorting',
'warn_on_leaving_unsaved',
'no_self_notified',
- 'textarea_font'
+ 'textarea_font',
+ 'auto_watch_on'
TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional']
+ AUTO_WATCH_ON_OPTIONS = ['add_note']
def initialize(attributes=nil, *args)
super
@@ -46,6 +48,9 @@ class UserPreference < ActiveRecord::Base
unless attributes && attributes.key?(:no_self_notified)
self.no_self_notified = true
end
+ unless attributes && attributes.key?(:auto_watch_on)
+ self.auto_watch_on = AUTO_WATCH_ON_OPTIONS
+ end
end
self.others ||= {}
end
@@ -88,6 +93,10 @@ class UserPreference < ActiveRecord::Base
def textarea_font; self[:textarea_font] end
def textarea_font=(value); self[:textarea_font]=value; end
+ def auto_watch_on; self[:auto_watch_on] || []; end
+ def auto_watch_on=(values); self[:auto_watch_on]=values; end
+ def auto_watch_on?(action); self.auto_watch_on.include?(action.to_s); end
+
# Returns the names of groups that are displayed on user's page
# Example:
# preferences.my_page_groups
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb
index 63402c977..c2055e76b 100644
--- a/app/views/my/account.html.erb
+++ b/app/views/my/account.html.erb
@@ -44,6 +44,11 @@
<%= render :partial => 'users/mail_notifications' %>
+
+
+
+