Skip to content

Commit

Permalink
Search only space members as participants for private calendar entry
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Feb 22, 2022
1 parent 1238ad4 commit 375f85b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions widgets/ParticipantAddForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use humhub\components\Widget;
use humhub\modules\calendar\models\CalendarEntryParticipant;
use humhub\modules\calendar\models\forms\CalendarEntryParticipationForm;
use humhub\modules\space\models\Space;
use humhub\modules\ui\form\widgets\ActiveForm;
use Yii;

Expand Down Expand Up @@ -55,9 +56,18 @@ public function run()
return '';
}

if (($this->model->entry->content->container instanceof Space) && !$this->model->entry->content->isPublic()) {
// Search only members for private Space
$searchUsersUrl = $this->model->entry->content->container->createUrl('/space/membership/search');
} else {
$searchUsersUrl = null;
}

return $this->render('participantAddForm', [
'form' => $this->form,
'model' => $this->model,
'searchUsersUrl' => $searchUsersUrl,
'addParticipantsUrl' => $this->model->entry->content->container->createUrl('/calendar/entry/add-participants')
]);
}
}
5 changes: 4 additions & 1 deletion widgets/views/participantAddForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

/* @var ActiveForm $form */
/* @var CalendarEntryParticipationForm $model */
/* @var string $searchUsersUrl */
/* @var string $addParticipantsUrl */
?>
<?= Html::beginTag('div', ['class' => 'calendar-entry-new-participants-form']) ?>
<div class="media">
Expand All @@ -23,6 +25,7 @@
'attribute' => 'newParticipants',
'placeholder' => Yii::t('AdminModule.user', 'Add new participants...'),
'options' => ['label' => false],
'url' => $searchUsersUrl,
]) ?>
</div>
<div class="media-body">
Expand All @@ -31,7 +34,7 @@
<div class="media-body">
<?= Button::info()->sm()
->icon('send')
->action('add', $model->entry->content->container->createUrl('/calendar/entry/add-participants')) ?>
->action('add', $addParticipantsUrl) ?>
</div>
</div>
<?php if ($model->entry->participation->canAddAll()) : ?>
Expand Down

0 comments on commit 375f85b

Please sign in to comment.