Project

General

Profile

Feature #2716 » 101-autowatch_plugin.patch

Vitaliy Ischenko, 2009-07-06 15:40

View differences:

vendor/plugins/redmine_auto_watch/init.rb
1
require 'redmine'
2

  
3
require_dependency 'auto_watch_hook'
4

  
5
Redmine::Plugin.register :redmine_auto_watch do
6
  name 'Redmine Auto Watch plugin'
7
  author 'Teddy Lerat'
8
  description 'This plugin is a hook to add users in the issue watchers list automatically when they are involved in it.'
9
  version '1.0.0'
10
end
vendor/plugins/redmine_auto_watch/lib/auto_watch_hook.rb
1
# Hooks to attach to the Redmine Issues.
2
class AutoWatchHook < Redmine::Hook::Listener
3
  def controller_issues_edit_before_save(context = { })
4
    @issue = context[:issue]
5
    unless @issue.watched_by?(User.current) || @issue.author == User.current
6
      @issue.add_watcher(User.current)
7
    end
8

  
9
    unless @issue.assigned_to == nil || @issue.watched_by?(@issue.assigned_to) || @issue.author == @issue.assigned_to
10
      @issue.add_watcher(@issue.assigned_to)
11
    end
12
  end
13
end
14

  
(2-2/3)