ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
class.ilObjHelpSettingsGUI.php
Go to the documentation of this file.
1<?php
2
20
26{
27 protected \ILIAS\Help\InternalGUIService $gui;
28 protected \ILIAS\Help\InternalDomainService $domain;
30 protected ilTabsGUI $tabs;
31
32 public function __construct(
33 int $a_id = 0,
34 int $a_id_type = self::REPOSITORY_NODE_ID,
35 int $a_parent_node_id = 0
36 ) {
37 global $DIC;
38
39 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
40
41 $service = $DIC->help()->internal();
42
43 $this->domain = $domain = $service->domain();
44 $this->gui = $gui = $service->gui();
45
46 $this->access = $domain->access();
47 $this->lng = $domain->lng();
48 $this->settings = $domain->settings();
49
50 $this->ctrl = $gui->ctrl();
51 $this->tabs = $gui->tabs();
52 $this->toolbar = $gui->toolbar();
53 $this->tpl = $gui->ui()->mainTemplate();
54
55 $this->help_request = $gui->standardRequest();
56 }
57
58 public function getType(): string
59 {
60 return "hlps";
61 }
62
63 public function executeCommand(): void
64 {
65 $this->lng->loadLanguageModule("help");
66
67 $next_class = $this->ctrl->getNextClass($this);
68 $cmd = $this->ctrl->getCmd();
69
70 $this->prepareOutput();
71
72 if (!$this->rbac_system->checkAccess("read", $this->object->getRefId())) {
73 throw new ilPermissionException($this->lng->txt('no_permission'));
74 }
75
76 switch ($next_class) {
77
78 case strtolower(ilGuidedTourAdminGUI::class):
79 $this->tabs_gui->setTabActive('guided_tour');
80 $gui = $this->gui->guidedTour()->adminGUI(
81 $this->checkPermissionBool("write")
82 );
83 $this->ctrl->forwardCommand($gui);
84 break;
85
86 case strtolower(ilPermissionGUI::class):
87 $this->tabs_gui->setTabActive('perm_settings');
88 $perm_gui = new ilPermissionGUI($this);
89 $this->ctrl->forwardCommand($perm_gui);
90 break;
91
92 default:
93 if (!$cmd || $cmd === 'view') {
94 $cmd = "editSettings";
95 }
96 $this->$cmd();
97 break;
98 }
99 }
100
101 public function editSettings(): void
102 {
103 $this->tabs->activateTab("settings");
104
105 if ($this->domain->module()->isAuthoringMode()) {
106 $this->tpl->setOnScreenMessage('info', "This installation is used for online help authoring. Help modules cannot be imported.");
107 return;
108 }
109
110 if ($this->checkPermissionBool("write")) {
111 // help file
112 $fi = new ilFileInputGUI($this->lng->txt("help_help_file"), "help_file");
113 $fi->setSuffixes(array("zip"));
114 $this->toolbar->addInputItem($fi, true);
115 $this->toolbar->addFormButton($this->lng->txt("upload"), "uploadHelpFile");
116 $this->toolbar->addSeparator();
117
118 // help mode
119 $options = array(
120 "" => $this->lng->txt("help_tooltips_and_help"),
121 "1" => $this->lng->txt("help_help_only"),
122 "2" => $this->lng->txt("help_tooltips_only")
123 );
124 $si = new ilSelectInputGUI($this->lng->txt("help_mode"), "help_mode");
125 $si->setOptions($options);
126 $si->setValue($this->settings->get("help_mode"));
127 $this->toolbar->addInputItem($si);
128
129 $this->toolbar->addFormButton($this->lng->txt("help_set_mode"), "setMode");
130 }
131 $this->toolbar->setFormAction($this->ctrl->getFormAction($this), true);
132
133 $table = new ilHelpModuleTableGUI($this, "editSettings", $this->checkPermissionBool("write"));
134
135 $this->tpl->setContent($table->getHTML());
136 }
137
138 public function getAdminTabs(): void
139 {
140 if ($this->checkPermissionBool("read")) {
141 $this->tabs_gui->addTab(
142 "settings",
143 $this->lng->txt("settings"),
144 $this->ctrl->getLinkTarget($this, "editSettings")
145 );
146 $this->tabs_gui->addTab(
147 "guided_tour",
148 $this->lng->txt("guided_tour"),
149 $this->ctrl->getLinkTargetByClass(ilGuidedTourAdminGUI::class)
150 );
151 }
152
153 if ($this->checkPermissionBool("edit_permission")) {
154 $this->tabs_gui->addTab(
155 "perm_settings",
156 $this->lng->txt("perm_settings"),
157 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
158 );
159 }
160 }
161
162 public function uploadHelpFile(): void
163 {
164 if (!isset($_FILES["help_file"]["tmp_name"]) || $_FILES["help_file"]["tmp_name"] === "") {
165 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("help_select_a_file"), true);
166 $this->ctrl->redirect($this, "editSettings");
167 }
168 if ($this->checkPermissionBool("write")) {
169 $this->domain->module()->upload($_FILES["help_file"]);
170 $this->tpl->setOnScreenMessage('success', $this->lng->txt("help_module_uploaded"), true);
171 }
172
173 $this->ctrl->redirect($this, "editSettings");
174 }
175
176 public function confirmHelpModulesDeletion(): void
177 {
178 $this->checkPermission("write");
179
180 $ids = $this->help_request->getIds();
181
182 if (count($ids) === 0) {
183 $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_checkbox"), true);
184 $this->ctrl->redirect($this, "editSettings");
185 } else {
186 $cgui = new ilConfirmationGUI();
187 $cgui->setFormAction($this->ctrl->getFormAction($this));
188 $cgui->setHeaderText($this->lng->txt("help_sure_delete_help_modules"));
189 $cgui->setCancel($this->lng->txt("cancel"), "editSettings");
190 $cgui->setConfirm($this->lng->txt("delete"), "deleteHelpModules");
191
192 foreach ($ids as $i) {
193 $cgui->addItem("id[]", $i, $this->domain->module()->lookupModuleLmId($i));
194 }
195
196 $this->tpl->setContent($cgui->getHTML());
197 }
198 }
199
200 public function deleteHelpModules(): void
201 {
202 $this->checkPermission("write");
203 $ids = $this->help_request->getIds();
204 foreach ($ids as $i) {
205 $this->domain->module()->deleteModule((int) $i);
206 }
207 $this->ctrl->redirect($this, "editSettings");
208 }
209
210 public function activateModule(): void
211 {
212 $this->checkPermission("write");
213 $this->domain->module()->activate($this->help_request->getHelpModuleId());
214 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
215 $this->ctrl->redirect($this, "editSettings");
216 }
217
218 public function deactivateModule(): void
219 {
220 $this->checkPermission("write");
221 $this->domain->module()->deactivate($this->help_request->getHelpModuleId());
222 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
223 $this->ctrl->redirect($this, "editSettings");
224 }
225
226 public function setMode(): void
227 {
228 $this->checkPermission("write");
229 if ($this->checkPermissionBool("write")) {
230 $this->settings->set(
231 "help_mode",
232 $this->help_request->getHelpMode()
233 );
234 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
235 }
236
237 $this->ctrl->redirect($this, "editSettings");
238 }
239
240 public function saveOrdering(): void
241 {
242 $this->checkPermission("write");
243 $this->domain->module()->saveOrder($this->help_request->getOrder());
244 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
245 $this->ctrl->redirect($this, "editSettings");
246 }
247
248}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a file property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@ilCtrl_Calls ilObjHelpSettingsGUI: ilPermissionGUI, ilGuidedTourAdminGUI @ilCtrl_isCalledBy ilObjHel...
__construct(int $a_id=0, int $a_id_type=self::REPOSITORY_NODE_ID, int $a_parent_node_id=0)
getAdminTabs()
administration tabs show only permissions and trash folder
getType()
Functions that must be overwritten.
ILIAS Help InternalGUIService $gui
ILIAS Help InternalDomainService $domain
New implementation of ilObjectGUI.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$service
Definition: ltiresult.php:36
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26