]> source.dussan.org Git - redmine.git/commitdiff
Code cleanup: use #project_condition.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 23 Oct 2014 17:23:02 +0000 (17:23 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 23 Oct 2014 17:23:02 +0000 (17:23 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13497 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb

index c2b8af134d50f6831d06ce5d90d9da6686859c49..92bbf0e88a0f22b5a1a62ec3a0b1c98262507bd3 100644 (file)
@@ -179,9 +179,8 @@ class Project < ActiveRecord::Base
       # If the permission belongs to a project module, make sure the module is enabled
       base_statement << " AND #{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.project_module}')"
     end
-    if options[:project]
-      project_statement = "#{Project.table_name}.id = #{options[:project].id}"
-      project_statement << " OR (#{Project.table_name}.lft > #{options[:project].lft} AND #{Project.table_name}.rgt < #{options[:project].rgt})" if options[:with_subprojects]
+    if project = options[:project]
+      project_statement = project.project_condition(options[:with_subprojects])
       base_statement = "(#{project_statement}) AND (#{base_statement})"
     end