summaryrefslogtreecommitdiffstats
path: root/lib/plugins
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2024-10-28 20:46:09 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2024-10-28 20:46:09 +0000
commit2c802a2bdf3ad125a4051f9b04a96a9b51e0661b (patch)
tree56d98827b40d1298c62db49b2b4a2e69820f73c9 /lib/plugins
parenta5a086eba16af67f9841a617dac6942b73d8e5af (diff)
downloadredmine-2c802a2bdf3ad125a4051f9b04a96a9b51e0661b.tar.gz
redmine-2c802a2bdf3ad125a4051f9b04a96a9b51e0661b.zip
Merged r22913-r22917 from trunk to 5.1-stable (#40946).
git-svn-id: https://svn.redmine.org/redmine/branches/5.1-stable@23167 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/plugins')
-rw-r--r--lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb b/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb
index 1a5888464..139766b21 100644
--- a/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb
+++ b/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb
@@ -43,6 +43,24 @@ module Redmine
users
end
+ # array of watchers that the given user is allowed to see
+ def visible_watcher_users(user = User.current)
+ if user.allowed_to?(:"view_#{self.class.name.underscore}_watchers", project)
+ watcher_users
+ else
+ # without permission, the user can only see themselves (if they're a watcher)
+ watcher_users & [user]
+ end
+ end
+
+ # true if user can be added as a watcher
+ def valid_watcher?(user)
+ return true unless respond_to?(:visible?)
+ return true unless user.is_a?(User)
+
+ visible?(user)
+ end
+
# Adds user as a watcher
def add_watcher(user)
if persisted?