diff --git a/CHANGELOG-DEV.md b/CHANGELOG-DEV.md index 92014d8da3..522d293974 100644 --- a/CHANGELOG-DEV.md +++ b/CHANGELOG-DEV.md @@ -11,3 +11,4 @@ HumHub Changelog - Enh #5820: Selftest for base URL - Enh #5891: Improve select2 width on people filters - Fix #5903: ContentContainerModule::getEnabledContentContainers() returns an empty array +- Enh #5908: New filter ActiveQueryUser->available() diff --git a/protected/humhub/modules/search/controllers/MentioningController.php b/protected/humhub/modules/search/controllers/MentioningController.php index 30b9732b82..ab6b6d8cb8 100644 --- a/protected/humhub/modules/search/controllers/MentioningController.php +++ b/protected/humhub/modules/search/controllers/MentioningController.php @@ -63,9 +63,8 @@ class MentioningController extends Controller // Find users $users = User::find() - ->visible() + ->available() ->search($keyword) - ->filterBlockedUsers() ->limit($this->module->mentioningSearchBoxResultLimit) ->orderBy(['user.last_login' => SORT_DESC]) ->all(); @@ -100,9 +99,8 @@ class MentioningController extends Controller // Find space members $users = Membership::getSpaceMembersQuery($space) - ->visible() + ->available() ->search($keyword) - ->filterBlockedUsers() ->limit($this->module->mentioningSearchBoxResultLimit) ->orderBy(['space_membership.last_visit' => SORT_DESC]) ->all(); @@ -159,7 +157,7 @@ class MentioningController extends Controller // Find users followed to the Content $users = Follow::getFollowersQuery($object, true) ->search($keyword) - ->filterBlockedUsers() + ->available() ->limit($this->module->mentioningSearchBoxResultLimit) ->orderBy(['user.last_login' => SORT_DESC]) ->all(); diff --git a/protected/humhub/modules/user/components/ActiveQueryUser.php b/protected/humhub/modules/user/components/ActiveQueryUser.php index b87533d338..57b8c8d2ed 100644 --- a/protected/humhub/modules/user/components/ActiveQueryUser.php +++ b/protected/humhub/modules/user/components/ActiveQueryUser.php @@ -307,4 +307,16 @@ class ActiveQueryUser extends ActiveQuery return $this; } + /** + * Filter users which are available for the given $user or for the current User + * + * @since 1.13 + * @param UserModel|null $user + * @return ActiveQueryUser + */ + public function available(?UserModel $user = null): ActiveQueryUser + { + return $this->visible()->filterBlockedUsers($user); + } + } diff --git a/protected/humhub/modules/user/components/PeopleQuery.php b/protected/humhub/modules/user/components/PeopleQuery.php index a7d3bf78c9..75871fd772 100644 --- a/protected/humhub/modules/user/components/PeopleQuery.php +++ b/protected/humhub/modules/user/components/PeopleQuery.php @@ -54,9 +54,8 @@ class PeopleQuery extends ActiveQueryUser { parent::init(); - $this->visible(); + $this->available(); - $this->filterBlockedUsers(); $this->filterByKeyword(); $this->filterByGroup(); $this->filterByConnection();