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
|
||||
statement_by_role = {}
|
||||
unless options[:member]
|
||||
role = user.logged? ? Role.non_member : Role.anonymous
|
||||
role = user.builtin_role
|
||||
if role.allowed_to?(permission)
|
||||
statement_by_role[role] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
||||
end
|
||||
|
|
|
@ -442,6 +442,15 @@ class User < Principal
|
|||
@membership_by_project_id[project_id]
|
||||
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
|
||||
def roles_for_project(project)
|
||||
roles = []
|
||||
|
@ -453,12 +462,10 @@ class User < Principal
|
|||
if membership
|
||||
roles = membership.roles
|
||||
else
|
||||
@role_non_member ||= Role.non_member
|
||||
roles << @role_non_member
|
||||
roles << builtin_role
|
||||
end
|
||||
else
|
||||
@role_anonymous ||= Role.anonymous
|
||||
roles << @role_anonymous
|
||||
roles << builtin_role
|
||||
end
|
||||
roles
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue