mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Improvements for not logged in users without guest mode
This commit is contained in:
parent
949d478e29
commit
ca2cea6862
@ -23,6 +23,9 @@ HumHub Change Log
|
||||
- Fix: File StorageManager setContent method broken
|
||||
- Enh: Added FileHelper methods createLink & getContentContainer
|
||||
- Enh: Javascript HumHub Client - better handle ajax redirects
|
||||
- Enh: TopMenu / TopMenuRightStack hide content when user is not logged in without guest mode
|
||||
- Enh: Added showUserName option in AccountTopMenu widget
|
||||
- Enh: Added isGuestAccessEnabled method in User component
|
||||
|
||||
1.2.0-beta.1 (February 08, 2017)
|
||||
--------------------------------
|
||||
|
@ -61,7 +61,7 @@ class User extends \yii\web\User
|
||||
|
||||
return $this->getIdentity()->guid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shortcut for getPermisisonManager()->can().
|
||||
*
|
||||
@ -75,10 +75,10 @@ class User extends \yii\web\User
|
||||
public function can($permission, $params = [], $allowCaching = true)
|
||||
{
|
||||
// Compatibility with Yii2 base permission system.
|
||||
if(is_string($permission)) {
|
||||
if (is_string($permission)) {
|
||||
return parent::can($permission, $params, $allowCaching);
|
||||
}
|
||||
|
||||
|
||||
return $this->getPermissionManager()->can($permission, $params, $allowCaching);
|
||||
}
|
||||
|
||||
@ -171,4 +171,14 @@ class User extends \yii\web\User
|
||||
parent::afterLogin($identity, $cookieBased, $duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the system configuration allows access for guests
|
||||
*
|
||||
* @return boolean is guest access enabled and allowed
|
||||
*/
|
||||
public static function isGuestAccessEnabled()
|
||||
{
|
||||
return (Yii::$app->getModule('user')->settings->get('auth.allowGuestAccess'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,8 +20,19 @@ use humhub\widgets\BaseMenu;
|
||||
class AccountTopMenu extends BaseMenu
|
||||
{
|
||||
|
||||
/**
|
||||
* @var boolean show user name
|
||||
*/
|
||||
public $showUserName = true;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public $template = "@humhub/modules/user/widgets/views/accountTopMenu";
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (Yii::$app->user->isGuest) {
|
||||
@ -74,4 +85,5 @@ class AccountTopMenu extends BaseMenu
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,15 +5,22 @@ use \yii\helpers\Url;
|
||||
?>
|
||||
<?php if (Yii::$app->user->isGuest): ?>
|
||||
<a href="#" class="btn btn-enter" data-action-click="ui.modal.load" data-action-url="<?= Url::toRoute('/user/auth/login'); ?>">
|
||||
<?= Yii::t('UserModule.widgets_views_accountTopMenu', 'Sign in / up'); ?>
|
||||
<?php if (Yii::$app->getModule('user')->settings->get('auth.anonymousRegistration')): ?>
|
||||
<?= Yii::t('UserModule.base', 'Sign in / up'); ?>
|
||||
<?php else: ?>
|
||||
<?= Yii::t('UserModule.base', 'Sign in'); ?>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<ul class="nav">
|
||||
<li class="dropdown account">
|
||||
<a href="#" id="account-dropdown-link" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<div class="user-title pull-left hidden-xs">
|
||||
<strong><?php echo Html::encode(Yii::$app->user->getIdentity()->displayName); ?></strong><br/><span class="truncate"><?= Html::encode(Yii::$app->user->getIdentity()->profile->title); ?></span>
|
||||
</div>
|
||||
|
||||
<?php if ($this->context->showUserName): ?>
|
||||
<div class="user-title pull-left hidden-xs">
|
||||
<strong><?= Html::encode(Yii::$app->user->getIdentity()->displayName); ?></strong><br/><span class="truncate"><?= Html::encode(Yii::$app->user->getIdentity()->profile->title); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<img id="user-account-image" class="img-rounded"
|
||||
src="<?= Yii::$app->user->getIdentity()->getProfileImage()->getUrl(); ?>"
|
||||
@ -28,8 +35,8 @@ use \yii\helpers\Url;
|
||||
<li class="divider"></li>
|
||||
<?php else: ?>
|
||||
<li>
|
||||
<a <?= isset($item['id']) ? 'id="'.$item['id'].'"' : '' ?> href="<?= $item['url']; ?>" <?= isset($item['pjax']) && $item['pjax'] === false ? 'data-pjax-prevent' : '' ?>>
|
||||
<?= $item['icon'] . ' ' .$item['label']; ?>
|
||||
<a <?= isset($item['id']) ? 'id="' . $item['id'] . '"' : '' ?> href="<?= $item['url']; ?>" <?= isset($item['pjax']) && $item['pjax'] === false ? 'data-pjax-prevent' : '' ?>>
|
||||
<?= $item['icon'] . ' ' . $item['label']; ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
@ -102,7 +102,7 @@ class BaseMenu extends \yii\base\Widget
|
||||
if (!isset($item['htmlOptions'])) {
|
||||
$item['htmlOptions'] = array();
|
||||
}
|
||||
|
||||
|
||||
if (!isset($item['pjax'])) {
|
||||
$item['pjax'] = true;
|
||||
}
|
||||
@ -245,6 +245,11 @@ class BaseMenu extends \yii\base\Widget
|
||||
public function run()
|
||||
{
|
||||
$this->trigger(self::EVENT_RUN);
|
||||
|
||||
if (empty($this->template)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->render($this->template, array());
|
||||
}
|
||||
|
||||
|
@ -1,29 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* HumHub
|
||||
* Copyright © 2014 The HumHub Project
|
||||
*
|
||||
* The texts of the GNU Affero General Public License with an additional
|
||||
* permission and of our proprietary license can be found at and
|
||||
* in the LICENSE file you have received along with this program.
|
||||
*
|
||||
* According to our dual licensing model, this program can be used either
|
||||
* under the terms of the GNU Affero General Public License, version 3,
|
||||
* or under a proprietary license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\widgets;
|
||||
|
||||
use Yii;
|
||||
use humhub\modules\user\components\User;
|
||||
|
||||
/**
|
||||
* TopMenuWidget is the primary top navigation class extended from MenuWidget.
|
||||
*
|
||||
* @package humhub.widgets
|
||||
* @since 0.5
|
||||
* @author Luke
|
||||
*/
|
||||
@ -31,11 +21,28 @@ class TopMenu extends BaseMenu
|
||||
{
|
||||
|
||||
/**
|
||||
* @var String template to use
|
||||
* @inheritdoc
|
||||
*/
|
||||
public $template = "topNavigation";
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public $id = 'top-menu-nav';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// Don't show top menu if guest access is disabled
|
||||
if (Yii::$app->user->isGuest && !User::isGuestAccessEnabled()) {
|
||||
$this->template = '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,33 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* HumHub
|
||||
* Copyright © 2014 The HumHub Project
|
||||
*
|
||||
* The texts of the GNU Affero General Public License with an additional
|
||||
* permission and of our proprietary license can be found at and
|
||||
* in the LICENSE file you have received along with this program.
|
||||
*
|
||||
* According to our dual licensing model, this program can be used either
|
||||
* under the terms of the GNU Affero General Public License, version 3,
|
||||
* or under a proprietary license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\widgets;
|
||||
|
||||
use Yii;
|
||||
use humhub\modules\user\components\User;
|
||||
|
||||
/**
|
||||
* TopMenuRightStackWidget holds items like search (right part)
|
||||
*
|
||||
* @package humhub.widgets
|
||||
* @since 0.6
|
||||
* @author Luke
|
||||
*/
|
||||
class TopMenuRightStack extends BaseStack
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Don't show stack if guest access is disabled and user is not logged in
|
||||
if (Yii::$app->user->isGuest && !User::isGuestAccessEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user