diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 98c70e0b4..7ebf7435d 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -467,7 +467,8 @@ class CoursesController < ApplicationController # user_ids_of_course_members = @course.course_members.where(role: [1,2,3]).pluck(:user_id) # @users = User.where.not(id: user_ids_of_course_members) - @users = User.where(status: User::STATUS_ACTIVE, laboratory_id: @course.laboratory_id) + @users = User.where(status: User::STATUS_ACTIVE) + @users = @users.where(laboratory_id: current_laboratory.id) unless current_laboratory.main_site? @users = @users.where("concat(users.lastname, users.firstname) like '%#{name}%'") if name.present? # REDO:Extension @users = @users.joins(user_extension: :school).where("schools.name like '%#{school_name}%'") if school_name.present? @@ -1083,7 +1084,8 @@ class CoursesController < ApplicationController school_name = params[:school_name] # REDO:Extension - @users = User.where(status: User::STATUS_ACTIVE, laboratory_id: @course.laboratory_id) + @users = User.where(status: User::STATUS_ACTIVE) + @users = @users.where(laboratory_id: current_laboratory.id) unless current_laboratory.main_site? @users = @users.where("concat(users.lastname, users.firstname) like '%#{name}%'") if name.present? # REDO:Extension @users = @users.joins(user_extension: :school).where("schools.name like '%#{school_name}%'") if school_name.present? diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 619d2c8a7..9077192cf 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -919,6 +919,7 @@ class ShixunsController < ApplicationController else @users = User.none end + @users = @users.where(laboratory_id: current_laboratory.id) unless current_laboratory.main_site? page = params[:page] || 1 limit = params[:limit] || 20 @user_count = @users.count diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 25cf93faa..d4f1281a2 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -302,6 +302,7 @@ class SubjectsController < ApplicationController member_ids = @subject.subject_members.map(&:user_id).join(',') condition = "%#{params[:search].strip}%".gsub(" ","") @users = User.where("id not in (?) and status = 1 and LOWER(concat(lastname, ifnull(firstname, ''), login)) LIKE ?", member_ids, "#{condition}") + @users = @users.where(laboratory_id: current_laboratory.id) unless current_laboratory.main_site? @users = @users.page(page).per(10) @users = @users.includes(:user_extension) diff --git a/app/controllers/users/recent_contacts_controller.rb b/app/controllers/users/recent_contacts_controller.rb index ea8e005d1..2576385b2 100644 --- a/app/controllers/users/recent_contacts_controller.rb +++ b/app/controllers/users/recent_contacts_controller.rb @@ -3,6 +3,7 @@ class Users::RecentContactsController < Users::BaseController def index contacts = observed_user.recent_contacts.distinct - @contacts = contacts.where(laboratory_id: current_laboratory.id).order('private_messages.created_at DESC').limit(10).includes(:user_extension) + contacts = contacts.where(laboratory_id: current_laboratory.id) unless current_laboratory.main_site? + @contacts = contacts.order('private_messages.created_at DESC').limit(10).includes(:user_extension) end end \ No newline at end of file diff --git a/app/controllers/users_for_private_messages_controller.rb b/app/controllers/users_for_private_messages_controller.rb index 1caf52a6c..610bf5d52 100644 --- a/app/controllers/users_for_private_messages_controller.rb +++ b/app/controllers/users_for_private_messages_controller.rb @@ -2,7 +2,8 @@ class UsersForPrivateMessagesController < ApplicationController before_action :require_login, :check_auth def index - users = User.active.where.not(id: current_user.id).where(laboratory_id: current_laboratory.id) + users = User.active.where.not(id: current_user.id) + users = users.where(laboratory_id: current_laboratory.id) unless current_laboratory.main_site? keyword = params[:keyword].to_s.strip if keyword.blank?