41         bool $a_call_by_reference = 
true,
    42         bool $a_prepare_output = 
true    46         $this->resource_storage = $DIC->resourceStorage();
    47         $this->rbacsystem = $DIC->rbac()->system();
    48         $this->
ctrl = $DIC->ctrl();
    49         $this->
access = $DIC->access();
    50         $this->
lng = $DIC->language();
    51         $this->
toolbar = $DIC->toolbar();
    52         $this->tpl = $DIC[
'tpl'];
    53         $this->
tabs = $DIC->tabs();
    55         $this->
http = $DIC->http();
    63         $this->
lng->loadLanguageModule(
'badge');
    68         $next_class = $this->
ctrl->getNextClass($this) ?? 
'';
    69         $cmd = $this->
ctrl->getCmd() ?? 
'';
    73         switch (strtolower($next_class)) {
    74             case strtolower(ilPermissionGUI::class):
    75                 $this->tabs_gui->setTabActive(
'perm_settings');
    77                 $this->
ctrl->forwardCommand($perm_gui);
    80             case strtolower(ilBadgeManagementGUI::class):
    82                 $this->tabs_gui->setTabActive(
'activity');
    84                 $this->
ctrl->forwardCommand($gui);
    88                 if (!$cmd || $cmd === 
'view') {
    89                     $cmd = 
'editSettings';
    92                 if ($this->badge_request->getBadgeIdFromUrl()) {
    93                     $this->
ctrl->setParameter($this, 
'tid', $this->badge_request->getBadgeIdFromUrl());
    96                 $get = fn(
string $key) => $this->
http->wrapper()->query()->retrieve(
    99                         $this->refinery->kindlyTo()->string(),
   104                 $table_action = $get(
'tid_table_action');
   105                 $return_cmd = $get(
'returnCmd') ?: 
'view';
   107                 $render_default = 
true;
   109                     'badge_type_activate' => [
'activateTypes', 
true],
   110                     'badge_type_deactivate' => [
'deactivateTypes', 
true],
   111                     'badge_image_template_editImageTemplate' => 
'editImageTemplate',
   112                     'obj_badge_user' => 
'editImageTemplate',
   113                     'obj_badge_activate' => 
'activateObjectBadges',
   114                     'obj_badge_deactivate' => 
'deactivateObjectBadges',
   115                     'obj_badge_show_users' => 
'listObjectBadgeUsers',
   116                     'badge_image_template_delete' => 
'confirmDeleteImageTemplates',
   117                     'obj_badge_delete' => 
'confirmDeleteObjectBadges',
   120                 $entry = $actions[$table_action] ?? null;
   121                 if ($cmd !== 
'action' || !$entry) {
   126                 $entry = is_array($entry) ? $entry : [$entry, 
false];
   127                 $this->{$entry[0]}();
   128                 if ($entry[1] && in_array($return_cmd, [
'listObjectBadges', 
'listObjectBadgeUsers', 
'listImageTemplates', 
'listTypes'], 
true)) {
   129                     $this->$return_cmd();
   139         if ($rbacsystem->
checkAccess(
'visible,read', $this->object->getRefId())) {
   140             $this->tabs_gui->addTab(
   142                 $this->
lng->txt(
'settings'),
   143                 $this->
ctrl->getLinkTarget($this, 
'editSettings')
   147                 $this->tabs_gui->addTab(
   149                     $this->
lng->txt(
'badge_types'),
   150                     $this->
ctrl->getLinkTarget($this, 
'listTypes')
   153                 $this->tabs_gui->addTab(
   155                     $this->
lng->txt(
'badge_image_templates'),
   156                     $this->
ctrl->getLinkTarget($this, 
'listImageTemplates')
   159                 $this->tabs_gui->addTab(
   161                     $this->
lng->txt(
'badge_activity_badges'),
   162                     $this->
ctrl->getLinkTargetByClass(
'ilbadgemanagementgui', 
'')
   165                 $this->tabs_gui->addTab(
   167                     $this->
lng->txt(
'badge_object_badges'),
   168                     $this->
ctrl->getLinkTarget($this, 
'listObjectBadges')
   173         if ($rbacsystem->
checkAccess(
'edit_permission', $this->object->getRefId())) {
   174             $this->tabs_gui->addTab(
   176                 $this->
lng->txt(
'perm_settings'),
   177                 $this->
ctrl->getLinkTargetByClass(
'ilpermissiongui', 
'perm')
   195             $this->
ctrl->redirect($this, 
'editSettings');
   206         $this->tabs_gui->setTabActive(
'settings');
   212         $this->tpl->setContent($a_form->getHTML());
   222         if ($form->checkInput()) {
   224             $handler->setActive((
bool) $form->getInput(
'act'));
   226             $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'), 
true);
   227             $ilCtrl->redirect($this, 
'editSettings');
   230         $form->setValuesByPost();
   239         $form->setFormAction($this->
ctrl->getFormAction($this));
   240         $form->setTitle($this->
lng->txt(
'badge_settings'));
   242         if ($ilAccess->checkAccess(
'write', 
'', $this->object->getRefId())) {
   243             $form->addCommandButton(
'saveSettings', $this->
lng->txt(
'save'));
   244             $form->addCommandButton(
'editSettings', $this->
lng->txt(
'cancel'));
   248         $act->setInfo($this->
lng->txt(
'badge_service_activate_info'));
   249         $form->addItem($act);
   252         $act->setChecked(
$handler->isActive());
   267         $this->tabs_gui->setTabActive(
'types');
   270         $this->
ctrl->setParameter($this, 
'returnCmd', __FUNCTION__);
   271         $tpl->renderTable(ILIAS_HTTP_PATH . 
'/' . $this->
ctrl->getLinkTarget($this, 
'action'));
   279         $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
   284                 if (!in_array(
$type, $tmpl_ids)) {
   285                     $change_state[] = 
$type;
   289             if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
   292                 $handler->setInactiveTypes($change_state);
   295             $this->tpl->setOnScreenMessage(
'success', 
$lng->
txt(
'settings_saved'), 
true);
   297         $this->
ctrl->redirect($this, 
'listTypes');
   305         $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
   310                 if (!in_array(
$type, $tmpl_ids)) {
   311                     $change_state[] = 
$type;
   316             if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
   317                 $types = 
$handler->getAvailableTypes(
false);
   323                 $handler->setInactiveTypes($change_state);
   325             $inactive = array_merge(
$handler->getInactiveTypes(), $tmpl_ids);
   326             $handler->setInactiveTypes($inactive);
   328             $this->tpl->setOnScreenMessage(
'success', 
$lng->
txt(
'settings_saved'), 
true);
   330         $this->
ctrl->redirect($this, 
'listTypes');
   345         $this->tabs_gui->setTabActive(
'imgtmpl');
   348             $ilToolbar->addButton(
   349                 $lng->
txt(
'badge_add_template'),
   350                 $ilCtrl->getLinkTarget($this, 
'addImageTemplate')
   355         $this->
ctrl->setParameter($this, 
'returnCmd', __FUNCTION__);
   356         $template_table->renderTable(ILIAS_HTTP_PATH . 
'/' . $this->
ctrl->getLinkTarget($this, 
'action'));
   368         $this->tabs_gui->setTabActive(
'imgtmpl');
   384         $form->setFormAction($ilCtrl->getFormAction($this, 
'saveBadge'));
   385         $form->setTitle(
$lng->
txt(
'badge_image_template_form'));
   388         $title->setMaxLength(255);
   389         $title->setRequired(
true);
   390         $form->addItem($title);
   394         if ($a_mode === 
'create') {
   395             $img->setRequired(
true);
   397         $img->setUseCache(
false);
   398         $img->setAllowDeletion(
false);
   399         $form->addItem($img);
   403         $types_mode->setValue(
'all');
   404         $form->addItem($types_mode);
   407         $types_mode->addOption($type_all);
   410         $types_mode->addOption($type_spec);
   414         $type_spec->addSubItem($types);
   420         if ($a_mode === 
'create') {
   421             $form->addCommandButton(
'saveImageTemplate', 
$lng->
txt(
'save'));
   423             $form->addCommandButton(
'updateImageTemplate', 
$lng->
txt(
'save'));
   425         $form->addCommandButton(
'listImageTemplates', 
$lng->
txt(
'cancel'));
   438         if ($form->checkInput()) {
   440             $tmpl->setTitle($form->getInput(
'title'));
   441             $tmpl->setTypes($form->getInput(
'type'));
   444             $tmpl->processImageUpload($tmpl);
   446             $this->tpl->setOnScreenMessage(
'success', 
$lng->
txt(
'settings_saved'), 
true);
   447             $ilCtrl->redirect($this, 
'listImageTemplates');
   450         $form->setValuesByPost();
   463         $this->tabs_gui->setTabActive(
'imgtmpl');
   465         $tmpl_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
   466         if (count($tmpl_ids) !== 1) {
   467             $this->
ctrl->redirect($this, 
'listImageTemplates');
   470         $template_id = (
int) array_pop($tmpl_ids);
   471         $ilCtrl->setParameter($this, 
'tid', $template_id);
   512         $tmpl_id = $this->badge_request->getTemplateId();
   514             $ilCtrl->redirect($this, 
'listImageTemplates');
   517         $ilCtrl->setParameter($this, 
'tid', $tmpl_id);
   522         if ($form->checkInput()) {
   523             $tmpl->setTitle($form->getInput(
'title'));
   525             if ($form->getInput(
'tmode') !== 
'all') {
   526                 $tmpl->setTypes($form->getInput(
'type'));
   528                 $tmpl->setTypes(null);
   533             $tmpl->processImageUpload($tmpl);
   535             $this->tpl->setOnScreenMessage(
'success', 
$lng->
txt(
'settings_saved'), 
true);
   536             $ilCtrl->redirect($this, 
'listImageTemplates');
   540         $form->setValuesByPost();
   553         $tmpl_ids = $this->badge_request->getBadgeAssignableUsers();
   554         if ($tmpl_ids === [
'ALL_OBJECTS']) {
   557                 $tmpl_ids[] = $template->getId();
   562             $ilCtrl->redirect($this, 
'listImageTemplates');
   565         $ilTabs->clearTargets();
   566         $ilTabs->setBackTarget(
   568             $ilCtrl->getLinkTarget($this, 
'listImageTemplates')
   572         $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
   573         $confirmation_gui->setHeaderText(
$lng->
txt(
'badge_template_deletion_confirmation'));
   574         $confirmation_gui->setCancel(
$lng->
txt(
'cancel'), 
'listImageTemplates');
   575         $confirmation_gui->setConfirm(
$lng->
txt(
'delete'), 
'deleteImageTemplates');
   577         foreach ($tmpl_ids as $tmpl_id) {
   579             $confirmation_gui->addItem(
'id[]', $tmpl_id, $tmpl->getTitle());
   588         $tmpl_ids = $this->badge_request->getIds();
   591             if (current($tmpl_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
   594                     $tmpl_ids[] = $template->getId();
   597             foreach ($tmpl_ids as $tmpl_id) {
   601             $this->tpl->setOnScreenMessage(
'success', 
$lng->
txt(
'badge_deletion'), 
true);
   603             $this->tpl->setOnScreenMessage(
'failure', 
$lng->
txt(
'badge_select_one'), 
true);
   606         $this->
ctrl->redirect($this, 
'listImageTemplates');
   626         $parent_obj_id = $this->badge_request->getParentId();
   627         if (!$parent_obj_id && $this->badge_request->getBadgeIdFromUrl()) {
   629             $badge = 
new ilBadge($this->badge_request->getBadgeIdFromUrl());
   630             $parent_obj_id = $badge->getParentId();
   632         if (!$parent_obj_id) {
   633             $this->
ctrl->redirect($this, 
'listObjectBadges');
   638         $this->tabs_gui->clearTargets();
   639         $this->tabs_gui->setBackTarget(
   640             $this->
lng->txt(
'back'),
   641             $this->
ctrl->getLinkTarget($this, 
'listObjectBadges')
   644         $this->
ctrl->saveParameter($this, 
'pid');
   646         $tbl = 
new ilBadgeUserTableGUI(null, null, $parent_obj_id, $this->badge_request->getBadgeId());
   647         $this->
ctrl->setParameter($this, 
'returnCmd', __FUNCTION__);
   648         $tbl->renderTable(ILIAS_HTTP_PATH . 
'/' . $this->
ctrl->getLinkTarget($this, 
'action'));
   664         $this->tabs_gui->setTabActive(
'obj_badges');
   667         $this->
ctrl->setParameter($this, 
'returnCmd', __FUNCTION__);
   668         $tbl->renderTable(ILIAS_HTTP_PATH . 
'/' . $this->
ctrl->getLinkTarget($this, 
'action'));
   680         $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
   682             !$ilAccess->checkAccess(
'write', 
'', $this->object->getRefId())) {
   683             $ilCtrl->
redirect($this, 
'listObjectBadges');
   695         if (current($badge_ids) === self::TABLE_ALL_OBJECTS_ACTION) {
   696             $filter = [
'type' => 
'' , 
'title' => 
'', 
'object' => 
''];
   699                 $badge_ids[] = $badge_item[
'id'];
   701             foreach ($badge_ids as $badge_id) {
   702                 $badge = 
new ilBadge($badge_id);
   703                 $badge->setActive($a_status);
   707             foreach ($badge_ids as $badge_id) {
   708                 $badge = 
new ilBadge($badge_id);
   709                 $badge->setActive($a_status);
   715         $this->tpl->setOnScreenMessage(
'success', 
$lng->
txt(
'settings_saved'), 
true);
   716         $ilCtrl->redirect($this, 
'listObjectBadges');
   736         $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromUrl();
   739         $ilTabs->setBackTarget(
   741             $ilCtrl->getLinkTarget($this, 
'listObjectBadges')
   745         $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
   746         $confirmation_gui->setHeaderText(
$lng->
txt(
'badge_deletion_confirmation'));
   747         $confirmation_gui->setCancel(
$lng->
txt(
'cancel'), 
'listObjectBadges');
   748         $confirmation_gui->setConfirm(
$lng->
txt(
'delete'), 
'deleteObjectBadges');
   750         if ($badge_ids === [
'ALL_OBJECTS']) {
   758                 $badge_ids[] = $badge_item[
'id'];
   761         foreach ($badge_ids as $badge_id) {
   762             $badge = 
new ilBadge($badge_id);
   763             $parent = $badge->getParentMeta();
   766                 $parent[
'id'] . 
') ' .
   768             if ($parent[
'deleted']) {
   769                 $container .= 
' <span class="il_ItemAlertProperty">' . 
$lng->
txt(
'deleted') . 
'</span>';
   772             $confirmation_gui->addItem(
   789         $badge_ids = $this->badge_request->getMultiActionBadgeIdsFromPost();
   791         foreach ($badge_ids as $badge_id) {
   792             $badge = 
new ilBadge($badge_id);
   796         $this->tpl->setOnScreenMessage(
'success', 
$lng->
txt(
'settings_saved'), 
true);
   797         $ilCtrl->redirect($this, 
'listObjectBadges');
 
ilBadgeGUIRequest $badge_request
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
resetlistObjectBadgeUsers()
 
ilBadgeManagementGUI: ilPropertyFormGUI 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
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...
 
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
 
prepareOutput(bool $show_sub_objects=true)
 
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
 
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)
 
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
 
setContent(string $a_html)
Sets content for standard template. 
 
editImageTemplate(ilPropertyFormGUI $a_form=null)
 
addImageTemplate(ilPropertyFormGUI $a_form=null)
 
static getInstancesByBadgeId(int $a_badge_id)
 
Class ilObjectGUI Basic methods of all Output classes. 
 
ILIAS ResourceStorage Services $resource_storage
 
clearTargets()
clear all targets 
 
applylistObjectBadgeUsers()
 
editSettings(ilPropertyFormGUI $a_form=null)
 
const TABLE_ALL_OBJECTS_ACTION
 
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
 
__construct(Container $dic, ilPlugin $plugin)
 
static getObjectInstances(?array $filter=null)
 
getSafePostCommands()
This method must return a list of safe POST commands. 
 
Interface ilCtrlSecurityInterface provides ilCtrl security information. 
 
toggleObjectBadges(bool $a_status)
 
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
 
confirmDeleteObjectBadges()