Actions
Maintenance #3052
closedxmera Omnia - Collection #3083: Update to RM 5.1.7
Check user query
Start date:
03/17/2025
Due date:
03/17/2025
% Done:
100%
Estimated time:
Compatible Redmine Version:
5.1.z
Pull Request Link:
Description
diff --git a/app/models/user_query.rb b/app/models/user_query.rb
index eba443ff6..7d0d688ac 100644
--- a/app/models/user_query.rb
+++ b/app/models/user_query.rb
@@ -17,6 +17,7 @@
# along with this program; if not, write to the Free Software
class UserQuery < Query
+ self.layout = 'admin'
self.queried_class = Principal # must be Principal (not User) for custom field filters to work
self.available_columns = [
@@ -33,6 +34,15 @@ class UserQuery < Query
QueryAssociationColumn.new(:auth_source, :name, caption: :field_auth_source, sortable: "#{AuthSource.table_name}.name")
]
+ def self.visible(*args)
+ user = args.shift || User.current
+ if user.admin?
+ where('1=1')
+ else
+ where('1=0')
+ end
+ end
+
def initialize(attributes=nil, *args)
super attributes
self.filters ||= { 'status' => {operator: "=", values: [User::STATUS_ACTIVE]} }
@@ -64,6 +74,14 @@ class UserQuery < Query
add_custom_fields_filters(user_custom_fields)
end
+ def visible?(user=User.current)
+ user&.admin?
+ end
+
+ def editable_by?(user)
+ user&.admin?
+ end
+
def auth_sources_values
AuthSource.order(name: :asc).to_a.map do |auth_source|
[auth_source.name, auth_source.id]
Actions