Project

General

Profile

Feature #8488 » private_issue_watchers_2.2_FIXED_4.diff

Justin Hahn, 2013-03-06 14:47

View differences:

app/models/issue.rb
100 100
          nil
101 101
        when 'default'
102 102
          user_ids = [user.id] + user.groups.map(&:id)
103
          "(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
103
          watched_issues = Issue.watched_by(user).map(&:id)
104
          "(#{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(',')}))"
104 105
        when 'own'
105 106
          user_ids = [user.id] + user.groups.map(&:id)
106
          "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
107
          watched_issues = Issue.watched_by(user).map(&:id)
108
          "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}) OR #{table_name}.id IN (#{watched_issues.join(',')}))"
107 109
        else
108 110
          '1=0'
109 111
        end
......
121 123
        when 'all'
122 124
          true
123 125
        when 'default'
124
          !self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
126
          !self.is_private? || (self.author == user || self.watched_by?(user) || user.is_or_belongs_to?(assigned_to))
125 127
        when 'own'
126
          self.author == user || user.is_or_belongs_to?(assigned_to)
128
          self.author == user || self.watched_by?(user) || user.is_or_belongs_to?(assigned_to)
127 129
        else
128 130
          false
129 131
        end
......
133 135
    end
134 136
  end
135 137

  
138
  # Override the acts_as_watchble default to allow any user with view issues
139
  # rights to watch/see this issue.
140
  def addable_watcher_users
141
    users = self.project.users.sort - self.watcher_users
142
    users.reject! {|user| !user.allowed_to?(:view_issues, self.project)}
143
    users
144
  end
145

  
146

  
136 147
  def initialize(attributes=nil, *args)
137 148
    super
138 149
    if new_record?
(11-11/14)