51 bool $a_call_by_reference =
true,
52 bool $a_prepare_output =
true
56 $this->rbacsystem =
$DIC->rbac()->system();
57 $this->
ctrl = $DIC->ctrl();
58 $this->
access = $DIC->access();
59 $this->
lng = $DIC->language();
60 $this->
toolbar = $DIC->toolbar();
61 $this->tpl =
$DIC[
'tpl'];
62 $this->
tabs = $DIC->tabs();
71 $this->
lng->loadLanguageModule(
'badge');
76 $next_class = $this->
ctrl->getNextClass($this) ??
'';
77 $cmd = $this->
ctrl->getCmd() ??
'';
81 switch (strtolower($next_class)) {
82 case strtolower(ilPermissionGUI::class):
83 $this->tabs_gui->setTabActive(
'perm_settings');
85 $this->
ctrl->forwardCommand($perm_gui);
88 case strtolower(ilBadgeManagementGUI::class):
90 $this->tabs_gui->setTabActive(
'activity');
92 $this->
ctrl->forwardCommand($gui);
96 if ($cmd ===
'' || $cmd ===
null || $cmd ===
'view' || !method_exists($this, $cmd .
'Cmd')) {
101 if ($this->badge_request->getBadgeIdFromUrl()) {
102 $this->
ctrl->setParameter($this,
'tid', $this->badge_request->getBadgeIdFromUrl());
112 if ($this->rbacsystem->checkAccess(
'read', $this->object->getRefId())) {
113 $this->tabs_gui->addTab(
115 $this->
lng->txt(
'settings'),
116 $this->ctrl->getLinkTarget($this, self::EDIT_SETTINGS_ACTION)
120 $this->tabs_gui->addTab(
122 $this->
lng->txt(
'badge_types'),
123 $this->ctrl->getLinkTarget($this, self::LIST_TYPES_ACTION)
126 $this->tabs_gui->addTab(
128 $this->
lng->txt(
'badge_image_templates'),
129 $this->ctrl->getLinkTarget($this, self::LIST_IMG_TPL_ACTION)
132 $this->tabs_gui->addTab(
134 $this->
lng->txt(
'badge_activity_badges'),
135 $this->ctrl->getLinkTargetByClass(
'ilbadgemanagementgui',
'')
138 $this->tabs_gui->addTab(
140 $this->
lng->txt(
'badge_object_badges'),
141 $this->ctrl->getLinkTarget($this, self::LIST_OBJ_BADGES_ACTION)
146 if ($this->rbacsystem->checkAccess(
'edit_permission', $this->object->getRefId())) {
147 $this->tabs_gui->addTab(
149 $this->
lng->txt(
'perm_settings'),
150 $this->ctrl->getLinkTargetByClass(
'ilpermissiongui',
'perm')
162 return $this->
http->wrapper()->query()->retrieve(
165 $this->refinery->kindlyTo()->string(),
166 $this->refinery->always(
null)
176 'badge_image_template_editImageTemplate',
'obj_badge_user' => $this->
editImageTemplate(),
182 default => $this->
ctrl->redirect($this, self::DEFAULT_ACTION),
194 $this->
ctrl->redirect($this, self::DEFAULT_ACTION);
204 $this->tabs_gui->setTabActive(
'settings');
210 $this->tpl->setContent($a_form->getHTML());
218 if ($form->checkInput()) {
220 $handler->setActive((
bool) $form->getInput(
'act'));
222 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'settings_saved'),
true);
223 $this->
ctrl->redirect($this, self::EDIT_SETTINGS_ACTION);
226 $form->setValuesByPost();
233 $form->setFormAction($this->
ctrl->getFormAction($this, self::SAVE_SETTINGS_ACTION));
234 $form->setTitle($this->
lng->txt(
'badge_settings'));
236 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
237 $form->addCommandButton(self::SAVE_SETTINGS_ACTION, $this->
lng->txt(
'save'));
238 $form->addCommandButton(self::EDIT_SETTINGS_ACTION, $this->
lng->txt(
'cancel'));
242 $act->setInfo($this->
lng->txt(
'badge_service_activate_info'));
243 $form->addItem($act);
246 $act->setChecked(
$handler->isActive());
258 $this->tabs_gui->setTabActive(
'types');
261 $tpl->renderTable(ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this, self::TABLE_ACTIONS));
268 $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
273 if (!in_array(
$type, $tmpl_ids)) {
274 $change_state[] =
$type;
278 if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
281 $handler->setInactiveTypes($change_state);
284 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'settings_saved'),
true);
287 $this->
ctrl->redirect($this, self::LIST_TYPES_ACTION);
294 $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
299 if (!in_array(
$type, $tmpl_ids)) {
300 $change_state[] =
$type;
305 if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
306 $types =
$handler->getAvailableTypes(
false);
312 $handler->setInactiveTypes($change_state);
314 $inactive = array_merge(
$handler->getInactiveTypes(), $tmpl_ids);
315 $handler->setInactiveTypes($inactive);
317 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'settings_saved'),
true);
320 $this->
ctrl->redirect($this, self::LIST_TYPES_ACTION);
330 $this->tabs_gui->setTabActive(
'imgtmpl');
334 $this->
lng->txt(
'badge_add_template'),
335 $this->ctrl->getLinkTarget($this, self::ADD_IMG_TPL_ACTION)
340 $this->
access->checkAccess(
'write',
'', $this->object->getRefId())
342 $template_table->renderTable(ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this, self::TABLE_ACTIONS));
351 $this->tabs_gui->setTabActive(
'imgtmpl');
357 $this->tpl->setContent($a_form->getHTML());
364 if ($a_mode ===
'create') {
365 $form->
setFormAction($this->
ctrl->getFormAction($this, self::SAVE_IMG_TPL_ACTION));
367 $form->setFormAction($this->
ctrl->getFormAction($this, self::UPDATE_IMG_TPL_ACTION));
369 $form->setTitle($this->
lng->txt(
'badge_image_template_form'));
372 $title->setMaxLength(255);
373 $title->setRequired(
true);
374 $form->addItem($title);
377 $img->setSuffixes([
'png',
'svg']);
378 if ($a_mode ===
'create') {
379 $img->setRequired(
true);
381 $img->setUseCache(
false);
382 $img->setAllowDeletion(
false);
383 $form->addItem($img);
386 $types_mode->setRequired(
true);
387 $types_mode->setValue(
'all');
388 $form->addItem($types_mode);
390 $type_all =
new ilRadioOption($this->
lng->txt(
'badge_template_types_all'),
'all');
391 $types_mode->addOption($type_all);
393 $type_spec =
new ilRadioOption($this->
lng->txt(
'badge_template_types_specific'),
'spec');
394 $types_mode->addOption($type_spec);
397 $types->setRequired(
true);
398 $type_spec->addSubItem($types);
404 if ($a_mode ===
'create') {
405 $form->addCommandButton(self::SAVE_IMG_TPL_ACTION, $this->
lng->txt(
'save'));
407 $form->addCommandButton(self::UPDATE_IMG_TPL_ACTION, $this->
lng->txt(
'save'));
409 $form->addCommandButton(self::LIST_IMG_TPL_ACTION, $this->
lng->txt(
'cancel'));
416 $this->checkPermission(
'write');
418 $form = $this->initImageTemplateForm(
'create');
419 if ($form->checkInput()) {
421 $tmpl->setTitle($form->getInput(
'title'));
422 $tmpl->setTypes($form->getInput(
'type'));
425 $tmpl->processImageUpload($tmpl);
427 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'settings_saved'),
true);
428 $this->
ctrl->redirect($this, self::LIST_IMG_TPL_ACTION);
431 $form->setValuesByPost();
432 $this->addImageTemplateCmd($form);
438 $this->checkPermission(
'write');
440 $this->assertActive();
441 $this->tabs_gui->setTabActive(
'imgtmpl');
443 $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
444 if (count($tmpl_ids) !== 1) {
445 $tmpl_id = $this->badge_request->getTemplateId();
447 $this->
ctrl->redirect($this, self::LIST_IMG_TPL_ACTION);
450 $tmpl_ids = [$tmpl_id];
453 $template_id = (
int) array_pop($tmpl_ids);
454 $this->
ctrl->setParameter($this,
'tid', $template_id);
459 $a_form = $this->initImageTemplateForm(
'edit');
460 $this->setImageTemplateFormValues($a_form, $tmpl);
463 $this->tpl->setContent($a_form->getHTML());
470 $a_form->getItemByPostVar(
'title')->setValue($a_tmpl->
getTitle());
490 $this->checkPermission(
'write');
492 $tmpl_id = $this->badge_request->getTemplateId();
494 $this->
ctrl->redirect($this, self::LIST_IMG_TPL_ACTION);
497 $this->
ctrl->setParameter($this,
'tid', $tmpl_id);
501 $form = $this->initImageTemplateForm(
'update');
502 if ($form->checkInput()) {
503 $tmpl->setTitle($form->getInput(
'title'));
505 if ($form->getInput(
'tmode') !==
'all') {
506 $tmpl->setTypes($form->getInput(
'type'));
508 $tmpl->setTypes(
null);
513 $tmpl->processImageUpload($tmpl);
515 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'settings_saved'),
true);
516 $this->
ctrl->redirect($this, self::LIST_IMG_TPL_ACTION);
519 $this->setImageTemplateFormValues($form, $tmpl);
520 $form->setValuesByPost();
521 $this->editImageTemplate($form);
526 $this->checkPermission(
'write');
528 $tmpl_ids = $this->badge_request->getBadgeAssignableUsers();
529 if ($tmpl_ids === [self::TABLE_ALL_OBJECTS_ACTION]) {
532 $tmpl_ids[] = $template->getId();
537 $this->
ctrl->redirect($this, self::LIST_IMG_TPL_ACTION);
540 $this->
tabs->clearTargets();
541 $this->
tabs->setBackTarget(
542 $this->
lng->txt(
'back'),
543 $this->ctrl->getLinkTarget($this, self::LIST_IMG_TPL_ACTION)
547 $confirmation_gui->setFormAction($this->
ctrl->getFormAction($this));
548 $confirmation_gui->setHeaderText($this->
lng->txt(
'badge_template_deletion_confirmation'));
549 $confirmation_gui->setCancel($this->
lng->txt(
'cancel'), self::LIST_IMG_TPL_ACTION);
550 $confirmation_gui->setConfirm($this->
lng->txt(
'delete'), self::DELETE_IMG_TPL_ACTION);
552 foreach ($tmpl_ids as $tmpl_id) {
554 $confirmation_gui->addItem(
'id[]', $tmpl_id, $tmpl->getTitle());
557 $this->tpl->setContent($confirmation_gui->getHTML());
562 $tmpl_ids = $this->badge_request->getIds();
564 if ($this->checkPermissionBool(
'write') && count($tmpl_ids) > 0) {
565 if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
568 $tmpl_ids[] = $template->getId();
571 foreach ($tmpl_ids as $tmpl_id) {
575 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'badge_deletion'),
true);
577 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->
lng->txt(
'badge_select_one'),
true);
580 $this->
ctrl->redirect($this, self::LIST_IMG_TPL_ACTION);
589 $parent_obj_id = $this->badge_request->getParentId();
590 if (!$parent_obj_id && $this->badge_request->getBadgeIdFromUrl()) {
592 $badge =
new ilBadge($this->badge_request->getBadgeIdFromUrl());
593 $parent_obj_id = $badge->getParentId();
595 if (!$parent_obj_id) {
596 $this->
ctrl->redirect($this, self::LIST_OBJ_BADGES_ACTION);
599 $this->assertActive();
601 $this->tabs_gui->clearTargets();
602 $this->tabs_gui->setBackTarget(
603 $this->
lng->txt(
'back'),
604 $this->ctrl->getLinkTarget($this, self::LIST_OBJ_BADGES_ACTION)
607 $this->
ctrl->saveParameter($this,
'pid');
609 $tbl =
new ilBadgeUserTableGUI(
null,
null, $parent_obj_id, $this->badge_request->getBadgeId());
610 $tbl->renderTable(ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this, self::TABLE_ACTIONS));
615 $this->assertActive();
616 $this->tabs_gui->setTabActive(
'obj_badges');
619 $tbl->renderTable(ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this, self::TABLE_ACTIONS));
628 $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
630 !$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
631 $this->
ctrl->redirect($this, self::LIST_OBJ_BADGES_ACTION);
639 $badge_ids = $this->getObjectBadgesFromMultiAction();
640 if (current($badge_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
641 $filter = [
'type' =>
'' ,
'title' =>
'',
'object' =>
''];
644 $badge_ids[] = $badge_item[
'id'];
648 foreach ($badge_ids as $badge_id) {
649 $badge =
new ilBadge($badge_id);
650 $badge->setActive($a_status);
654 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'settings_saved'),
true);
655 $this->
ctrl->redirect($this, self::LIST_OBJ_BADGES_ACTION);
660 $this->toggleObjectBadges(
true);
665 $this->toggleObjectBadges(
false);
670 $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
672 $this->
tabs->clearTargets();
673 $this->
tabs->setBackTarget(
674 $this->
lng->txt(
'back'),
675 $this->ctrl->getLinkTarget($this, self::LIST_OBJ_BADGES_ACTION)
679 $confirmation_gui->setFormAction($this->
ctrl->getFormAction($this));
680 $confirmation_gui->setHeaderText($this->
lng->txt(
'badge_deletion_confirmation'));
681 $confirmation_gui->setCancel($this->
lng->txt(
'cancel'), self::LIST_OBJ_BADGES_ACTION);
682 $confirmation_gui->setConfirm($this->
lng->txt(
'delete'), self::DELETE_OBJ_BADGES_ACTION);
684 if ($badge_ids === [self::TABLE_ALL_OBJECTS_ACTION]) {
692 $badge_ids[] = $badge_item[
'id'];
695 foreach ($badge_ids as $badge_id) {
696 $badge =
new ilBadge($badge_id);
697 $parent = $badge->getParentMeta();
700 $parent[
'id'] .
') ' .
702 if ($parent[
'deleted']) {
703 $container .=
' <span class="il_ItemAlertProperty">' . $this->
lng->txt(
'deleted') .
'</span>';
706 $confirmation_gui->addItem(
715 $this->tpl->setContent($confirmation_gui->getHTML());
720 $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromPost();
722 foreach ($badge_ids as $badge_id) {
723 $badge =
new ilBadge($badge_id);
727 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'settings_saved'),
true);
728 $this->
ctrl->redirect($this, self::LIST_OBJ_BADGES_ACTION);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static getInstancesByBadgeId(int $a_badge_id)
@ilCtrl_Calls ilBadgeManagementGUI: ilPropertyFormGUI
static getObjectInstances(?array $filter=null)
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...
@ilCtrl_Calls ilObjBadgeAdministrationGUI: ilPermissionGUI, ilBadgeManagementGUI @ilCtrl_IsCalledBy i...
initImageTemplateForm(string $a_mode)
const string ADD_IMG_TPL_ACTION
const string SAVE_IMG_TPL_ACTION
deleteImageTemplatesCmd()
confirmDeleteObjectBadges()
const string LIST_IMG_TPL_ACTION
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
setImageTemplateFormValues(ilPropertyFormGUI $a_form, ilBadgeImageTemplate $a_tmpl)
confirmDeleteImageTemplates()
const string DELETE_OBJ_BADGES_ACTION
addImageTemplateCmd(?ilPropertyFormGUI $a_form=null)
const string SAVE_SETTINGS_ACTION
ilBadgeGUIRequest $badge_request
getAdminTabs()
administration tabs show only permissions and trash folder
toggleObjectBadges(bool $a_status)
const string LIST_TYPES_ACTION
const string EDIT_SETTINGS_ACTION
const string LIST_OBJ_BADGES_ACTION
const string DELETE_IMG_TPL_ACTION
getObjectBadgesFromMultiAction()
editSettingsCmd(?ilPropertyFormGUI $a_form=null)
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
const string UPDATE_IMG_TPL_ACTION
getSafePostCommands()
This method must return a list of safe POST commands.
const string DEFAULT_ACTION
const string TABLE_ACTIONS
const string TABLE_ALL_OBJECTS_ACTION
editImageTemplate(?ilPropertyFormGUI $a_form=null)
Class ilObjectGUI Basic methods of all Output classes.
ilGlobalTemplateInterface $tpl
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
This class represents an option in a radio group.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
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.
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc