summaryrefslogtreecommitdiffstats
path: root/app/models/issue.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-06-05 10:06:17 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-06-05 10:06:17 +0000
commit79df68e17fc09a4d8bc87cad8efb4bc31c085dcd (patch)
tree33b0e4d2bfa3e26b6d2fa28a35d91a2b659242c7 /app/models/issue.rb
parent939a7137ef985647d34fdacadf419b313bcd9110 (diff)
downloadredmine-79df68e17fc09a4d8bc87cad8efb4bc31c085dcd.tar.gz
redmine-79df68e17fc09a4d8bc87cad8efb4bc31c085dcd.zip
Limit trackers for new issue to certain roles (#7839).
git-svn-id: http://svn.redmine.org/redmine/trunk@15464 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index d6133d3a9..2baaea3f8 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1368,16 +1368,27 @@ class Issue < ActiveRecord::Base
# Returns a scope of trackers that user can assign the issue to
def allowed_target_trackers(user=User.current)
- if project
- self.class.allowed_target_trackers(project, user, tracker_id_was)
- else
- Tracker.none
- end
+ self.class.allowed_target_trackers(project, user, tracker_id_was)
end
# Returns a scope of trackers that user can assign project issues to
def self.allowed_target_trackers(project, user=User.current, current_tracker=nil)
- project.trackers.sorted
+ if project
+ scope = project.trackers.sorted
+ unless user.admin?
+ roles = user.roles_for_project(project).select {|r| r.has_permission?(:add_issues)}
+ unless roles.any? {|r| r.permissions_all_trackers?(:add_issues)}
+ tracker_ids = roles.map {|r| r.permissions_tracker_ids(:add_issues)}.flatten.uniq
+ if current_tracker
+ tracker_ids << current_tracker
+ end
+ scope = scope.where(:id => tracker_ids)
+ end
+ end
+ scope
+ else
+ Tracker.none
+ end
end
private