ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjLearningHistorySettingsGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
14{
18 protected $rbacsystem;
19
23 protected $error;
24
28 protected $request;
29
33 protected $tabs;
34
38 protected $ui;
39
40
44 protected $setting;
45
49 protected $main_tpl;
50
51
57 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
58 {
59 global $DIC;
60
61 $this->lng = $DIC->language();
62 $this->rbacsystem = $DIC->rbac()->system();
63 $this->error = $DIC["ilErr"];
64 $this->ctrl = $DIC->ctrl();
65 $this->request = $DIC->http()->request();
66 $this->tabs = $DIC->tabs();
67 $this->ui = $DIC->ui();
68 $this->setting = $DIC->settings();
69 $this->main_tpl = $DIC->ui()->mainTemplate();
70
71 $this->type = 'lhts';
72
73 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
74
75 $this->lng->loadLanguageModule("lhist");
76 }
77
82 public function executeCommand()
83 {
87
88 $next_class = $ctrl->getNextClass($this);
89 $cmd = $ctrl->getCmd("editSettings");
90
91 if (!$rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
92 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
93 }
94
95 $this->prepareOutput();
96
97 switch ($next_class) {
98 case 'ilpermissiongui':
99 $tabs->activateTab('perm_settings');
100 $perm_gui = new ilPermissionGUI($this);
101 $ctrl->forwardCommand($perm_gui);
102 break;
103
104 default:
105 if ($cmd == "view") {
106 $cmd = "editSettings";
107 }
108 if (in_array($cmd, ["editSettings", "saveSettings"])) {
109 $this->$cmd();
110 }
111 break;
112 }
113 }
114
118 public function getAdminTabs()
119 {
124
125 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
126 $tabs->addTab(
127 "settings",
128 $lng->txt("settings"),
129 $ctrl->getLinkTarget($this, "editSettings")
130 );
131 }
132
133 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
134 $tabs->addTab(
135 "perm_settings",
136 $lng->txt("perm_settings"),
137 $ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
138 );
139 }
140 }
141
145 public function editSettings()
146 {
148 $ui = $this->ui;
150
151 $tabs->activateTab("settings");
152
153 $form = $this->initForm();
154 $main_tpl->setContent($ui->renderer()->render($form));
155 }
156
161 public function initForm()
162 {
163 $ui = $this->ui;
164 $f = $ui->factory();
168
169 $fields["enable_learning_history"] = $f->input()->field()->checkbox(
170 $lng->txt("lhist_enable_learning_history"),
171 $lng->txt("lhist_enable_learning_history_info")
172 )
173 ->withValue((bool) $setting->get("enable_learning_history"));
174
175 // section
176 $section1 = $f->input()->field()->section($fields, $lng->txt("settings"));
177
178
179 $form_action = $ctrl->getLinkTarget($this, "saveSettings");
180 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
181 }
182
186 public function saveSettings()
187 {
189 $form = $this->initForm();
193
194 if ($request->getMethod() == "POST") {
195 $form = $form->withRequest($request);
196 $data = $form->getData();
197 if (is_array($data["sec"])) {
198 $setting->set("enable_learning_history", (int) ($data["sec"]["enable_learning_history"]));
199 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
200 }
201 }
202 $ctrl->redirect($this, "editSettings");
203 }
204}
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
ui()
Definition: ui.php:5