Browse files

Adding files

  • Loading branch information...
1 parent 8cccac0 commit 90ae7fb6336637e16c431b3cd6bc7afef44343da @mezza committed May 14, 2010
Showing with 25 additions and 0 deletions.
  1. +3 −0 README
  2. +10 −0 init.rb
  3. +12 −0 lib/auto_watch_hook.rb
View
3 README
@@ -0,0 +1,3 @@
+Useful plugin for Redmine written by Teddy Lerat.
+
+http://www.redmine.org/issues/2716
View
10 init.rb
@@ -0,0 +1,10 @@
+require 'redmine'
+
+require_dependency 'auto_watch_hook'
+
+Redmine::Plugin.register :redmine_auto_watch do
+ name 'Redmine Auto Watch plugin'
+ author 'Teddy Lerat'
+ description 'This plugin is a hook to add users in the issue watchers list automatically when they are involved in it.'
+ version '1.0.0'
+end
View
12 lib/auto_watch_hook.rb
@@ -0,0 +1,12 @@
+# Hooks to attach to the Redmine Issues.
+class AutoWatchHook < Redmine::Hook::Listener
+ def controller_issues_edit_before_save(context = { })
+ @issue = context[:issue]
+ unless @issue.watched_by?(User.current) || @issue.author == User.current
+ @issue.add_watcher(User.current)
+ end
+ unless @issue.assigned_to == nil || @issue.watched_by?(@issue.assigned_to) || @issue.author == @issue.assigned_to
+ @issue.add_watcher(@issue.assigned_to)
+ end
+ end
+end

0 comments on commit 90ae7fb

Please sign in to comment.