diff --git a/components/ILIAS/Calendar/classes/class.ilCalendarCategoryGUI.php b/components/ILIAS/Calendar/classes/class.ilCalendarCategoryGUI.php index 915e231ede82..6305586c1a78 100755 --- a/components/ILIAS/Calendar/classes/class.ilCalendarCategoryGUI.php +++ b/components/ILIAS/Calendar/classes/class.ilCalendarCategoryGUI.php @@ -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); @@ -333,16 +344,21 @@ 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)); @@ -350,7 +366,7 @@ protected function confirmDelete(): void $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()); } diff --git a/components/ILIAS/Calendar/classes/class.ilCalendarManageTableGUI.php b/components/ILIAS/Calendar/classes/class.ilCalendarManageTableGUI.php index b196fea95d68..ab7747347658 100755 --- a/components/ILIAS/Calendar/classes/class.ilCalendarManageTableGUI.php +++ b/components/ILIAS/Calendar/classes/class.ilCalendarManageTableGUI.php @@ -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 @@ -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'));