Project

General

Profile

Actions

Feature #2475

closed

Hooks for IssuesController

Added by Sean Robins over 15 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Plugin API
Target version:
Start date:
2009-01-09
Due date:
% Done:

100%

Estimated time:
Resolution:
Fixed

Description

I have been tasked with providing a plugin to allow Redmine to act as a controller for a 3rd party VCS system's built in issue tracker. In order to reduce situations where orphaned issue records could be created in the 3rd party tool, Hook events need to be called After issues have been saved in Redmine.

At present, I have modified my own Redmine installation's issues_controller.rb file to provide hooks in the new() and edit() methods of the IssuesController class, directly after the redirect_to statements in those methods.

In the add() method, I have done the following:

...
if @issue.save
  attach_files(@issue, params[:attachments])
  flash[:notice] = l(:notice_successful_create)
  Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
  redirect_to :controller => 'issues', :action => 'show', :id => @issue
  #
  call_hook(:controller_issues_new_after_save, { :issue => @issue })
  #
  return
end
...

... and in edit():

  ...
  if !journal.new_record?
    # Only send notification if something was actually changed
    flash[:notice] = l(:notice_successful_update)
    Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
  end
  redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
  #
  call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
  #
  ...

For my own most immediate requirements, this is the minimum I have needed to get the job done, and would very much appreciate if the feature could be added to future releases of Redmine, as this would save me needing to edit Redmine source whenever a new version is release.

I can however envisage situations where before and after events could be needed for issue creation, editing, deletion, or possibly anywhere that issue record changes are submitted.

Thanks.

Sean


Related issues

Related to Redmine - Defect #3118: hook controller_issues_new_after_save is missing from issues_controllerClosedEric Davis2009-04-03

Actions
Actions

Also available in: Atom PDF