From c8dee2603e8d592619af57c59fd31431d2639fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Farr=C3=A9?= Date: Fri, 12 Jan 2024 10:19:55 +0100 Subject: [PATCH] Fix #437: Hide the profile calendar if the module is not available for users --- controllers/GlobalController.php | 13 ++++++----- docs/CHANGELOG.md | 3 ++- views/global/selectContainerModal.php | 32 +++++++++++++++++++-------- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/controllers/GlobalController.php b/controllers/GlobalController.php index a253bc94..eea0c4e8 100644 --- a/controllers/GlobalController.php +++ b/controllers/GlobalController.php @@ -5,13 +5,13 @@ use DateTime; use humhub\components\Controller; use humhub\modules\calendar\helpers\CalendarUtils; +use humhub\modules\calendar\helpers\Url; use humhub\modules\calendar\interfaces\CalendarService; use humhub\modules\calendar\interfaces\recurrence\RecurrenceFormModel; use humhub\modules\calendar\models\CalendarEntry; use humhub\modules\calendar\models\CalendarEntryDummy; use humhub\modules\calendar\models\fullcalendar\FullCalendar; use humhub\modules\calendar\models\SnippetModuleSettings; -use humhub\modules\calendar\permissions\CreateEntry; use humhub\modules\calendar\widgets\FilterType; use humhub\modules\content\components\ContentContainerModuleManager; use humhub\modules\content\models\ContentContainer; @@ -22,7 +22,6 @@ use humhub\widgets\ModalButton; use humhub\widgets\ModalDialog; use Yii; -use humhub\modules\calendar\helpers\Url; use yii\web\HttpException; /** @@ -95,16 +94,18 @@ public function actionSelect($start = null, $end = null) $contentContainerSelection = []; $user = Yii::$app->user->getIdentity(); - $contentContainerSelection[$user->contentcontainer_id] = Yii::t('CalendarModule.base', 'Profile Calendar'); + if ($user->moduleManager->canEnable('calendar')) { + $contentContainerSelection[$user->contentcontainer_id] = Yii::t('CalendarModule.base', 'Profile Calendar'); + } $calendarMemberSpaceQuery = Membership::getUserSpaceQuery(Yii::$app->user->getIdentity()); - if(!ContentContainerModuleManager::getDefaultState(Space::class, 'calendar')) { + if (!ContentContainerModuleManager::getDefaultState(Space::class, 'calendar')) { $calendarMemberSpaceQuery->leftJoin('contentcontainer_module', 'contentcontainer_module.module_id = :calendar AND contentcontainer_module.contentcontainer_id = space.contentcontainer_id', [':calendar' => 'calendar'] )->andWhere('contentcontainer_module.module_id IS NOT NULL') - ->andWhere(['contentcontainer_module.module_state' => ContentContainerModuleState::STATE_ENABLED]); + ->andWhere(['contentcontainer_module.module_state' => ContentContainerModuleState::STATE_ENABLED]); } foreach ($calendarMemberSpaceQuery->all() as $space) { @@ -214,7 +215,7 @@ public function actionLoadAjax($start, $end) $output = []; if (!Yii::$app->user->isGuest) { - $settings = $this->getUserSettings(); + $settings = $this->getUserSettings(); $selectors = Yii::$app->request->get('selectors', []); $filters = Yii::$app->request->get('filters', []); diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 53f788a9..95367ebb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,7 @@ Changelog 1.5.7 (Unreleased) -------------------------- - Fix #433: Fix memory usage on integrity check +- Fix #437: Hide the profile calendar if the module is not available for users 1.5.6 (October 26, 2023) -------------------------- @@ -13,7 +14,7 @@ Changelog ------------------------- - Enh #424: Tests for `next` version - Enh #423: Add Create Button -- Fix #419: Don't use loader for wall entry menu on open modal window +- Fix #419: Don't use loader for wall entry menu on open modal window - Enh #379: Allow managing of global event types from container side - Enh #382: Allow inviting by users who can manage a calendar entry diff --git a/views/global/selectContainerModal.php b/views/global/selectContainerModal.php index d9bfd47c..54768340 100644 --- a/views/global/selectContainerModal.php +++ b/views/global/selectContainerModal.php @@ -6,23 +6,37 @@ * */ +use humhub\libs\Html; use humhub\widgets\ModalButton; use humhub\widgets\ModalDialog; use yii\bootstrap\ActiveForm; -use humhub\libs\Html; /* @var $contentContainerSelection array */ /* @var $submitUrl array */ ?> - Yii::t('CalendarModule.base', 'Choose target calendar'), 'size' => 'small'])?> - - -