Project

General

Profile

Patch #37565 ยป patch.diff

Vincent Robert, 2022-08-09 15:22

View differences:

app/models/issue_custom_field.rb
40 40
      " OR #{Issue.table_name}.project_id IN (SELECT project_id FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} WHERE custom_field_id = #{id_column})"
41 41

  
42 42
    "((#{sql}) AND (#{tracker_condition}) AND (#{project_condition}) AND (#{Issue.visible_condition(user)}))"
43
    "((#{sql}) AND (#{tracker_condition}) AND (#{project_condition}) AND (#{Issue.visible_condition(user, {skip_pre_condition: true})}))"
43 44
  end
44 45

  
45 46
  def validate_custom_field
app/models/project.rb
178 178
  # * :member => true                   limit the condition to the user projects
179 179
  def self.allowed_to_condition(user, permission, options={})
180 180
    perm = Redmine::AccessControl.permission(permission)
181
    base_statement =
182
      if perm && perm.read?
181
    if options[:skip_pre_condition]
182
      base_statement = "1=1"
183
    else
184
      base_statement = if perm && perm.read?
183 185
        "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}"
184 186
      else
185 187
        "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}"
186 188
      end
187
    if !options[:skip_pre_condition] && perm && perm.project_module
188
      # If the permission belongs to a project module, make sure the module is enabled
189
      base_statement +=
190
        " AND EXISTS (SELECT 1 AS one FROM #{EnabledModule.table_name} em" \
191
          " WHERE em.project_id = #{Project.table_name}.id" \
192
          " AND em.name='#{perm.project_module}')"
189
      if perm && perm.project_module
190
        # If the permission belongs to a project module, make sure the module is enabled
191
        base_statement +=
192
          " AND EXISTS (SELECT 1 AS one FROM #{EnabledModule.table_name} em" \
193
            " WHERE em.project_id = #{Project.table_name}.id" \
194
            " AND em.name='#{perm.project_module}')"
195
      end
193 196
    end
194 197
    if project = options[:project]
195 198
      project_statement = project.project_condition(options[:with_subprojects])
    (1-1/1)