diff --git a/vendor/plugins/redmine_auto_watch/init.rb b/vendor/plugins/redmine_auto_watch/init.rb new file mode 100644 index 0000000..63b7787 --- /dev/null +++ b/vendor/plugins/redmine_auto_watch/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 diff --git a/vendor/plugins/redmine_auto_watch/lib/auto_watch_hook.rb b/vendor/plugins/redmine_auto_watch/lib/auto_watch_hook.rb new file mode 100644 index 0000000..4af2200 --- /dev/null +++ b/vendor/plugins/redmine_auto_watch/lib/auto_watch_hook.rb @@ -0,0 +1,14 @@ +# 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 +