Skip to content

Commit

Permalink
Fix #437: Hide the profile calendar if the module is not available fo…
Browse files Browse the repository at this point in the history
…r users
  • Loading branch information
marc-farre committed Jan 12, 2024
1 parent 2425ba8 commit c8dee26
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
13 changes: 7 additions & 6 deletions controllers/GlobalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,7 +22,6 @@
use humhub\widgets\ModalButton;
use humhub\widgets\ModalDialog;
use Yii;
use humhub\modules\calendar\helpers\Url;
use yii\web\HttpException;

/**
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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', []);
Expand Down
3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
--------------------------
Expand All @@ -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

Expand Down
32 changes: 23 additions & 9 deletions views/global/selectContainerModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

?>

<?php ModalDialog::begin(['header' => Yii::t('CalendarModule.base', '<strong>Choose</strong> target calendar'), 'size' => 'small'])?>
<?php $form = ActiveForm::begin()?>
<div class="modal-body">
<?= Html::dropDownList('contentContainerId', null, $contentContainerSelection, ['class' => 'form-control', 'data-ui-select2' => ''])?>
</div>
<div class="modal-footer">
<?= ModalButton::submitModal($submitUrl, Yii::t('CalendarModule.base', 'Next'))?>
<?php ModalDialog::begin(['header' => Yii::t('CalendarModule.base', '<strong>Choose</strong> target calendar'), 'size' => 'small']) ?>
<?php if ($contentContainerSelection): ?>
<?php $form = ActiveForm::begin() ?>
<div class="modal-body">
<?= Html::dropDownList('contentContainerId', null, $contentContainerSelection, ['class' => 'form-control', 'data-ui-select2' => '']) ?>
</div>
<div class="modal-footer">
<?= ModalButton::submitModal($submitUrl, Yii::t('CalendarModule.base', 'Next')) ?>
</div>
<?php $form = ActiveForm::end() ?>

<?php else: ?>
<div class="modal-body">
<div class="alert alert-danger">
<strong>
<?= Yii::t('CalendarModule.base', 'Please first enable the calendar module in a space!') ?>
</strong>
</div>
<?php $form = ActiveForm::end()?>
</div>
<div class="modal-footer">
<?= ModalButton::cancel(Yii::t('base', 'Close')) ?>
</div>
<?php endif; ?>
<?php ModalDialog::end() ?>

0 comments on commit c8dee26

Please sign in to comment.