40 bool $a_call_by_reference =
true,
41 bool $a_prepare_output =
true 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();
61 $this->
lng->loadLanguageModule(
'badge');
66 $next_class = $this->
ctrl->getNextClass($this) ??
'';
67 $cmd = $this->
ctrl->getCmd() ??
'';
71 switch (strtolower($next_class)) {
72 case strtolower(ilPermissionGUI::class):
73 $this->tabs_gui->setTabActive(
'perm_settings');
75 $this->
ctrl->forwardCommand($perm_gui);
78 case strtolower(ilBadgeManagementGUI::class):
80 $this->tabs_gui->setTabActive(
'activity');
82 $this->
ctrl->forwardCommand($gui);
86 if (!$cmd || $cmd ===
'view') {
87 $cmd =
'editSettings';
90 if ($this->badge_request->getBadgeIdFromUrl()) {
91 $this->
ctrl->setParameter($this,
'tid', $this->badge_request->getBadgeIdFromUrl());
94 $get = fn(
string $key) => $this->
http->wrapper()->query()->retrieve(
97 $this->refinery->kindlyTo()->string(),
102 $table_action = $get(
'tid_table_action');
103 $return_cmd = $get(
'returnCmd') ?:
'view';
105 $render_default =
true;
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',
118 $entry = $actions[$table_action] ??
null;
119 if ($cmd !==
'action' || !$entry) {
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();
137 if ($rbacsystem->
checkAccess(
'visible,read', $this->object->getRefId())) {
138 $this->tabs_gui->addTab(
140 $this->
lng->txt(
'settings'),
141 $this->
ctrl->getLinkTarget($this,
'editSettings')
145 $this->tabs_gui->addTab(
147 $this->
lng->txt(
'badge_types'),
148 $this->
ctrl->getLinkTarget($this,
'listTypes')
151 $this->tabs_gui->addTab(
153 $this->
lng->txt(
'badge_image_templates'),
154 $this->
ctrl->getLinkTarget($this,
'listImageTemplates')
157 $this->tabs_gui->addTab(
159 $this->
lng->txt(
'badge_activity_badges'),
160 $this->
ctrl->getLinkTargetByClass(
'ilbadgemanagementgui',
'')
163 $this->tabs_gui->addTab(
165 $this->
lng->txt(
'badge_object_badges'),
166 $this->
ctrl->getLinkTarget($this,
'listObjectBadges')
171 if ($rbacsystem->
checkAccess(
'edit_permission', $this->object->getRefId())) {
172 $this->tabs_gui->addTab(
174 $this->
lng->txt(
'perm_settings'),
175 $this->
ctrl->getLinkTargetByClass(
'ilpermissiongui',
'perm')
193 $this->
ctrl->redirect($this,
'editSettings');
204 $this->tabs_gui->setTabActive(
'settings');
210 $this->tpl->setContent($a_form->getHTML());
220 if ($form->checkInput()) {
222 $handler->setActive((
bool) $form->getInput(
'act'));
224 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
225 $ilCtrl->redirect($this,
'editSettings');
228 $form->setValuesByPost();
237 $form->setFormAction($this->
ctrl->getFormAction($this));
238 $form->setTitle($this->
lng->txt(
'badge_settings'));
240 if ($ilAccess->checkAccess(
'write',
'', $this->object->getRefId())) {
241 $form->addCommandButton(
'saveSettings', $this->
lng->txt(
'save'));
242 $form->addCommandButton(
'editSettings', $this->
lng->txt(
'cancel'));
246 $act->setInfo($this->
lng->txt(
'badge_service_activate_info'));
247 $form->addItem($act);
250 $act->setChecked(
$handler->isActive());
265 $this->tabs_gui->setTabActive(
'types');
268 $this->
ctrl->setParameter($this,
'returnCmd', __FUNCTION__);
269 $tpl->renderTable(ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this,
'action'));
277 $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
282 if (!in_array(
$type, $tmpl_ids)) {
283 $change_state[] =
$type;
287 if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
290 $handler->setInactiveTypes($change_state);
293 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
'settings_saved'),
true);
295 $this->
ctrl->redirect($this,
'listTypes');
303 $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
308 if (!in_array(
$type, $tmpl_ids)) {
309 $change_state[] =
$type;
314 if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
315 $types =
$handler->getAvailableTypes(
false);
321 $handler->setInactiveTypes($change_state);
323 $inactive = array_merge(
$handler->getInactiveTypes(), $tmpl_ids);
324 $handler->setInactiveTypes($inactive);
326 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
'settings_saved'),
true);
328 $this->
ctrl->redirect($this,
'listTypes');
343 $this->tabs_gui->setTabActive(
'imgtmpl');
346 $ilToolbar->addButton(
347 $lng->
txt(
'badge_add_template'),
348 $ilCtrl->getLinkTarget($this,
'addImageTemplate')
353 $this->
ctrl->setParameter($this,
'returnCmd', __FUNCTION__);
354 $template_table->renderTable(ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this,
'action'));
366 $this->tabs_gui->setTabActive(
'imgtmpl');
382 $form->setFormAction($ilCtrl->getFormAction($this,
'saveBadge'));
383 $form->setTitle(
$lng->
txt(
'badge_image_template_form'));
386 $title->setMaxLength(255);
387 $title->setRequired(
true);
388 $form->addItem($title);
392 if ($a_mode ===
'create') {
393 $img->setRequired(
true);
395 $img->setUseCache(
false);
396 $img->setAllowDeletion(
false);
397 $form->addItem($img);
401 $types_mode->setValue(
'all');
402 $form->addItem($types_mode);
405 $types_mode->addOption($type_all);
408 $types_mode->addOption($type_spec);
412 $type_spec->addSubItem($types);
418 if ($a_mode ===
'create') {
419 $form->addCommandButton(
'saveImageTemplate',
$lng->
txt(
'save'));
421 $form->addCommandButton(
'updateImageTemplate',
$lng->
txt(
'save'));
423 $form->addCommandButton(
'listImageTemplates',
$lng->
txt(
'cancel'));
436 if ($form->checkInput()) {
438 $tmpl->setTitle($form->getInput(
'title'));
439 $tmpl->setTypes($form->getInput(
'type'));
442 $tmpl->processImageUpload($tmpl);
444 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
'settings_saved'),
true);
445 $ilCtrl->redirect($this,
'listImageTemplates');
448 $form->setValuesByPost();
461 $this->tabs_gui->setTabActive(
'imgtmpl');
463 $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
464 if (count($tmpl_ids) !== 1) {
465 $this->
ctrl->redirect($this,
'listImageTemplates');
468 $template_id = (
int) array_pop($tmpl_ids);
469 $ilCtrl->setParameter($this,
'tid', $template_id);
510 $tmpl_id = $this->badge_request->getTemplateId();
512 $ilCtrl->redirect($this,
'listImageTemplates');
515 $ilCtrl->setParameter($this,
'tid', $tmpl_id);
520 if ($form->checkInput()) {
521 $tmpl->setTitle($form->getInput(
'title'));
523 if ($form->getInput(
'tmode') !==
'all') {
524 $tmpl->setTypes($form->getInput(
'type'));
526 $tmpl->setTypes(
null);
531 $tmpl->processImageUpload($tmpl);
533 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
'settings_saved'),
true);
534 $ilCtrl->redirect($this,
'listImageTemplates');
538 $form->setValuesByPost();
551 $tmpl_ids = $this->badge_request->getBadgeAssignableUsers();
552 if ($tmpl_ids === [
'ALL_OBJECTS']) {
555 $tmpl_ids[] = $template->getId();
560 $ilCtrl->redirect($this,
'listImageTemplates');
563 $ilTabs->clearTargets();
564 $ilTabs->setBackTarget(
566 $ilCtrl->getLinkTarget($this,
'listImageTemplates')
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');
575 foreach ($tmpl_ids as $tmpl_id) {
577 $confirmation_gui->addItem(
'id[]', $tmpl_id, $tmpl->getTitle());
586 $tmpl_ids = $this->badge_request->getIds();
589 if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
592 $tmpl_ids[] = $template->getId();
595 foreach ($tmpl_ids as $tmpl_id) {
599 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
'badge_deletion'),
true);
601 $this->tpl->setOnScreenMessage(
'failure',
$lng->
txt(
'badge_select_one'),
true);
604 $this->
ctrl->redirect($this,
'listImageTemplates');
624 $parent_obj_id = $this->badge_request->getParentId();
625 if (!$parent_obj_id && $this->badge_request->getBadgeIdFromUrl()) {
627 $badge =
new ilBadge($this->badge_request->getBadgeIdFromUrl());
628 $parent_obj_id = $badge->getParentId();
630 if (!$parent_obj_id) {
631 $this->
ctrl->redirect($this,
'listObjectBadges');
636 $this->tabs_gui->clearTargets();
637 $this->tabs_gui->setBackTarget(
638 $this->
lng->txt(
'back'),
639 $this->
ctrl->getLinkTarget($this,
'listObjectBadges')
642 $this->
ctrl->saveParameter($this,
'pid');
645 $this->
ctrl->setParameter($this,
'returnCmd', __FUNCTION__);
646 $tbl->renderTable(ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this,
'action'));
662 $this->tabs_gui->setTabActive(
'obj_badges');
665 $this->
ctrl->setParameter($this,
'returnCmd', __FUNCTION__);
666 $tbl->renderTable(ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this,
'action'));
678 $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
680 !$ilAccess->checkAccess(
'write',
'', $this->object->getRefId())) {
681 $ilCtrl->
redirect($this,
'listObjectBadges');
693 if (current($badge_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
694 $filter = [
'type' =>
'' ,
'title' =>
'',
'object' =>
''];
697 $badge_ids[] = $badge_item[
'id'];
699 foreach ($badge_ids as $badge_id) {
700 $badge =
new ilBadge($badge_id);
701 $badge->setActive($a_status);
705 foreach ($badge_ids as $badge_id) {
706 $badge =
new ilBadge($badge_id);
707 $badge->setActive($a_status);
713 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
'settings_saved'),
true);
714 $ilCtrl->redirect($this,
'listObjectBadges');
734 $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
737 $ilTabs->setBackTarget(
739 $ilCtrl->getLinkTarget($this,
'listObjectBadges')
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');
748 if ($badge_ids === [
'ALL_OBJECTS']) {
756 $badge_ids[] = $badge_item[
'id'];
759 foreach ($badge_ids as $badge_id) {
760 $badge =
new ilBadge($badge_id);
761 $parent = $badge->getParentMeta();
764 $parent[
'id'] .
') ' .
766 if ($parent[
'deleted']) {
767 $container .=
' <span class="il_ItemAlertProperty">' .
$lng->
txt(
'deleted') .
'</span>';
770 $confirmation_gui->addItem(
787 $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromPost();
789 foreach ($badge_ids as $badge_id) {
790 $badge =
new ilBadge($badge_id);
794 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
'settings_saved'),
true);
795 $ilCtrl->redirect($this,
'listObjectBadges');
ilBadgeGUIRequest $badge_request
This class represents an option in a radio group.
resetlistObjectBadgeUsers()
ilBadgeManagementGUI: ilPropertyFormGUI
This class represents an option in a checkbox group.
getObjectBadgesFromMultiAction()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
prepareOutput(bool $show_sub_objects=true)
addImageTemplate(?ilPropertyFormGUI $a_form=null)
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
setContent(string $a_html)
Sets content for standard template.
confirmDeleteImageTemplates()
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
setImageTemplateFormValues(ilPropertyFormGUI $a_form, ilBadgeImageTemplate $a_tmpl)
getImageFromResourceId(int $size=ilBadgeImage::IMAGE_SIZE_XS)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 ...
initImageTemplateForm(string $a_mode)
static http()
Fetches the global http state from ILIAS.
ilGlobalTemplateInterface $tpl
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
static getInstancesByBadgeId(int $a_badge_id)
Class ilObjectGUI Basic methods of all Output classes.
ILIAS ResourceStorage Services $resource_storage
clearTargets()
clear all targets
applylistObjectBadgeUsers()
const TABLE_ALL_OBJECTS_ACTION
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
editSettings(?ilPropertyFormGUI $a_form=null)
__construct(Container $dic, ilPlugin $plugin)
static getObjectInstances(?array $filter=null)
getSafePostCommands()
This method must return a list of safe POST commands.
editImageTemplate(?ilPropertyFormGUI $a_form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
toggleObjectBadges(bool $a_status)
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
confirmDeleteObjectBadges()