ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjBadgeAdministrationGUI.php
Go to the documentation of this file.
1<?php
2
24
30{
31 public const TABLE_ALL_OBJECTS_ACTION = 'ALL_OBJECTS';
32 private \ILIAS\ResourceStorage\Services $resource_storage;
36
37 public function __construct(
38 $a_data,
39 int $a_id,
40 bool $a_call_by_reference = true,
41 bool $a_prepare_output = true
42 ) {
43 global $DIC;
44
45 $this->resource_storage = $DIC->resourceStorage();
46 $this->rbacsystem = $DIC->rbac()->system();
47 $this->ctrl = $DIC->ctrl();
48 $this->access = $DIC->access();
49 $this->lng = $DIC->language();
50 $this->toolbar = $DIC->toolbar();
51 $this->tpl = $DIC['tpl'];
52 $this->tabs = $DIC->tabs();
53 $this->type = 'bdga';
54 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
55
56 $this->badge_request = new ilBadgeGUIRequest(
57 $DIC->http(),
58 $DIC->refinery()
59 );
60
61 $this->lng->loadLanguageModule('badge');
62 }
63
64 public function executeCommand(): void
65 {
66 $next_class = $this->ctrl->getNextClass($this) ?? '';
67 $cmd = $this->ctrl->getCmd() ?? '';
68
69 $this->prepareOutput();
70
71 switch (strtolower($next_class)) {
72 case strtolower(ilPermissionGUI::class):
73 $this->tabs_gui->setTabActive('perm_settings');
74 $perm_gui = new ilPermissionGUI($this);
75 $this->ctrl->forwardCommand($perm_gui);
76 break;
77
78 case strtolower(ilBadgeManagementGUI::class):
79 $this->assertActive();
80 $this->tabs_gui->setTabActive('activity');
81 $gui = new ilBadgeManagementGUI($this->ref_id, $this->obj_id, $this->type);
82 $this->ctrl->forwardCommand($gui);
83 break;
84
85 default:
86 if (!$cmd || $cmd === 'view') {
87 $cmd = 'editSettings';
88 }
89
90 if ($this->badge_request->getBadgeIdFromUrl()) {
91 $this->ctrl->setParameter($this, 'tid', $this->badge_request->getBadgeIdFromUrl());
92 }
93
94 $get = fn(string $key) => $this->http->wrapper()->query()->retrieve(
95 $key,
96 $this->refinery->byTrying([
97 $this->refinery->kindlyTo()->string(),
98 $this->refinery->always('')
99 ])
100 );
101
102 $table_action = $get('tid_table_action');
103 $return_cmd = $get('returnCmd') ?: 'view';
104
105 $render_default = true;
106 $actions = [
107 'badge_type_activate' => ['activateTypes', true],
108 'badge_type_deactivate' => ['deactivateTypes', true],
109 'badge_image_template_editImageTemplate' => 'editImageTemplate',
110 'obj_badge_user' => 'editImageTemplate',
111 'obj_badge_activate' => 'activateObjectBadges',
112 'obj_badge_deactivate' => 'deactivateObjectBadges',
113 'obj_badge_show_users' => 'listObjectBadgeUsers',
114 'badge_image_template_delete' => 'confirmDeleteImageTemplates',
115 'obj_badge_delete' => 'confirmDeleteObjectBadges',
116 ];
117
118 $entry = $actions[$table_action] ?? null;
119 if ($cmd !== 'action' || !$entry) {
120 $this->$cmd();
121 return;
122 }
123
124 $entry = is_array($entry) ? $entry : [$entry, false];
125 $this->{$entry[0]}();
126 if ($entry[1] && in_array($return_cmd, ['listObjectBadges', 'listObjectBadgeUsers', 'listImageTemplates', 'listTypes'], true)) {
127 $this->$return_cmd();
128 }
129 break;
130 }
131 }
132
133 public function getAdminTabs(): void
134 {
136
137 if ($rbacsystem->checkAccess('visible,read', $this->object->getRefId())) {
138 $this->tabs_gui->addTab(
139 'settings',
140 $this->lng->txt('settings'),
141 $this->ctrl->getLinkTarget($this, 'editSettings')
142 );
143
144 if (ilBadgeHandler::getInstance()->isActive()) {
145 $this->tabs_gui->addTab(
146 'types',
147 $this->lng->txt('badge_types'),
148 $this->ctrl->getLinkTarget($this, 'listTypes')
149 );
150
151 $this->tabs_gui->addTab(
152 'imgtmpl',
153 $this->lng->txt('badge_image_templates'),
154 $this->ctrl->getLinkTarget($this, 'listImageTemplates')
155 );
156
157 $this->tabs_gui->addTab(
158 'activity',
159 $this->lng->txt('badge_activity_badges'),
160 $this->ctrl->getLinkTargetByClass('ilbadgemanagementgui', '')
161 );
162
163 $this->tabs_gui->addTab(
164 'obj_badges',
165 $this->lng->txt('badge_object_badges'),
166 $this->ctrl->getLinkTarget($this, 'listObjectBadges')
167 );
168 }
169 }
170
171 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
172 $this->tabs_gui->addTab(
173 'perm_settings',
174 $this->lng->txt('perm_settings'),
175 $this->ctrl->getLinkTargetByClass('ilpermissiongui', 'perm')
176 );
177 }
178 }
179
180 public function getSafePostCommands(): array
181 {
182 return [];
183 }
184
185 public function getUnsafeGetCommands(): array
186 {
187 return ['action'];
188 }
189
190 protected function assertActive(): void
191 {
192 if (!ilBadgeHandler::getInstance()->isActive()) {
193 $this->ctrl->redirect($this, 'editSettings');
194 }
195 }
196
197
198 //
199 // settings
200 //
201
202 protected function editSettings(?ilPropertyFormGUI $a_form = null): void
203 {
204 $this->tabs_gui->setTabActive('settings');
205
206 if (!$a_form) {
207 $a_form = $this->initFormSettings();
208 }
209
210 $this->tpl->setContent($a_form->getHTML());
211 }
212
213 protected function saveSettings(): void
214 {
215 $ilCtrl = $this->ctrl;
216
217 $this->checkPermission('write');
218
219 $form = $this->initFormSettings();
220 if ($form->checkInput()) {
222 $handler->setActive((bool) $form->getInput('act'));
223
224 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
225 $ilCtrl->redirect($this, 'editSettings');
226 }
227
228 $form->setValuesByPost();
229 $this->editSettings($form);
230 }
231
233 {
234 $ilAccess = $this->access;
235
236 $form = new ilPropertyFormGUI();
237 $form->setFormAction($this->ctrl->getFormAction($this));
238 $form->setTitle($this->lng->txt('badge_settings'));
239
240 if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
241 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
242 $form->addCommandButton('editSettings', $this->lng->txt('cancel'));
243 }
244
245 $act = new ilCheckboxInputGUI($this->lng->txt('badge_service_activate'), 'act');
246 $act->setInfo($this->lng->txt('badge_service_activate_info'));
247 $form->addItem($act);
248
250 $act->setChecked($handler->isActive());
251
252 return $form;
253 }
254
255
256 //
257 // types
258 //
259
260 protected function listTypes(): void
261 {
262 $ilAccess = $this->access;
263
264 $this->assertActive();
265 $this->tabs_gui->setTabActive('types');
266
267 $tpl = new ilBadgeTypesTableGUI($this->access->checkAccess("write", "", $this->object->getRefId()));
268 $this->ctrl->setParameter($this, 'returnCmd', __FUNCTION__);
269 $tpl->renderTable(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTarget($this, 'action'));
270 }
271
272 protected function activateTypes(): void
273 {
275 $this->assertActive();
276
277 $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
278 if ($this->checkPermissionBool('write') && count($tmpl_ids) > 0) {
280 $change_state = [];
281 foreach ($handler->getInactiveTypes() as $type) {
282 if (!in_array($type, $tmpl_ids)) {
283 $change_state[] = $type;
284 }
285 }
286
287 if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
288 $handler->setInactiveTypes([]);
289 } else {
290 $handler->setInactiveTypes($change_state);
291 }
292
293 $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
294 }
295 $this->ctrl->redirect($this, 'listTypes');
296 }
297
298 protected function deactivateTypes(): void
299 {
301 $this->assertActive();
302
303 $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
304 if ($this->checkPermissionBool('write') && count($tmpl_ids) > 0) {
306 $change_state = [];
307 foreach ($handler->getInactiveTypes() as $type) {
308 if (!in_array($type, $tmpl_ids)) {
309 $change_state[] = $type;
310 }
311 }
312
313 $res = [];
314 if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
315 $types = $handler->getAvailableTypes(false);
316 foreach ($types as $id => $type) {
317 $res[] = $id;
318 }
319 $handler->setInactiveTypes($res);
320 } else {
321 $handler->setInactiveTypes($change_state);
322 }
323 $inactive = array_merge($handler->getInactiveTypes(), $tmpl_ids);
324 $handler->setInactiveTypes($inactive);
325
326 $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
327 }
328 $this->ctrl->redirect($this, 'listTypes');
329 }
330
331
332 //
333 // images templates
334 //
335
336 protected function listImageTemplates(): void
337 {
339 $ilToolbar = $this->toolbar;
340 $ilCtrl = $this->ctrl;
341
342 $this->assertActive();
343 $this->tabs_gui->setTabActive('imgtmpl');
344
345 if ($this->checkPermissionBool('write')) {
346 $ilToolbar->addButton(
347 $lng->txt('badge_add_template'),
348 $ilCtrl->getLinkTarget($this, 'addImageTemplate')
349 );
350 }
351
352 $template_table = new ilBadgeImageTemplateTableGUI($this->access->checkAccess("write", "", $this->object->getRefId()));
353 $this->ctrl->setParameter($this, 'returnCmd', __FUNCTION__);
354 $template_table->renderTable(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTarget($this, 'action'));
355 }
356
357
358 protected function addImageTemplate(
359 ?ilPropertyFormGUI $a_form = null
360 ): void {
361 $tpl = $this->tpl;
362
363 $this->checkPermission('write');
364
365 $this->assertActive();
366 $this->tabs_gui->setTabActive('imgtmpl');
367
368 if (!$a_form) {
369 $a_form = $this->initImageTemplateForm('create');
370 }
371
372 $tpl->setContent($a_form->getHTML());
373 }
374
375 protected function initImageTemplateForm(
376 string $a_mode
378 $lng = $this->lng;
379 $ilCtrl = $this->ctrl;
380
381 $form = new ilPropertyFormGUI();
382 $form->setFormAction($ilCtrl->getFormAction($this, 'saveBadge'));
383 $form->setTitle($lng->txt('badge_image_template_form'));
384
385 $title = new ilTextInputGUI($lng->txt('title'), 'title');
386 $title->setMaxLength(255);
387 $title->setRequired(true);
388 $form->addItem($title);
389
390 $img = new ilImageFileInputGUI($lng->txt('image'), 'img');
391 $img->setSuffixes(['png', 'svg']);
392 if ($a_mode === 'create') {
393 $img->setRequired(true);
394 }
395 $img->setUseCache(false);
396 $img->setAllowDeletion(false);
397 $form->addItem($img);
398
399 $types_mode = new ilRadioGroupInputGUI($lng->txt('badge_template_types'), 'tmode');
400 $types_mode->setRequired(true);
401 $types_mode->setValue('all');
402 $form->addItem($types_mode);
403
404 $type_all = new ilRadioOption($lng->txt('badge_template_types_all'), 'all');
405 $types_mode->addOption($type_all);
406
407 $type_spec = new ilRadioOption($lng->txt('badge_template_types_specific'), 'spec');
408 $types_mode->addOption($type_spec);
409
410 $types = new ilCheckboxGroupInputGUI($lng->txt('badge_types'), 'type');
411 $types->setRequired(true);
412 $type_spec->addSubItem($types);
413
414 foreach (ilBadgeHandler::getInstance()->getAvailableTypes(false) as $id => $type) {
415 $types->addOption(new ilCheckboxOption($type->getCaption(), $id));
416 }
417
418 if ($a_mode === 'create') {
419 $form->addCommandButton('saveImageTemplate', $lng->txt('save'));
420 } else {
421 $form->addCommandButton('updateImageTemplate', $lng->txt('save'));
422 }
423 $form->addCommandButton('listImageTemplates', $lng->txt('cancel'));
424
425 return $form;
426 }
427
428 protected function saveImageTemplate(): void
429 {
430 $ilCtrl = $this->ctrl;
432
433 $this->checkPermission('write');
434
435 $form = $this->initImageTemplateForm('create');
436 if ($form->checkInput()) {
437 $tmpl = new ilBadgeImageTemplate();
438 $tmpl->setTitle($form->getInput('title'));
439 $tmpl->setTypes($form->getInput('type'));
440 $tmpl->create();
441
442 $tmpl->processImageUpload($tmpl);
443
444 $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
445 $ilCtrl->redirect($this, 'listImageTemplates');
446 }
447
448 $form->setValuesByPost();
449 $this->addImageTemplate($form);
450 }
451
452 protected function editImageTemplate(
453 ?ilPropertyFormGUI $a_form = null
454 ): void {
455 $ilCtrl = $this->ctrl;
456 $tpl = $this->tpl;
457
458 $this->checkPermission('write');
459
460 $this->assertActive();
461 $this->tabs_gui->setTabActive('imgtmpl');
462
463 $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
464 if (count($tmpl_ids) !== 1) {
465 $this->ctrl->redirect($this, 'listImageTemplates');
466 }
467
468 $template_id = (int) array_pop($tmpl_ids);
469 $ilCtrl->setParameter($this, 'tid', $template_id);
470
471 $tmpl = new ilBadgeImageTemplate($template_id);
472
473 if (!$a_form) {
474 $a_form = $this->initImageTemplateForm('edit');
475 $this->setImageTemplateFormValues($a_form, $tmpl);
476 }
477
478 $tpl->setContent($a_form->getHTML());
479 }
480
481 protected function setImageTemplateFormValues(
482 ilPropertyFormGUI $a_form,
484 ): void {
485 $a_form->getItemByPostVar('title')->setValue($a_tmpl->getTitle());
486 if ($a_tmpl->getImageRid() !== null) {
487 $img = $a_tmpl->getImageFromResourceId();
488 $a_form->getItemByPostVar('img')->setImage($img);
489 $a_form->getItemByPostVar('img')->setValue($a_tmpl->getImageRid());
490 } else {
491 $a_form->getItemByPostVar('img')->setImage($a_tmpl->getImagePath());
492 $a_form->getItemByPostVar('img')->setValue($a_tmpl->getImage());
493 }
494
495 if ($a_tmpl->getTypes()) {
496 $a_form->getItemByPostVar('tmode')->setValue('spec');
497 $a_form->getItemByPostVar('type')->setValue($a_tmpl->getTypes());
498 } else {
499 $a_form->getItemByPostVar('tmode')->setValue('all');
500 }
501 }
502
503 protected function updateImageTemplate(): void
504 {
505 $ilCtrl = $this->ctrl;
507
508 $this->checkPermission('write');
509
510 $tmpl_id = $this->badge_request->getTemplateId();
511 if (!$tmpl_id) {
512 $ilCtrl->redirect($this, 'listImageTemplates');
513 }
514
515 $ilCtrl->setParameter($this, 'tid', $tmpl_id);
516
517 $tmpl = new ilBadgeImageTemplate($tmpl_id);
518
519 $form = $this->initImageTemplateForm('update');
520 if ($form->checkInput()) {
521 $tmpl->setTitle($form->getInput('title'));
522
523 if ($form->getInput('tmode') !== 'all') {
524 $tmpl->setTypes($form->getInput('type'));
525 } else {
526 $tmpl->setTypes(null);
527 }
528
529 $tmpl->update();
530
531 $tmpl->processImageUpload($tmpl);
532
533 $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
534 $ilCtrl->redirect($this, 'listImageTemplates');
535 }
536
537 $this->setImageTemplateFormValues($form, $tmpl);
538 $form->setValuesByPost();
539 $this->editImageTemplate($form);
540 }
541
542 protected function confirmDeleteImageTemplates(): void
543 {
544 $ilCtrl = $this->ctrl;
546 $tpl = $this->tpl;
547 $ilTabs = $this->tabs;
548
549 $this->checkPermission('write');
550
551 $tmpl_ids = $this->badge_request->getBadgeAssignableUsers();
552 if ($tmpl_ids === ['ALL_OBJECTS']) {
553 $tmpl_ids = [];
554 foreach (ilBadgeImageTemplate::getInstances() as $template) {
555 $tmpl_ids[] = $template->getId();
556 }
557 }
558
559 if (!$tmpl_ids) {
560 $ilCtrl->redirect($this, 'listImageTemplates');
561 }
562
563 $ilTabs->clearTargets();
564 $ilTabs->setBackTarget(
565 $lng->txt('back'),
566 $ilCtrl->getLinkTarget($this, 'listImageTemplates')
567 );
568
569 $confirmation_gui = new ilConfirmationGUI();
570 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
571 $confirmation_gui->setHeaderText($lng->txt('badge_template_deletion_confirmation'));
572 $confirmation_gui->setCancel($lng->txt('cancel'), 'listImageTemplates');
573 $confirmation_gui->setConfirm($lng->txt('delete'), 'deleteImageTemplates');
574
575 foreach ($tmpl_ids as $tmpl_id) {
576 $tmpl = new ilBadgeImageTemplate($tmpl_id);
577 $confirmation_gui->addItem('id[]', $tmpl_id, $tmpl->getTitle());
578 }
579
580 $tpl->setContent($confirmation_gui->getHTML());
581 }
582
583 protected function deleteImageTemplates(): void
584 {
586 $tmpl_ids = $this->badge_request->getIds();
587
588 if ($this->checkPermissionBool('write') && count($tmpl_ids) > 0) {
589 if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
590 $tmpl_ids = [];
591 foreach (ilBadgeImageTemplate::getInstances() as $template) {
592 $tmpl_ids[] = $template->getId();
593 }
594 }
595 foreach ($tmpl_ids as $tmpl_id) {
596 $tmpl = new ilBadgeImageTemplate((int) $tmpl_id);
597 $tmpl->delete();
598 }
599 $this->tpl->setOnScreenMessage('success', $lng->txt('badge_deletion'), true);
600 } else {
601 $this->tpl->setOnScreenMessage('failure', $lng->txt('badge_select_one'), true);
602 }
603
604 $this->ctrl->redirect($this, 'listImageTemplates');
605 }
606
607
608 //
609 // object badges
610 //
611
612 protected function applyObjectFilter(): void
613 {
614 $this->listObjectBadges();
615 }
616
617 protected function resetObjectFilter(): void
618 {
619 $this->listObjectBadges();
620 }
621
622 protected function listObjectBadgeUsers(): void
623 {
624 $parent_obj_id = $this->badge_request->getParentId();
625 if (!$parent_obj_id && $this->badge_request->getBadgeIdFromUrl()) {
626 // In this case, we want't to list the users that have been awarded a specific badge
627 $badge = new ilBadge($this->badge_request->getBadgeIdFromUrl());
628 $parent_obj_id = $badge->getParentId();
629 }
630 if (!$parent_obj_id) {
631 $this->ctrl->redirect($this, 'listObjectBadges');
632 }
633
634 $this->assertActive();
635
636 $this->tabs_gui->clearTargets();
637 $this->tabs_gui->setBackTarget(
638 $this->lng->txt('back'),
639 $this->ctrl->getLinkTarget($this, 'listObjectBadges')
640 );
641
642 $this->ctrl->saveParameter($this, 'pid');
643
644 $tbl = new ilBadgeUserTableGUI(null, null, $parent_obj_id, $this->badge_request->getBadgeId());
645 $this->ctrl->setParameter($this, 'returnCmd', __FUNCTION__);
646 $tbl->renderTable(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTarget($this, 'action'));
647 }
648
649 protected function applylistObjectBadgeUsers(): void
650 {
651 $this->listObjectBadges();
652 }
653
654 protected function resetlistObjectBadgeUsers(): void
655 {
656 $this->listObjectBadges();
657 }
658
659 protected function listObjectBadges(): void
660 {
661 $this->assertActive();
662 $this->tabs_gui->setTabActive('obj_badges');
663
664 $tbl = new ilObjectBadgeTableGUI($this, $this->access->checkAccess("write", "", $this->object->getRefId()));
665 $this->ctrl->setParameter($this, 'returnCmd', __FUNCTION__);
666 $tbl->renderTable(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTarget($this, 'action'));
667 }
668
669 //
670 // see ilBadgeManagementGUI
671 //
672
673 protected function getObjectBadgesFromMultiAction(): array
674 {
675 $ilAccess = $this->access;
676 $ilCtrl = $this->ctrl;
677
678 $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
679 if (!$badge_ids ||
680 !$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
681 $ilCtrl->redirect($this, 'listObjectBadges');
682 }
683
684 return $badge_ids;
685 }
686
687 protected function toggleObjectBadges(bool $a_status): void
688 {
689 $ilCtrl = $this->ctrl;
691
692 $badge_ids = $this->getObjectBadgesFromMultiAction();
693 if (current($badge_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
694 $filter = ['type' => '' , 'title' => '', 'object' => ''];
695 $badge_ids = [];
696 foreach (ilBadge::getObjectInstances($filter) as $badge_item) {
697 $badge_ids[] = $badge_item['id'];
698 }
699 foreach ($badge_ids as $badge_id) {
700 $badge = new ilBadge($badge_id);
701 $badge->setActive($a_status);
702 $badge->update();
703 }
704 } else {
705 foreach ($badge_ids as $badge_id) {
706 $badge = new ilBadge($badge_id);
707 $badge->setActive($a_status);
708 $badge->update();
709 }
710 }
711
712
713 $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
714 $ilCtrl->redirect($this, 'listObjectBadges');
715 }
716
717 protected function activateObjectBadges(): void
718 {
719 $this->toggleObjectBadges(true);
720 }
721
722 protected function deactivateObjectBadges(): void
723 {
724 $this->toggleObjectBadges(false);
725 }
726
727 protected function confirmDeleteObjectBadges(): void
728 {
729 $ilCtrl = $this->ctrl;
731 $tpl = $this->tpl;
732 $ilTabs = $this->tabs;
733
734 $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
735
736 $ilTabs->clearTargets();
737 $ilTabs->setBackTarget(
738 $lng->txt('back'),
739 $ilCtrl->getLinkTarget($this, 'listObjectBadges')
740 );
741
742 $confirmation_gui = new ilConfirmationGUI();
743 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
744 $confirmation_gui->setHeaderText($lng->txt('badge_deletion_confirmation'));
745 $confirmation_gui->setCancel($lng->txt('cancel'), 'listObjectBadges');
746 $confirmation_gui->setConfirm($lng->txt('delete'), 'deleteObjectBadges');
747
748 if ($badge_ids === ['ALL_OBJECTS']) {
749 $badge_ids = [];
750 $filter = [
751 'type' => '',
752 'title' => '',
753 'object' => ''
754 ];
755 foreach (ilBadge::getObjectInstances($filter) as $badge_item) {
756 $badge_ids[] = $badge_item['id'];
757 }
758 }
759 foreach ($badge_ids as $badge_id) {
760 $badge = new ilBadge($badge_id);
761 $parent = $badge->getParentMeta();
762
763 $container = '(' . $parent['type'] . '/' .
764 $parent['id'] . ') ' .
765 $parent['title'];
766 if ($parent['deleted']) {
767 $container .= ' <span class="il_ItemAlertProperty">' . $lng->txt('deleted') . '</span>';
768 }
769
770 $confirmation_gui->addItem(
771 'id[]',
772 $badge_id,
773 $container . ' - ' .
774 $badge->getTitle() .
775 ' (' . count(ilBadgeAssignment::getInstancesByBadgeId($badge_id)) . ')'
776 );
777 }
778
779 $tpl->setContent($confirmation_gui->getHTML());
780 }
781
782 protected function deleteObjectBadges(): void
783 {
784 $ilCtrl = $this->ctrl;
786
787 $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromPost();
788
789 foreach ($badge_ids as $badge_id) {
790 $badge = new ilBadge($badge_id);
791 $badge->delete();
792 }
793
794 $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
795 $ilCtrl->redirect($this, 'listObjectBadges');
796 }
797}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class Services.
Definition: Services.php:38
static getInstancesByBadgeId(int $a_badge_id)
getImageFromResourceId(int $size=ilBadgeImage::IMAGE_SIZE_XS)
@ilCtrl_Calls ilBadgeManagementGUI: ilPropertyFormGUI
static getObjectInstances(?array $filter=null)
This class represents a property in a property form.
This class represents a checkbox property in a property form.
This class represents an option in a checkbox group.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents an image file property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
@ilCtrl_Calls ilObjBadgeAdministrationGUI: ilPermissionGUI, ilBadgeManagementGUI @ilCtrl_IsCalledBy i...
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
setImageTemplateFormValues(ilPropertyFormGUI $a_form, ilBadgeImageTemplate $a_tmpl)
getAdminTabs()
administration tabs show only permissions and trash folder
addImageTemplate(?ilPropertyFormGUI $a_form=null)
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
ILIAS ResourceStorage Services $resource_storage
editSettings(?ilPropertyFormGUI $a_form=null)
getSafePostCommands()
This method must return a list of safe POST commands.
editImageTemplate(?ilPropertyFormGUI $a_form=null)
Class ilObjectGUI Basic methods of all Output classes.
ilAccessHandler $access
ilGlobalTemplateInterface $tpl
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
ilToolbarGUI $toolbar
prepareOutput(bool $show_sub_objects=true)
ilLanguage $lng
This class represents a property form user interface.
getItemByPostVar(string $a_post_var)
This class represents a property in a property form.
This class represents an option in a radio group.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text property in a property form.
setContent(string $a_html)
Sets content for standard template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$handler
Definition: oai.php:29
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26
$container
@noRector
Definition: wac.php:37