@@ -451,26 +451,29 class Project < ActiveRecord::Base | |||||
451 | # Returns a scope of the Versions on subprojects |
|
451 | # Returns a scope of the Versions on subprojects | |
452 | def rolled_up_versions |
|
452 | def rolled_up_versions | |
453 | @rolled_up_versions ||= |
|
453 | @rolled_up_versions ||= | |
454 | Version.scoped(:include => :project, |
|
454 | Version. | |
455 | :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> #{STATUS_ARCHIVED}", lft, rgt]) |
|
455 | includes(:project). | |
|
456 | where("#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> ?", lft, rgt, STATUS_ARCHIVED) | |||
456 | end |
|
457 | end | |
457 |
|
458 | |||
458 | # Returns a scope of the Versions used by the project |
|
459 | # Returns a scope of the Versions used by the project | |
459 | def shared_versions |
|
460 | def shared_versions | |
460 | if new_record? |
|
461 | if new_record? | |
461 | Version.scoped(:include => :project, |
|
462 | Version. | |
462 | :conditions => "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND #{Version.table_name}.sharing = 'system'") |
|
463 | includes(:project). | |
|
464 | where("#{Project.table_name}.status <> ? AND #{Version.table_name}.sharing = 'system'", STATUS_ARCHIVED) | |||
463 | else |
|
465 | else | |
464 | @shared_versions ||= begin |
|
466 | @shared_versions ||= begin | |
465 | r = root? ? self : root |
|
467 | r = root? ? self : root | |
466 | Version.scoped(:include => :project, |
|
468 | Version. | |
467 | :conditions => "#{Project.table_name}.id = #{id}" + |
|
469 | includes(:project). | |
468 | " OR (#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND (" + |
|
470 | where("#{Project.table_name}.id = #{id}" + | |
469 | " #{Version.table_name}.sharing = 'system'" + |
|
471 | " OR (#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND (" + | |
470 | " OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" + |
|
472 | " #{Version.table_name}.sharing = 'system'" + | |
471 |
|
|
473 | " OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" + | |
472 |
|
|
474 | " OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" + | |
473 | "))") |
|
475 | " OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" + | |
|
476 | "))") | |||
474 | end |
|
477 | end | |
475 | end |
|
478 | end | |
476 | end |
|
479 | end | |
@@ -954,7 +957,7 class Project < ActiveRecord::Base | |||||
954 |
|
957 | |||
955 | def allowed_permissions |
|
958 | def allowed_permissions | |
956 | @allowed_permissions ||= begin |
|
959 | @allowed_permissions ||= begin | |
957 |
module_names = enabled_modules. |
|
960 | module_names = enabled_modules.pluck(:name) | |
958 | Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name} |
|
961 | Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name} | |
959 | end |
|
962 | end | |
960 | end |
|
963 | end |
General Comments 0
You need to be logged in to leave comments.
Login now