summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-04-06 17:34:45 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-04-06 17:34:45 +0000
commit1cd985dd6b2a674b632be0d490f6f5070e35591d (patch)
tree7c8ac28f617888b721154df5e3a8876bc4a2b7e2 /app/controllers
parent8ea86a8249463e3d848e0490228da63b40d2d0bb (diff)
downloadredmine-1cd985dd6b2a674b632be0d490f6f5070e35591d.tar.gz
redmine-1cd985dd6b2a674b632be0d490f6f5070e35591d.zip
Option to copy watchers when copying issues (#10460).
git-svn-id: http://svn.redmine.org/redmine/trunk@16509 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/issues_controller.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index b6c72a314..177fdeb38 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -265,6 +265,7 @@ class IssuesController < ApplicationController
if @copy
@attachments_present = @issues.detect {|i| i.attachments.any?}.present?
@subtasks_present = @issues.detect {|i| !i.leaf?}.present?
+ @watchers_present = User.current.allowed_to?(:add_issue_watchers, @projects) && Watcher.where(:watchable_type => 'Issue', :watchable_id => @issues.map(&:id)).exists?
end
@safe_attributes = edited_issues.map(&:safe_attribute_names).reduce(:&)
@@ -280,6 +281,7 @@ class IssuesController < ApplicationController
attributes = parse_params_for_bulk_update(params[:issue])
copy_subtasks = (params[:copy_subtasks] == '1')
copy_attachments = (params[:copy_attachments] == '1')
+ copy_watchers = (params[:copy_watchers] == '1')
if @copy
unless User.current.allowed_to?(:copy_issues, @projects)
@@ -292,6 +294,9 @@ class IssuesController < ApplicationController
unless User.current.allowed_to?(:add_issues, target_projects)
raise ::Unauthorized
end
+ unless User.current.allowed_to?(:add_issue_watchers, @projects)
+ copy_watchers = false
+ end
else
unless @issues.all?(&:attributes_editable?)
raise ::Unauthorized
@@ -313,6 +318,7 @@ class IssuesController < ApplicationController
issue = orig_issue.copy({},
:attachments => copy_attachments,
:subtasks => copy_subtasks,
+ :watchers => copy_watchers,
:link => link_copy?(params[:link_copy])
)
else
@@ -484,7 +490,8 @@ class IssuesController < ApplicationController
@link_copy = link_copy?(params[:link_copy]) || request.get?
@copy_attachments = params[:copy_attachments].present? || request.get?
@copy_subtasks = params[:copy_subtasks].present? || request.get?
- @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
+ @copy_watchers = User.current.allowed_to?(:add_issue_watchers, @project)
+ @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :watchers => @copy_watchers, :link => @link_copy)
@issue.parent_issue_id = @copy_from.parent_id
rescue ActiveRecord::RecordNotFound
render_404