42 private readonly \ILIAS\HTTP\GlobalHttpState
$http;
50 $this->
ctrl = $DIC->ctrl();
51 $this->
lng = $DIC->language();
52 $this->tpl =
$DIC[
'tpl'];
53 $this->
tabs = $DIC->tabs();
54 $this->
user = $DIC->user();
56 $this->
http = $DIC->http();
74 $this->
lng->loadLanguageModule(
'badge');
76 switch ($this->
ctrl->getNextClass()) {
78 $cmd = $this->
ctrl->getCmd(self::DEFAULT_ACTION);
79 if ($cmd ===
'' || $cmd ===
null || !method_exists($this, $cmd .
'Cmd')) {
96 return $this->
http->wrapper()->query()->retrieve(
99 $this->refinery->kindlyTo()->string(),
100 $this->refinery->always(
null)
108 'obj_badge_activate' => $this->
activate(),
109 'obj_badge_deactivate' => $this->
deactivate(),
110 default => $this->
ctrl->redirect($this, self::DEFAULT_ACTION),
121 $this->tpl->setContent($this->
renderDeck($this->tile_view->show()));
122 $this->noti_repo->updateLastCheckedTimestamp();
127 $template =
new ilTemplate(
'tpl.badge_backpack.html',
true,
true,
'components/ILIAS/Badge/');
128 $template->setVariable(
'DECK', $deck);
129 return $template->get();
135 $tpl->renderTable(ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this, self::TABLE_ACTIONS));
140 $badge_ids = array_filter(
141 $this->
http->wrapper()->query()->retrieve(
143 $this->refinery->byTrying([
144 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
145 $this->refinery->always([])
150 if ($badge_ids === [self::TABLE_ALL_OBJECTS_ACTION]) {
151 $badge_assignments = array_filter(
156 $badge_assignments = array_filter(
162 $this->request->getBadgeIds()
168 if (!empty($badge_assignments)) {
169 return $badge_assignments;
172 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->
lng->txt(
'select_one'),
true);
173 $this->
ctrl->redirect($this, self::MANAGE_BADGES_ACTION);
180 if (!$ass->getPosition()) {
181 $ass->setPosition(999);
186 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'position_updated'),
true);
187 $this->
ctrl->redirect($this, self::MANAGE_BADGES_ACTION);
194 if ($ass->getPosition()) {
195 $ass->setPosition(
null);
200 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'position_updated'),
true);
201 $this->
ctrl->redirect($this, self::MANAGE_BADGES_ACTION);
208 if (!$ass->getPosition()) {
209 $ass->setPosition(999);
214 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'position_updated'),
true);
215 $this->
ctrl->redirect($this, self::LIST_BADGES_ACTION);
222 if ($ass->getPosition()) {
223 $ass->setPosition(
null);
228 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'position_updated'),
true);
229 $this->
ctrl->redirect($this, self::LIST_BADGES_ACTION);
234 $this->
tabs->addSubTab(
236 $this->
lng->txt(
'obj_bdga'),
237 $this->ctrl->getLinkTarget($this,
'listBackpackGroups')
240 $this->
tabs->addSubTab(
242 $this->
lng->txt(
'settings'),
243 $this->ctrl->getLinkTarget($this,
'editSettings')
246 $this->
tabs->activateTab(
'backpack_badges');
252 $this->
tabs->activateSubTab(
'backpack_badges');
254 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->
lng->txt(
'badge_backpack_gallery_info'));
257 $bp_groups = $bp->getGroups();
259 if (!count($bp_groups)) {
260 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->
lng->txt(
'badge_backpack_no_groups'));
264 $tmpl =
new ilTemplate(
'tpl.badge_backpack.html',
true,
true,
'components/ILIAS/Badge/');
266 $tmpl->setVariable(
'BACKPACK_TITLE', $this->
lng->txt(
'badge_backpack_list'));
270 foreach ($bp_groups as $group_id => $group) {
271 $bp_badges = $bp->getBadges($group_id);
272 if (count($bp_badges)) {
273 foreach ($bp_badges as $badge) {
274 $tmpl->setCurrentBlock(
'badge_bl');
275 $tmpl->setVariable(
'BADGE_TITLE', $badge[
'title']);
276 $tmpl->setVariable(
'BADGE_DESC', $badge[
'description']);
277 $tmpl->setVariable(
'BADGE_IMAGE', $badge[
'image_url']);
278 $tmpl->setVariable(
'BADGE_CRITERIA', $badge[
'criteria_url']);
279 $tmpl->setVariable(
'BADGE_ISSUER', $badge[
'issuer_name']);
280 $tmpl->setVariable(
'BADGE_ISSUER_URL', $badge[
'issuer_url']);
282 $tmpl->parseCurrentBlock();
286 $tmpl->setCurrentBlock(
'group_bl');
287 $tmpl->setVariable(
'GROUP_TITLE', $group[
'title']);
288 $tmpl->parseCurrentBlock();
291 $this->tpl->setContent($tmpl->get());
300 $mail = $this->
user->getPref(self::BACKPACK_EMAIL);
302 $mail = $this->
user->getEmail();
311 $form->setFormAction($this->
ctrl->getFormAction($this,
'saveSettings'));
312 $form->setTitle($this->
lng->txt(
'settings'));
315 $email->setInfo($this->
lng->txt(
'badge_backpack_email_info'));
317 $form->addItem($email);
319 $form->addCommandButton(
'saveSettings', $this->
lng->txt(
'save'));
326 $this->
ctrl->redirect($this, self::LIST_BADGES_ACTION);
332 if ($form->checkInput()) {
333 $new_email = $form->getInput(
'email');
336 $this->
user->writePref(self::BACKPACK_EMAIL, $new_email);
339 if ($new_email !== $old_email) {
343 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'settings_saved'),
true);
344 $this->
ctrl->redirect($this,
'editSettings');
347 $form->setValuesByPost();
Badge notification repository (using user preferences.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static clearBadgeCache(int $a_user_id)
static getInstancesByUserId(int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly BadgeNotificationPrefRepository $noti_repo
readonly ILIAS HTTP GlobalHttpState $http
getSafePostCommands()
This method must return a list of safe POST commands.
readonly ilGlobalTemplateInterface $tpl
const string LIST_BADGES_ACTION
const string TABLE_ALL_OBJECTS_ACTION
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
final const string BACKPACK_EMAIL
const string MANAGE_BADGES_ACTION
const string TABLE_ACTIONS
readonly ilCtrlInterface $ctrl
readonly ilBadgeGUIRequest $request
const string DEFAULT_ACTION
readonly ILIAS Refinery Factory $refinery
editSettingsCmd(?ilPropertyFormGUI $a_form=null)
readonly TileView $tile_view
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.