DEV: Add plugin_modifier for groups in users_controller#search_users (#22329)

This commit is contained in:
Mark VanLandingham
2023-06-28 14:04:22 -05:00
committed by GitHub
parent ed70b16db6
commit acaea2b5c5
2 changed files with 25 additions and 0 deletions

View File

@ -1234,6 +1234,11 @@ class UsersController < ApplicationController
groups = block.call(groups, current_user) if params[param_name.to_s]
end
# the plugin registry callbacks above are only evaluated when a param
# is present matching the name of the callback. Any modifier registered using
# register_modifier(:groups_for_users_search) will be evaluated without needing the
# param.
groups = DiscoursePluginRegistry.apply_modifier(:groups_for_users_search, groups)
groups = Group.search_groups(term, groups: groups, sort: :auto)
to_render[:groups] = groups.map { |m| { name: m.name, full_name: m.full_name } }