Fix: Hide also header (space, profile) counts when following system is disabled

This commit is contained in:
Lucas Bartholemy 2017-06-09 18:55:38 +02:00
parent 3da3e6d459
commit fd1ec6205c
5 changed files with 85 additions and 81 deletions

View File

@ -21,6 +21,8 @@ HumHub Change Log
- Fix: Invite Users does not respect ManageUsers/ManageGroups permission
- Fix: Mail summaries sent in incorrect language
- Fix: Send button text on request space membership dialog
- Fix: Hide also header (space, profile) counts when following system is disabled
1.2.0 (April 16, 2017)
--------------------------------

View File

@ -8,6 +8,7 @@
namespace humhub\modules\space\widgets;
use Yii;
use yii\base\Widget;
use humhub\modules\content\models\Content;
use humhub\modules\post\models\Post;
@ -36,10 +37,11 @@ class Header extends Widget
'contentcontainer_id' => $this->space->contentContainerRecord->id
])->count();
return $this->render('header', array(
return $this->render('header', [
'space' => $this->space,
'followingEnabled' => !Yii::$app->getModule('space')->disableFollow,
'postCount' => $postCount
));
]);
}
}

View File

@ -2,7 +2,6 @@
/* @var $this \humhub\components\View */
/* @var $currentSpace \humhub\modules\space\models\Space */
use yii\helpers\Html;
if ($space->isAdmin()) {
@ -99,7 +98,7 @@ if ($space->isAdmin()) {
<?php if ($space->profileImage->hasImage()) : ?>
<!-- profile image output-->
<a data-ui-gallery="spaceHeader" href="<?= $space->profileImage->getUrl('_org'); ?>">
<?php echo \humhub\modules\space\widgets\Image::widget(['space' => $space, 'width' => 140]); ?>
<?php echo \humhub\modules\space\widgets\Image::widget(['space' => $space, 'width' => 140]); ?>
</a>
<?php else : ?>
<?php echo \humhub\modules\space\widgets\Image::widget(['space' => $space, 'width' => 140]); ?>
@ -165,35 +164,35 @@ if ($space->isAdmin()) {
<div class="statistics pull-left">
<div class="pull-left entry">
<span class="count"><?php echo $postCount; ?></span></a>
<span class="count"><?= $postCount; ?></span></a>
<br>
<span
class="title"><?php echo Yii::t('SpaceModule.widgets_views_profileHeader', 'Posts'); ?></span>
class="title"><?= Yii::t('SpaceModule.widgets_views_profileHeader', 'Posts'); ?></span>
</div>
<a href="<?= $space->createUrl('/space/membership/members-list'); ?>" data-target="#globalModal">
<div class="pull-left entry">
<span class="count"><?php echo $space->getMemberships()->count(); ?></span>
<span class="count"><?= $space->getMemberships()->count(); ?></span>
<br>
<span
class="title"><?php echo Yii::t('SpaceModule.widgets_views_profileHeader', 'Members'); ?></span>
class="title"><?= Yii::t('SpaceModule.widgets_views_profileHeader', 'Members'); ?></span>
</div>
</a>
<a href="<?= $space->createUrl('/space/space/follower-list'); ?>" data-target="#globalModal">
<div class="pull-left entry">
<span class="count"><?php echo $space->getFollowerCount(); ?></span><br>
<span
class="title"><?php echo Yii::t('SpaceModule.widgets_views_profileHeader', 'Followers'); ?></span>
</div>
</a>
<?php if ($followingEnabled): ?>
<a href="<?= $space->createUrl('/space/space/follower-list'); ?>" data-target="#globalModal">
<div class="pull-left entry">
<span class="count"><?= $space->getFollowerCount(); ?></span><br>
<span
class="title"><?= Yii::t('SpaceModule.widgets_views_profileHeader', 'Followers'); ?></span>
</div>
</a>
<?php endif; ?>
</div>
<!-- end: User statistics -->
<div class="controls controls-header pull-right">
<?php
echo humhub\modules\space\widgets\HeaderControls::widget(['widgets' => [
<?=
humhub\modules\space\widgets\HeaderControls::widget(['widgets' => [
[\humhub\modules\space\widgets\InviteButton::className(), ['space' => $space], ['sortOrder' => 10]],
[\humhub\modules\space\widgets\MembershipButton::className(), ['space' => $space], ['sortOrder' => 20]],
[\humhub\modules\space\widgets\FollowButton::className(), [

View File

@ -74,6 +74,7 @@ class ProfileHeader extends \yii\base\Widget
'user' => $this->user,
'isProfileOwner' => $this->isProfileOwner,
'friendshipsEnabled' => $friendshipsEnabled,
'followingEnabled' => !Yii::$app->getModule('user')->disableFollow,
'countFriends' => $countFriends,
'countFollowers' => $this->user->getFollowerCount(),
'countFollowing' => $countFollowing,

View File

@ -71,22 +71,22 @@ if ($allowModifyProfileBanner || $allowModifyProfileImage) {
class="btn btn-info btn-sm" data-target="#globalModal" data-backdrop="static" aria-label="<?= Yii::t('UserModule.base', 'Crop profile background'); ?>">
<i class="fa fa-edit"></i>
</a>
<?php
echo \humhub\widgets\ModalConfirm::widget(array(
'uniqueID' => 'modal_bannerimagedelete',
'linkOutput' => 'a',
'ariaLabel' => Yii::t('UserModule.widgets_views_deleteBanner', 'Delete profile banner'),
'title' => Yii::t('UserModule.widgets_views_deleteBanner', '<strong>Confirm</strong> image deleting'),
'message' => Yii::t('UserModule.widgets_views_deleteBanner', 'Do you really want to delete your title image?'),
'buttonTrue' => Yii::t('UserModule.widgets_views_deleteBanner', 'Delete'),
'buttonFalse' => Yii::t('UserModule.widgets_views_deleteBanner', 'Cancel'),
'linkContent' => '<i class="fa fa-times"></i>',
'cssClass' => 'btn btn-danger btn-sm',
'style' => $user->getProfileBannerImage()->hasImage() ? '' : 'display: none;',
'linkHref' => Url::to(['/user/image/delete', 'userGuid' => $user->guid, 'type' => ImageController::TYPE_PROFILE_BANNER_IMAGE]),
'confirmJS' => 'function(jsonResp) { resetProfileImage(jsonResp); }'
));
?>
<?php
echo \humhub\widgets\ModalConfirm::widget([
'uniqueID' => 'modal_bannerimagedelete',
'linkOutput' => 'a',
'ariaLabel' => Yii::t('UserModule.widgets_views_deleteBanner', 'Delete profile banner'),
'title' => Yii::t('UserModule.widgets_views_deleteBanner', '<strong>Confirm</strong> image deleting'),
'message' => Yii::t('UserModule.widgets_views_deleteBanner', 'Do you really want to delete your title image?'),
'buttonTrue' => Yii::t('UserModule.widgets_views_deleteBanner', 'Delete'),
'buttonFalse' => Yii::t('UserModule.widgets_views_deleteBanner', 'Cancel'),
'linkContent' => '<i class="fa fa-times"></i>',
'cssClass' => 'btn btn-danger btn-sm',
'style' => $user->getProfileBannerImage()->hasImage() ? '' : 'display: none;',
'linkHref' => Url::to(['/user/image/delete', 'userGuid' => $user->guid, 'type' => ImageController::TYPE_PROFILE_BANNER_IMAGE]),
'confirmJS' => 'function(jsonResp) { resetProfileImage(jsonResp); }'
]);
?>
</div>
<?php endif; ?>
</div>
@ -133,23 +133,23 @@ if ($allowModifyProfileBanner || $allowModifyProfileImage) {
?>"
href="<?php echo Url::to(['/user/image/crop', 'userGuid' => $user->guid, 'type' => ImageController::TYPE_PROFILE_IMAGE]); ?>"
class="btn btn-info btn-sm" data-target="#globalModal" data-backdrop="static" aria-label="<?= Yii::t('UserModule.base', 'Crop profile image'); ?>">
<i class="fa fa-edit"></i></a>
<?php
echo \humhub\widgets\ModalConfirm::widget(array(
'uniqueID' => 'modal_profileimagedelete',
'linkOutput' => 'a',
'ariaLabel' => Yii::t('UserModule.base', 'Delete profile image'),
'title' => Yii::t('UserModule.widgets_views_deleteImage', '<strong>Confirm</strong> image deleting'),
'message' => Yii::t('UserModule.widgets_views_deleteImage', 'Do you really want to delete your profile image?'),
'buttonTrue' => Yii::t('UserModule.widgets_views_deleteImage', 'Delete'),
'buttonFalse' => Yii::t('UserModule.widgets_views_deleteImage', 'Cancel'),
'linkContent' => '<i class="fa fa-times"></i>',
'cssClass' => 'btn btn-danger btn-sm',
'style' => $user->getProfileImage()->hasImage() ? '' : 'display: none;',
'linkHref' => Url::to(["/user/image/delete", 'type' => ImageController::TYPE_PROFILE_IMAGE, 'userGuid' => $user->guid]),
'confirmJS' => 'function(jsonResp) { resetProfileImage(jsonResp); }'
));
?>
<i class="fa fa-edit"></i></a>
<?php
echo \humhub\widgets\ModalConfirm::widget(array(
'uniqueID' => 'modal_profileimagedelete',
'linkOutput' => 'a',
'ariaLabel' => Yii::t('UserModule.base', 'Delete profile image'),
'title' => Yii::t('UserModule.widgets_views_deleteImage', '<strong>Confirm</strong> image deleting'),
'message' => Yii::t('UserModule.widgets_views_deleteImage', 'Do you really want to delete your profile image?'),
'buttonTrue' => Yii::t('UserModule.widgets_views_deleteImage', 'Delete'),
'buttonFalse' => Yii::t('UserModule.widgets_views_deleteImage', 'Cancel'),
'linkContent' => '<i class="fa fa-times"></i>',
'cssClass' => 'btn btn-danger btn-sm',
'style' => $user->getProfileImage()->hasImage() ? '' : 'display: none;',
'linkHref' => Url::to(["/user/image/delete", 'type' => ImageController::TYPE_PROFILE_IMAGE, 'userGuid' => $user->guid]),
'confirmJS' => 'function(jsonResp) { resetProfileImage(jsonResp); }'
));
?>
</div>
<?php endif; ?>
@ -169,47 +169,47 @@ if ($allowModifyProfileBanner || $allowModifyProfileImage) {
<?php if ($friendshipsEnabled): ?>
<a href="<?= Url::to(['/friendship/list/popup', 'userId' => $user->id]); ?>" data-target="#globalModal">
<div class="pull-left entry">
<span class="count"><?php echo $countFriends; ?></span>
<span class="count"><?= $countFriends; ?></span>
<br>
<span class="title"><?php echo Yii::t('UserModule.widgets_views_profileHeader', 'Friends'); ?></span>
<span class="title"><?= Yii::t('UserModule.widgets_views_profileHeader', 'Friends'); ?></span>
</div>
</a>
<?php endif; ?>
<?php if ($followingEnabled): ?>
<a href="<?= $user->createUrl('/user/profile/follower-list'); ?>" data-target="#globalModal">
<div class="pull-left entry">
<span class="count"><?= $countFollowers; ?></span>
<br>
<span class="title"><?= Yii::t('UserModule.widgets_views_profileHeader', 'Followers'); ?></span>
</div>
</a>
<a href="<?= $user->createUrl('/user/profile/followed-users-list'); ?>" data-target="#globalModal">
<div class="pull-left entry">
<span class="count"><?= $countFollowing; ?></span>
<br>
<span class="title"><?= Yii::t('UserModule.widgets_views_profileHeader', 'Following'); ?></span>
</div>
</a>
<?php endif; ?>
<a href="<?= $user->createUrl('/user/profile/follower-list'); ?>" data-target="#globalModal">
<div class="pull-left entry">
<span class="count"><?php echo $countFollowers; ?></span>
<br>
<span class="title"><?php echo Yii::t('UserModule.widgets_views_profileHeader', 'Followers'); ?></span>
</div>
</a>
<a href="<?= $user->createUrl('/user/profile/followed-users-list'); ?>" data-target="#globalModal">
<div class="pull-left entry">
<span class="count"><?php echo $countFollowing; ?></span>
<br>
<span class="title"><?php echo Yii::t('UserModule.widgets_views_profileHeader', 'Following'); ?></span>
</div>
</a>
<a href="<?= $user->createUrl('/user/profile/space-membership-list'); ?>" data-target="#globalModal">
<div class="pull-left entry">
<span class="count"><?php echo $countSpaces; ?></span><br>
<span class="title"><?php echo Yii::t('UserModule.widgets_views_profileHeader', 'Spaces'); ?></span>
<span class="count"><?= $countSpaces; ?></span><br>
<span class="title"><?= Yii::t('UserModule.widgets_views_profileHeader', 'Spaces'); ?></span>
</div>
</a>
</div>
<!-- end: User statistics -->
<div class="controls controls-header pull-right">
<?php
echo \humhub\modules\user\widgets\ProfileHeaderControls::widget(
array(
'user' => $user,
'widgets' => array(
array(\humhub\modules\user\widgets\ProfileEditButton::className(), array('user' => $user), array()),
array(\humhub\modules\user\widgets\UserFollowButton::className(), array('user' => $user), array()),
array(\humhub\modules\friendship\widgets\FriendshipButton::className(), array('user' => $user), array()),
)
));
<?=
humhub\modules\user\widgets\ProfileHeaderControls::widget([
'user' => $user,
'widgets' => [
[\humhub\modules\user\widgets\ProfileEditButton::className(), ['user' => $user], []],
[\humhub\modules\user\widgets\UserFollowButton::className(), ['user' => $user], []],
[\humhub\modules\friendship\widgets\FriendshipButton::className(), ['user' => $user], []],
]
]);
?>
</div>
</div>