Skip to content

Commit

Permalink
Badges: Fix missing badge id in "Pagination" of data table
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansenDatabay committed Jan 10, 2025
1 parent 802c6f8 commit b60022f
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions components/ILIAS/Badge/classes/class.ilBadgeManagementGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,59 +802,66 @@ protected function listUsers(): void
$drop->setOptions($manual);
$ilToolbar->addInputItem($drop, true);

$ilToolbar->setFormAction($ilCtrl->getFormAction($this, 'awardBadgeUserSelection'));
$ilToolbar->addFormButton($lng->txt('badge_award_badge'), 'awardBadgeUserSelection');
$ilToolbar->setFormAction($ilCtrl->getFormAction($this, 'selectBadgeForAwardingOrRevoking'));
$ilToolbar->addFormButton($lng->txt('badge_award_badge'), 'selectBadgeForAwardingOrRevoking');
}
}

$tbl = new ilBadgeUserTableGUI($this->parent_ref_id);
$tbl->renderTable();
}

private function selectBadgeForAwardingOrRevoking(): never
{
$this->ctrl->setParameter(
$this,
'bid',
$this->http->wrapper()->post()->retrieve('bid', $this->refinery->kindlyTo()->int())
);
$this->ctrl->redirect($this, 'awardBadgeUserSelection');
}

protected function awardBadgeUserSelection(): void
{
$ilCtrl = $this->ctrl;
$ilTabs = $this->tabs;
$lng = $this->lng;

$badge_ids = $this->request->getMultiActionBadgeIdsFromUrl();
$bid = null;

if ($badge_ids === []) {
$post = $this->http->wrapper()->post();
if ($post->has('bid')) {
$bid = $post->retrieve('bid', $this->refinery->kindlyTo()->int());
if ($this->http->wrapper()->post()->has('bid')) {
$bid = $this->http->wrapper()->post()->retrieve('bid', $this->refinery->kindlyTo()->int());
} elseif ($this->http->wrapper()->query()->has('bid')) {
$bid = $this->http->wrapper()->query()->retrieve('bid', $this->refinery->kindlyTo()->int());
}
} elseif (count($badge_ids) === 1) {
$bid = (int) $badge_ids[0];
}

if (!$bid ||
!$this->hasWrite()) {
$ilCtrl->redirect($this, 'listUsers');
$this->ctrl->redirect($this, 'listUsers');
}

$manual = array_keys(
ilBadgeHandler::getInstance()->getAvailableManualBadges($this->parent_obj_id, $this->parent_obj_type)
);

if (!in_array($bid, $manual, true)) {
$ilCtrl->redirect($this, 'listUsers');
$this->ctrl->redirect($this, 'listUsers');
}

$back_target = 'listUsers';
if ($this->request->getTgt() === 'bdgl') {
$ilCtrl->saveParameter($this, 'tgt');
$this->ctrl->saveParameter($this, 'tgt');
$back_target = 'listBadges';
}

$ilTabs->clearTargets();
$ilTabs->setBackTarget(
$lng->txt('back'),
$ilCtrl->getLinkTarget($this, $back_target)
$this->tabs->clearTargets();
$this->tabs->setBackTarget(
$this->lng->txt('back'),
$this->ctrl->getLinkTarget($this, $back_target)
);

$ilCtrl->setParameter($this, 'bid', $bid);
$this->ctrl->setParameter($this, 'bid', $bid);

$badge = new ilBadge($bid);

Expand Down

0 comments on commit b60022f

Please sign in to comment.