From b0a8888e356aa287fc9c968a5d9b05fc2aff0748 Mon Sep 17 00:00:00 2001
From: Jean-Philippe Lang
Date: Wed, 14 Nov 2007 21:54:16 +0000
Subject: [PATCH] Fixed: admin should be able to move issues to any project.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@903 e93f8b46-1217-0410-a6f0-8f06a7374b81
---
app/controllers/projects_controller.rb | 9 +++++++--
app/views/projects/move_issues.rhtml | 2 +-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index e708dd6fc..092e1dd00 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -295,10 +295,15 @@ class ProjectsController < ApplicationController
redirect_to :controller => 'issues', :action => 'index', :project_id => @project and return unless @issues
@projects = []
# find projects to which the user is allowed to move the issue
- User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:controller => 'projects', :action => 'move_issues')}
+ if User.current.admin?
+ # admin is allowed to move issues to any active (visible) project
+ @projects = Project.find(:all, :conditions => Project.visible_by(User.current), :order => 'name')
+ else
+ User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:controller => 'projects', :action => 'move_issues')}
+ end
# issue can be moved to any tracker
@trackers = Tracker.find(:all)
- if request.post? and params[:new_project_id] and params[:new_tracker_id]
+ if request.post? && params[:new_project_id] && @projects.collect(&:id).include?(params[:new_project_id].to_i) && params[:new_tracker_id]
new_project = Project.find_by_id(params[:new_project_id])
new_tracker = Tracker.find_by_id(params[:new_tracker_id])
@issues.each do |i|
diff --git a/app/views/projects/move_issues.rhtml b/app/views/projects/move_issues.rhtml
index e9e4bb787..b29653037 100644
--- a/app/views/projects/move_issues.rhtml
+++ b/app/views/projects/move_issues.rhtml
@@ -18,7 +18,7 @@
<%= select_tag "new_project_id", options_from_collection_for_select(@projects, "id", "name", @project.id) %>
-<%= select_tag "new_tracker_id", '' + options_from_collection_for_select(@trackers, "id", "name") %>
+<%= select_tag "new_tracker_id", "" + options_from_collection_for_select(@trackers, "id", "name") %>
<%= submit_tag l(:button_move) %>
<% end %>