ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjLearningHistorySettingsGUI.php
Go to the documentation of this file.
1<?php
2
26{
28 protected ilTabsGUI $tabs;
29 protected \ILIAS\DI\UIServices $ui;
32
33 public function __construct(
34 $a_data,
35 int $a_id,
36 bool $a_call_by_reference = true,
37 bool $a_prepare_output = true
38 ) {
39 global $DIC;
40
41 $this->lng = $DIC->language();
42 $this->rbacsystem = $DIC->rbac()->system();
43 $this->ctrl = $DIC->ctrl();
44 $this->request = $DIC->http()->request();
45 $this->tabs = $DIC->tabs();
46 $this->ui = $DIC->ui();
47 $this->setting = $DIC->settings();
48 $this->main_tpl = $DIC->ui()->mainTemplate();
49
50 $this->type = 'lhts';
51
52 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
53
54 $this->lng->loadLanguageModule("lhist");
55 }
56
57 public function executeCommand(): void
58 {
62
63 $next_class = $ctrl->getNextClass($this);
64 $cmd = $ctrl->getCmd("editSettings");
65
66 if (!$rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
67 throw new ilPermissionException($this->lng->txt('no_permission'));
68 }
69
70 $this->prepareOutput();
71
72 switch ($next_class) {
73 case 'ilpermissiongui':
74 $tabs->activateTab('perm_settings');
75 $perm_gui = new ilPermissionGUI($this);
76 $ctrl->forwardCommand($perm_gui);
77 break;
78
79 default:
80 if ($cmd === "view") {
81 $cmd = "editSettings";
82 }
83 if (in_array($cmd, ["editSettings", "saveSettings"])) {
84 $this->$cmd();
85 }
86 break;
87 }
88 }
89
90 public function getAdminTabs(): void
91 {
96
97 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
99 "settings",
100 $lng->txt("settings"),
101 $ctrl->getLinkTarget($this, "editSettings")
102 );
103 }
104
105 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
106 $tabs->addTab(
107 "perm_settings",
108 $lng->txt("perm_settings"),
109 $ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
110 );
111 }
112 }
113
114 public function editSettings(): void
115 {
117 $ui = $this->ui;
119
120 $tabs->activateTab("settings");
121
122 $form = $this->initForm();
123 $main_tpl->setContent($ui->renderer()->render($form));
124 }
125
126 public function initForm(): \ILIAS\UI\Component\Input\Container\Form\Standard
127 {
128 $ui = $this->ui;
129 $f = $ui->factory();
133
134 $fields["enable_learning_history"] = $f->input()->field()->checkbox(
135 $lng->txt("lhist_enable_learning_history"),
136 $lng->txt("lhist_enable_learning_history_info")
137 )
138 ->withValue((bool) $setting->get("enable_learning_history"));
139
140 // section
141 $section1 = $f->input()->field()->section($fields, $lng->txt("settings"));
142
143
144 $form_action = $ctrl->getLinkTarget($this, "saveSettings");
145 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
146 }
147
148 public function saveSettings(): void
149 {
151 $form = $this->initForm();
154 $setting = $this->setting;
155
156 if ($request->getMethod() === "POST") {
157 $form = $form->withRequest($request);
158 $data = $form->getData();
159 if (is_array($data["sec"])) {
160 $setting->set("enable_learning_history", (int) ($data["sec"]["enable_learning_history"]));
161 $this->main_tpl->setOnScreenMessage('info', $lng->txt("msg_obj_modified"), true);
162 }
163 }
164 $ctrl->redirect($this, "editSettings");
165 }
166}
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
getNextClass($a_gui_class=null)
@inheritDoc
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
forwardCommand(object $a_gui_object)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAdminTabs()
administration tabs show only permissions and trash folder
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput(bool $show_sub_objects=true)
ServerRequestInterface $request
ilLanguage $lng
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 ...
ILIAS Setting Class.
set(string $a_key, string $a_val)
get(string $a_keyword, ?string $a_default_value=null)
get setting
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.
activateTab(string $a_id)
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26