Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5459 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
5beef16378
commit
80e2eed702
|
@ -157,19 +157,18 @@ class Project < ActiveRecord::Base
|
||||||
base_statement
|
base_statement
|
||||||
else
|
else
|
||||||
statement_by_role = {}
|
statement_by_role = {}
|
||||||
if user.logged?
|
unless options[:member]
|
||||||
if Role.non_member.allowed_to?(permission) && !options[:member]
|
role = user.logged? ? Role.non_member : Role.anonymous
|
||||||
statement_by_role[Role.non_member] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
if role.allowed_to?(permission)
|
||||||
|
statement_by_role[role] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
if user.logged?
|
||||||
user.projects_by_role.each do |role, projects|
|
user.projects_by_role.each do |role, projects|
|
||||||
if role.allowed_to?(permission)
|
if role.allowed_to?(permission)
|
||||||
statement_by_role[role] = "#{Project.table_name}.id IN (#{projects.collect(&:id).join(',')})"
|
statement_by_role[role] = "#{Project.table_name}.id IN (#{projects.collect(&:id).join(',')})"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
if Role.anonymous.allowed_to?(permission) && !options[:member]
|
|
||||||
statement_by_role[Role.anonymous] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if statement_by_role.empty?
|
if statement_by_role.empty?
|
||||||
"1=0"
|
"1=0"
|
||||||
|
|
Loading…
Reference in New Issue