New filter ActiveQueryUser->available() (#5908)

* New filter ActiveQueryUser->available()

* Update CHANGELOG-DEV.md
This commit is contained in:
Yuriy Bakhtin 2022-10-27 15:23:14 +03:00 committed by GitHub
parent 1fae0b8ca8
commit ed9c7a1770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 7 deletions

View File

@ -11,3 +11,4 @@ HumHub Changelog
- Enh #5820: Selftest for base URL - Enh #5820: Selftest for base URL
- Enh #5891: Improve select2 width on people filters - Enh #5891: Improve select2 width on people filters
- Fix #5903: ContentContainerModule::getEnabledContentContainers() returns an empty array - Fix #5903: ContentContainerModule::getEnabledContentContainers() returns an empty array
- Enh #5908: New filter ActiveQueryUser->available()

View File

@ -63,9 +63,8 @@ class MentioningController extends Controller
// Find users // Find users
$users = User::find() $users = User::find()
->visible() ->available()
->search($keyword) ->search($keyword)
->filterBlockedUsers()
->limit($this->module->mentioningSearchBoxResultLimit) ->limit($this->module->mentioningSearchBoxResultLimit)
->orderBy(['user.last_login' => SORT_DESC]) ->orderBy(['user.last_login' => SORT_DESC])
->all(); ->all();
@ -100,9 +99,8 @@ class MentioningController extends Controller
// Find space members // Find space members
$users = Membership::getSpaceMembersQuery($space) $users = Membership::getSpaceMembersQuery($space)
->visible() ->available()
->search($keyword) ->search($keyword)
->filterBlockedUsers()
->limit($this->module->mentioningSearchBoxResultLimit) ->limit($this->module->mentioningSearchBoxResultLimit)
->orderBy(['space_membership.last_visit' => SORT_DESC]) ->orderBy(['space_membership.last_visit' => SORT_DESC])
->all(); ->all();
@ -159,7 +157,7 @@ class MentioningController extends Controller
// Find users followed to the Content // Find users followed to the Content
$users = Follow::getFollowersQuery($object, true) $users = Follow::getFollowersQuery($object, true)
->search($keyword) ->search($keyword)
->filterBlockedUsers() ->available()
->limit($this->module->mentioningSearchBoxResultLimit) ->limit($this->module->mentioningSearchBoxResultLimit)
->orderBy(['user.last_login' => SORT_DESC]) ->orderBy(['user.last_login' => SORT_DESC])
->all(); ->all();

View File

@ -307,4 +307,16 @@ class ActiveQueryUser extends ActiveQuery
return $this; 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);
}
} }

View File

@ -54,9 +54,8 @@ class PeopleQuery extends ActiveQueryUser
{ {
parent::init(); parent::init();
$this->visible(); $this->available();
$this->filterBlockedUsers();
$this->filterByKeyword(); $this->filterByKeyword();
$this->filterByGroup(); $this->filterByGroup();
$this->filterByConnection(); $this->filterByConnection();