Adds User#builtin_role.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11965 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
cd716e311a
commit
e978b3ace0
|
@ -186,7 +186,7 @@ class Project < ActiveRecord::Base
|
||||||
else
|
else
|
||||||
statement_by_role = {}
|
statement_by_role = {}
|
||||||
unless options[:member]
|
unless options[:member]
|
||||||
role = user.logged? ? Role.non_member : Role.anonymous
|
role = user.builtin_role
|
||||||
if role.allowed_to?(permission)
|
if role.allowed_to?(permission)
|
||||||
statement_by_role[role] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
statement_by_role[role] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -442,6 +442,15 @@ class User < Principal
|
||||||
@membership_by_project_id[project_id]
|
@membership_by_project_id[project_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the user's bult-in role
|
||||||
|
def builtin_role
|
||||||
|
if logged?
|
||||||
|
@role_non_member ||= Role.non_member
|
||||||
|
else
|
||||||
|
@role_anonymous ||= Role.anonymous
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Return user's roles for project
|
# Return user's roles for project
|
||||||
def roles_for_project(project)
|
def roles_for_project(project)
|
||||||
roles = []
|
roles = []
|
||||||
|
@ -453,12 +462,10 @@ class User < Principal
|
||||||
if membership
|
if membership
|
||||||
roles = membership.roles
|
roles = membership.roles
|
||||||
else
|
else
|
||||||
@role_non_member ||= Role.non_member
|
roles << builtin_role
|
||||||
roles << @role_non_member
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@role_anonymous ||= Role.anonymous
|
roles << builtin_role
|
||||||
roles << @role_anonymous
|
|
||||||
end
|
end
|
||||||
roles
|
roles
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue