diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-04-30 17:32:42 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-04-30 17:32:42 +0000 |
commit | f6d2a4c29f15812b6b73953238c2a705bef589a1 (patch) | |
tree | 219ba96b1765c21ccc063d2b9e3ba100b67c6c36 /app | |
parent | b26d0fe0411c47fd2c2aaf1c1f451de24a8de353 (diff) | |
download | redmine-f6d2a4c29f15812b6b73953238c2a705bef589a1.tar.gz redmine-f6d2a4c29f15812b6b73953238c2a705bef589a1.zip |
Backported r3683 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3717 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/issues_controller.rb | 9 | ||||
-rw-r--r-- | app/models/issue.rb | 16 |
2 files changed, 17 insertions, 8 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index d627f712d..2a60c3616 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -283,14 +283,7 @@ class IssuesController < ApplicationController def move @copy = params[:copy_options] && params[:copy_options][:copy] - @allowed_projects = [] - # find projects to which the user is allowed to move the issue - if User.current.admin? - # admin is allowed to move issues to any active (visible) project - @allowed_projects = Project.find(:all, :conditions => Project.visible_by(User.current)) - else - User.current.memberships.each {|m| @allowed_projects << m.project if m.roles.detect {|r| r.allowed_to?(:move_issues)}} - end + @allowed_projects = Issue.allowed_target_projects_on_move @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id] @target_project ||= @project @trackers = @target_project.trackers diff --git a/app/models/issue.rb b/app/models/issue.rb index 25a07107c..36051f209 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -389,6 +389,22 @@ class Issue < ActiveRecord::Base Issue.update_versions(["#{Version.table_name}.project_id IN (?) OR #{Issue.table_name}.project_id IN (?)", moved_project_ids, moved_project_ids]) end + # Returns an array of projects that current user can move issues to + def self.allowed_target_projects_on_move + projects = [] + if User.current.admin? + # admin is allowed to move issues to any active (visible) project + projects = Project.visible.all + elsif User.current.logged? + if Role.non_member.allowed_to?(:move_issues) + projects = Project.visible.all + else + User.current.memberships.each {|m| projects << m.project if m.roles.detect {|r| r.allowed_to?(:move_issues)}} + end + end + projects + end + private # Update issues so their versions are not pointing to a |