mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Count all active and non-invisible members for guests on space directory (#6162)
This commit is contained in:
parent
569992aba5
commit
448f4ee2bb
@ -10,6 +10,7 @@ namespace humhub\modules\space\widgets;
|
||||
use humhub\components\Widget;
|
||||
use humhub\modules\space\models\Membership;
|
||||
use humhub\modules\space\models\Space;
|
||||
use humhub\modules\user\models\User;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
@ -36,11 +37,16 @@ class SpaceDirectoryIcons extends Widget
|
||||
}
|
||||
|
||||
$membership = $this->space->getMembership();
|
||||
$membersCount = Membership::getSpaceMembersQuery($this->space)->active()->visible()->count();
|
||||
$membersCountQuery = Membership::getSpaceMembersQuery($this->space)->active();
|
||||
if (Yii::$app->user->isGuest) {
|
||||
$membersCountQuery->andWhere(['!=', 'user.visibility', User::VISIBILITY_HIDDEN]);
|
||||
} else {
|
||||
$membersCountQuery->visible();
|
||||
}
|
||||
|
||||
return $this->render('spaceDirectoryIcons', [
|
||||
'space' => $this->space,
|
||||
'membersCount' => Yii::$app->formatter->asShortInteger($membersCount),
|
||||
'membersCount' => Yii::$app->formatter->asShortInteger($membersCountQuery->count()),
|
||||
'canViewMembers' => $membership && $membership->isPrivileged(),
|
||||
]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user