Private issues (#7414).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5466 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
+13
-2
@@ -90,8 +90,10 @@ class Issue < ActiveRecord::Base
|
||||
def self.visible_condition(user, options={})
|
||||
Project.allowed_to_condition(user, :view_issues, options) do |role, user|
|
||||
case role.issues_visibility
|
||||
when 'default'
|
||||
when 'all'
|
||||
nil
|
||||
when 'default'
|
||||
"(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id = #{user.id})"
|
||||
when 'own'
|
||||
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id = #{user.id})"
|
||||
else
|
||||
@@ -104,8 +106,10 @@ class Issue < ActiveRecord::Base
|
||||
def visible?(usr=nil)
|
||||
(usr || User.current).allowed_to?(:view_issues, self.project) do |role, user|
|
||||
case role.issues_visibility
|
||||
when 'default'
|
||||
when 'all'
|
||||
true
|
||||
when 'default'
|
||||
!self.is_private? || self.author == user || self.assigned_to == user
|
||||
when 'own'
|
||||
self.author == user || self.assigned_to == user
|
||||
else
|
||||
@@ -257,6 +261,12 @@ class Issue < ActiveRecord::Base
|
||||
'done_ratio',
|
||||
:if => lambda {|issue, user| issue.new_statuses_allowed_to(user).any? }
|
||||
|
||||
safe_attributes 'is_private',
|
||||
:if => lambda {|issue, user|
|
||||
user.allowed_to?(:set_issues_private, issue.project) ||
|
||||
(issue.author == user && user.allowed_to?(:set_own_issues_private, issue.project))
|
||||
}
|
||||
|
||||
# Safely sets attributes
|
||||
# Should be called from controllers instead of #attributes=
|
||||
# attr_accessible is too rough because we still want things like
|
||||
@@ -552,6 +562,7 @@ class Issue < ActiveRecord::Base
|
||||
s << ' overdue' if overdue?
|
||||
s << ' child' if child?
|
||||
s << ' parent' unless leaf?
|
||||
s << ' private' if is_private?
|
||||
s << ' created-by-me' if User.current.logged? && author_id == User.current.id
|
||||
s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
|
||||
s
|
||||
|
||||
@@ -17,4 +17,22 @@
|
||||
|
||||
class JournalDetail < ActiveRecord::Base
|
||||
belongs_to :journal
|
||||
before_save :normalize_values
|
||||
|
||||
private
|
||||
|
||||
def normalize_values
|
||||
self.value = normalize(value)
|
||||
self.old_value = normalize(old_value)
|
||||
end
|
||||
|
||||
def normalize(v)
|
||||
if v == true
|
||||
"1"
|
||||
elsif v == false
|
||||
"0"
|
||||
else
|
||||
v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+2
-1
@@ -21,7 +21,8 @@ class Role < ActiveRecord::Base
|
||||
BUILTIN_ANONYMOUS = 2
|
||||
|
||||
ISSUES_VISIBILITY_OPTIONS = [
|
||||
['default', :label_issues_visibility_all],
|
||||
['all', :label_issues_visibility_all],
|
||||
['default', :label_issues_visibility_public],
|
||||
['own', :label_issues_visibility_own]
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user