Feature #2716 » 101-autowatch_plugin.patch
| vendor/plugins/redmine_auto_watch/init.rb | ||
|---|---|---|
|
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
|
||
| vendor/plugins/redmine_auto_watch/lib/auto_watch_hook.rb | ||
|---|---|---|
|
# 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
|
||