Feature #8488 » private_issue_watchers_2.2_FIXED_3.diff
| app/models/issue.rb | ||
|---|---|---|
|
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(',')}))"
|
||
|
watched_issues = Watcher.find(:all, :conditions => { :watchable_type => "Issue", :user_id => user.id}).map(&:watchable_id).uniq.sort
|
||
|
"(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}) OR #{table_name}.id IN (#{watched_issues.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(',')}))"
|
||
|
watched_issues = Watcher.find(:all, :conditions => { :watchable_type => "Issue", :user_id => user.id}).map(&:watchable_id).uniq.sort
|
||
|
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}) OR #{table_name}.id IN (#{watched_issues.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?
|
||