Project

General

Profile

Actions

Maintenance #3052

closed

xmera Omnia - Collection #3083: Update to RM 5.1.7

Check user query

Added by liaham 26 days ago. Updated 22 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
03/17/2025
Due date:
03/17/2025
% Done:

100%

Estimated time:
Compatible Redmine Version:
5.1.z

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 #1

Updated by liaham 22 days ago

  • Due date set to 03/17/2025
  • Status changed from New to Closed
  • Assignee set to liaham
  • Start date set to 03/17/2025
  • % Done changed from 0 to 100
Actions #2

Updated by liaham 22 days ago

  • Parent task set to #3083
Actions

Also available in: Atom PDF