Feature #8488 » private_issue_watchers_2.2_FIXED.diff
| app/models/issue.rb | ||
|---|---|---|
|
scope :visible,
|
||
|
lambda {|*args| { :include => :project,
|
||
|
:joins => %Q{LEFT OUTER JOIN "#{Watcher.table_name}" ON "#{Watcher.table_name}"."watchable_id" = "#{table_name}"."id" AND "#{Watcher.table_name}"."watchable_type" = 'Issue'},
|
||
|
:conditions => Issue.visible_condition(args.shift || User.current, *args) } }
|
||
|
scope :open, lambda {|*args|
|
||
| ... | ... | |
|
nil
|
||
|
when 'default'
|
||
|
user_ids = [user.id] + user.groups.map(&:id)
|
||
|
"(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||
|
"(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{Watcher.table_name}.user_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||
|
when 'own'
|
||
|
user_ids = [user.id] + user.groups.map(&:id)
|
||
|
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||
|
"(#{table_name}.author_id = #{user.id} OR #{Watcher.table_name}.user_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||
|
else
|
||
|
'1=0'
|
||
|
end
|
||
| ... | ... | |
|
when 'all'
|
||
|
true
|
||
|
when 'default'
|
||
|
!self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
|
||
|
!self.is_private? || self.author == user || self.watched_by?(user) || user.is_or_belongs_to?(assigned_to)
|
||
|
when 'own'
|
||
|
self.author == user || user.is_or_belongs_to?(assigned_to)
|
||
|
self.author == user || self.watched_by?(user) || user.is_or_belongs_to?(assigned_to)
|
||
|
else
|
||
|
false
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
# Override the acts_as_watchble default to allow any user with view issues
|
||
|
# rights to watch/see this issue.
|
||
|
def addable_watcher_users
|
||
|
users = self.project.users.sort - self.watcher_users
|
||
|
users.reject! {|user| !user.allowed_to?(:view_issues, self.project)}
|
||
|
users
|
||
|
end
|
||
|
def initialize(attributes=nil, *args)
|
||
|
super
|
||
|
if new_record?
|
||
| app/models/journal.rb | ||
|---|---|---|
|
user = args.shift || User.current
|
||
|
includes(:issue => :project).
|
||
|
joins(%Q{LEFT OUTER JOIN "#{Watcher.table_name}" ON "#{Watcher.table_name}"."watchable_id" = "#{Issue.table_name}"."id" AND "#{Watcher.table_name}"."watchable_type" = 'Issue'}).
|
||
|
where(Issue.visible_condition(user, *args)).
|
||
|
where("(#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(user, :view_private_notes, *args)}))", false)
|
||
|
}
|
||