Fix visibility members counter for guests (#6037)

* Fix visibility members counter for guests

* Display members count without link for guest
This commit is contained in:
Yuriy Bakhtin 2023-01-11 17:37:48 +04:00 committed by GitHub
parent a37e6f78ea
commit a37ef7c455
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 12 deletions

View File

@ -11,6 +11,7 @@ HumHub Changelog
- Enh #6001: Added new `ContentActiveFixture` and migrated `PostFixture` to it
- Fix #6007: Fix number of space members
- Fix #6012: View own invisible profile
- Fix #6026: Fix visibility members counter for guests
1.13.0 (December 21, 2022)
--------------------------

View File

@ -8,7 +8,9 @@
namespace humhub\modules\space\widgets;
use humhub\components\Widget;
use humhub\modules\space\models\Membership;
use humhub\modules\space\models\Space;
use Yii;
/**
* SpaceDirectoryIcons shows footer icons for spaces cards
@ -29,9 +31,17 @@ class SpaceDirectoryIcons extends Widget
*/
public function run()
{
if ($this->space->getAdvancedSettings()->hideMembers) {
return '';
}
$membership = $this->space->getMembership();
$membersCount = Membership::getSpaceMembersQuery($this->space)->active()->visible()->count();
return $this->render('spaceDirectoryIcons', [
'space' => $this->space,
'showMemberships' => !$this->space->getAdvancedSettings()->hideMembers
'membersCount' => Yii::$app->formatter->asShortInteger($membersCount),
'canViewMembers' => $membership && $membership->isPrivileged(),
]);
}

View File

@ -5,18 +5,19 @@
* @license https://www.humhub.com/licences
*/
use humhub\modules\space\models\Membership;
use humhub\modules\space\models\Space;
use yii\helpers\Url;
use yii\web\View;
use humhub\widgets\Link;
use yii\helpers\Html;
/* @var $this View */
/* @var $space Space */
/* @var $showMemberships bool */
?>
/* @var $membersCount int */
/* @var $canViewMembers bool */
<?php if ($showMemberships): ?>
<a href="#" class="fa fa-users" data-action-click="ui.modal.load"
data-action-url="<?= Url::to(['/space/membership/members-list', 'container' => $space]) ?>">
<span><?= Yii::$app->formatter->asShortInteger(Membership::getSpaceMembersQuery($space)->active()->visible()->count()) ?></span></a>
<?php endif; ?>
$text = ' <span>' . $membersCount . '</span>';
$class = 'fa fa-users';
?>
<?php if ($canViewMembers) : ?>
<?= Link::withAction($text, 'ui.modal.load', $space->createUrl('/space/membership/members-list'))->cssClass($class) ?>
<?php else: ?>
<?= Html::tag('span', $text, ['class' => $class]) ?>
<?php endif; ?>