# HG changeset patch # Date 1348198057 -28800 # Node ID 201c68b37ccdd853ab0c07e299970c5162731fb1 # Parent ca7f4facf743868a095757b2dab3b0cf561138dc add the patch, ensure files stil in unix format diff -r ca7f4facf743 -r 201c68b37ccd app/models/issue.rb --- a/app/models/issue.rb Fri Sep 21 11:21:53 2012 +0800 +++ b/app/models/issue.rb Fri Sep 21 11:27:37 2012 +0800 @@ -60,8 +60,7 @@ validates_numericality_of :estimated_hours, :allow_nil => true validate :validate_issue, :validate_required_fields - scope :visible, - lambda {|*args| { :include => :project, + scope :visible, lambda {|*args| { :include => [:project, :watchers], :conditions => Issue.visible_condition(args.shift || User.current, *args) } } scope :open, lambda {|*args| @@ -89,10 +88,10 @@ 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 @@ -106,15 +105,24 @@ 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? diff -r ca7f4facf743 -r 201c68b37ccd app/models/journal.rb --- a/app/models/journal.rb Fri Sep 21 11:21:53 2012 +0800 +++ b/app/models/journal.rb Fri Sep 21 11:27:37 2012 +0800 @@ -38,7 +38,7 @@ " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"} scope :visible, lambda {|*args| { - :include => {:issue => :project}, + :include => {:issue => [:project, :watchers]}, :conditions => Issue.visible_condition(args.shift || User.current, *args) }}