Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions components/ILIAS/Calendar/classes/class.ilCalendarCategoryGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ protected function initSelectedCategoryIdsFromPost(): array
return [];
}

protected function initSelectedCategoryIdFromGet(): int
{
if ($this->http->wrapper()->query()->has('selected_cat_id')) {
return $this->http->wrapper()->query()->retrieve(
'selected_cat_id',
$this->refinery->kindlyTo()->int()
);
}
return 0;
}

public function executeCommand(): void
{
$next_class = $this->ctrl->getNextClass($this);
Expand Down Expand Up @@ -333,24 +344,29 @@ protected function update(): void

protected function confirmDelete(): void
{
$cat_ids = $this->initSelectedCategoryIdsFromPost();
if (
!count($cat_ids) &&
$this->initCategoryIdFromQuery() > 0
) {
$cat_ids = [$this->initCategoryIdFromQuery()];
$selected_category_ids_from_post = $this->initSelectedCategoryIdsFromPost();
$selected_cat_id = $this->initSelectedCategoryIdFromGet();
$category_id = $this->initCategoryIdFromQuery();

if (!count($selected_category_ids_from_post)) {
if ($selected_cat_id > 0) {
$selected_category_ids_from_post = [$selected_cat_id];
} elseif ($category_id > 0) {
$selected_category_ids_from_post = [$category_id];
}
}
if (!count($cat_ids)) {
if (!count($selected_category_ids_from_post)) {
$this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
$this->manage();
return;
}
$confirmation_gui = new ilConfirmationGUI();
$confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
$confirmation_gui->setHeaderText($this->lng->txt('cal_del_cal_sure'));
$confirmation_gui->setConfirm($this->lng->txt('delete'), 'delete');
$confirmation_gui->setCancel($this->lng->txt('cancel'), 'manage');

foreach ($cat_ids as $cat_id) {
foreach ($selected_category_ids_from_post as $cat_id) {
$category = new ilCalendarCategory($cat_id);
$confirmation_gui->addItem('category_id[]', (string) $cat_id, $category->getTitle());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ protected function fillRow(array $a_set): void
$url
);
}
$this->ctrl->clearParameterByClass($this->getParentObject()::class, 'category_id');

// delete
if ($this->actions->checkDeleteCal($a_set['id'])) {
$this->ctrl->setParameter($this->getParentObject(), 'selected_cat_id', $a_set['id']);
$url = $this->ctrl->getLinkTarget($this->getParentObject(), 'confirmDelete');
$this->ctrl->clearParameterByClass($this->getParentObject()::class, 'selected_cat_id');

$dropDownItems[] = $this->ui_factory->button()->shy(
$this->lng->txt('delete'),
$url
Expand All @@ -142,8 +146,6 @@ protected function fillRow(array $a_set): void
$this->tpl->parseCurrentBlock();
}

$this->ctrl->setParameter($this->getParentObject(), 'category_id', '');

switch ($a_set['type']) {
case ilCalendarCategory::TYPE_GLOBAL:
$this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('standard/icon_calg.svg'));
Expand Down
Loading