summaryrefslogtreecommitdiffstats
path: root/vendor/plugins
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-08-03 09:14:43 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-08-03 09:14:43 +0000
commita332e0a4febeb36aac41f8d5762d18f4cbbf115c (patch)
tree8e0883bbdbfd7bfca332880da6f1739362b8c579 /vendor/plugins
parent6034067d8623e87ef1391962b882fcc93196bf4b (diff)
downloadredmine-a332e0a4febeb36aac41f8d5762d18f4cbbf115c.tar.gz
redmine-a332e0a4febeb36aac41f8d5762d18f4cbbf115c.zip
Adds permissions for viewing the watcher list and adding new watchers on the issue detail view (#398).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1712 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'vendor/plugins')
-rw-r--r--vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb18
-rw-r--r--vendor/plugins/gloc-1.1.0/lib/gloc-rails-text.rb4
2 files changed, 19 insertions, 3 deletions
diff --git a/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb b/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb
index 53e4455cf..2cb122795 100644
--- a/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb
+++ b/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb
@@ -13,6 +13,7 @@ module Redmine
class_eval do
has_many :watchers, :as => :watchable, :dependent => :delete_all
+ has_many :watcher_users, :through => :watchers, :source => :user
end
end
end
@@ -22,25 +23,40 @@ module Redmine
base.extend ClassMethods
end
+ # Returns an array of users that are proposed as watchers
+ def addable_watcher_users
+ self.project.users.sort - self.watcher_users
+ end
+
+ # Adds user as a watcher
def add_watcher(user)
self.watchers << Watcher.new(:user => user)
end
+ # Removes user from the watchers list
def remove_watcher(user)
return nil unless user && user.is_a?(User)
Watcher.delete_all "watchable_type = '#{self.class}' AND watchable_id = #{self.id} AND user_id = #{user.id}"
end
+ # Adds/removes watcher
+ def set_watcher(user, watching=true)
+ watching ? add_watcher(user) : remove_watcher(user)
+ end
+
+ # Returns if object is watched by user
def watched_by?(user)
!self.watchers.find(:first,
:conditions => ["#{Watcher.table_name}.user_id = ?", user.id]).nil?
end
+ # Returns an array of watchers' email addresses
def watcher_recipients
self.watchers.collect { |w| w.user.mail if w.user.active? }.compact
end
module ClassMethods
+ # Returns the objects that are watched by user
def watched_by(user)
find(:all,
:include => :watchers,
@@ -50,4 +66,4 @@ module Redmine
end
end
end
-end \ No newline at end of file
+end
diff --git a/vendor/plugins/gloc-1.1.0/lib/gloc-rails-text.rb b/vendor/plugins/gloc-1.1.0/lib/gloc-rails-text.rb
index f437410dc..51c024838 100644
--- a/vendor/plugins/gloc-1.1.0/lib/gloc-rails-text.rb
+++ b/vendor/plugins/gloc-1.1.0/lib/gloc-rails-text.rb
@@ -138,8 +138,8 @@ module ActionView #:nodoc:
def add_options(option_tags, options, value = nil)
option_tags = "<option value=\"\"></option>\n" + option_tags if options[:include_blank]
- if value.blank? && options[:prompt]
- ("<option value=\"\">#{options[:prompt].kind_of?(String) ? options[:prompt] : l(:actionview_instancetag_blank_option)}</option>\n") + option_tags
+ if options[:prompt]
+ ("<option value=\"\">--- #{options[:prompt].kind_of?(String) ? options[:prompt] : l(:actionview_instancetag_blank_option)} ---</option>\n") + option_tags
else
option_tags
end