ILIAS  release_8 Revision v8.24
class.ilObjHelpSettingsGUI.php
Go to the documentation of this file.
1<?php
2
20
29{
31 protected ilTabsGUI $tabs;
32
33 public function __construct(
34 int $a_id = 0,
35 int $a_id_type = self::REPOSITORY_NODE_ID,
36 int $a_parent_node_id = 0
37 ) {
38 global $DIC;
39 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
40
41 $this->access = $DIC->access();
42 $this->lng = $DIC->language();
43 $this->ctrl = $DIC->ctrl();
44 $this->settings = $DIC->settings();
45 $this->tabs = $DIC->tabs();
46 $this->toolbar = $DIC->toolbar();
47 $this->tpl = $DIC["tpl"];
48
49 $this->help_request = new StandardGUIRequest(
50 $DIC->http(),
51 $DIC->refinery()
52 );
53 }
54
55 public function getType(): string
56 {
57 return "hlps";
58 }
59
60 public function executeCommand(): void
61 {
63 $lng->loadLanguageModule("help");
64
65 $next_class = $this->ctrl->getNextClass($this);
66 $cmd = $this->ctrl->getCmd();
67
68 $this->prepareOutput();
69
70 if (!$this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
71 throw new ilPermissionException($this->lng->txt('no_permission'));
72 }
73
74 switch ($next_class) {
75 case 'ilpermissiongui':
76 $this->tabs_gui->setTabActive('perm_settings');
77 $perm_gui = new ilPermissionGUI($this);
78 $this->ctrl->forwardCommand($perm_gui);
79 break;
80
81 default:
82 if (!$cmd || $cmd === 'view') {
83 $cmd = "editSettings";
84 }
85
86 $this->$cmd();
87 break;
88 }
89 }
90
91 public function editSettings(): void
92 {
93 $ilCtrl = $this->ctrl;
96 $ilTabs = $this->tabs;
97 $ilToolbar = $this->toolbar;
98
99 $ilTabs->activateTab("settings");
100
101 if ((int) OH_REF_ID > 0) {
102 $this->tpl->setOnScreenMessage('info', "This installation is used for online help authoring. Help modules cannot be imported.");
103 return;
104 }
105
106 if ($this->checkPermissionBool("write")) {
107 // help file
108 $fi = new ilFileInputGUI($lng->txt("help_help_file"), "help_file");
109 $fi->setSuffixes(array("zip"));
110 $ilToolbar->addInputItem($fi, true);
111 $ilToolbar->addFormButton($lng->txt("upload"), "uploadHelpFile");
112 $ilToolbar->addSeparator();
113
114 // help mode
115 $options = array(
116 "" => $lng->txt("help_tooltips_and_help"),
117 "1" => $lng->txt("help_help_only"),
118 "2" => $lng->txt("help_tooltips_only")
119 );
120 $si = new ilSelectInputGUI($this->lng->txt("help_mode"), "help_mode");
121 $si->setOptions($options);
122 $si->setValue($ilSetting->get("help_mode"));
123 $ilToolbar->addInputItem($si);
124
125 $ilToolbar->addFormButton($lng->txt("help_set_mode"), "setMode");
126 }
127 $ilToolbar->setFormAction($ilCtrl->getFormAction($this), true);
128
129 $tab = new ilHelpModuleTableGUI($this, "editSettings", $this->checkPermissionBool("write"));
130
131 $this->tpl->setContent($tab->getHTML());
132 }
133
134 public function getAdminTabs(): void
135 {
136 if ($this->checkPermissionBool("visible,read")) {
137 $this->tabs_gui->addTab(
138 "settings",
139 $this->lng->txt("settings"),
140 $this->ctrl->getLinkTarget($this, "editSettings")
141 );
142 }
143
144 if ($this->checkPermissionBool("edit_permission")) {
145 $this->tabs_gui->addTab(
146 "perm_settings",
147 $this->lng->txt("perm_settings"),
148 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
149 );
150 }
151 }
152
153 public function uploadHelpFile(): void
154 {
156 $ilCtrl = $this->ctrl;
157
158 if (!isset($_FILES["help_file"]["tmp_name"]) || $_FILES["help_file"]["tmp_name"] === "") {
159 $this->tpl->setOnScreenMessage('failure', $lng->txt("help_select_a_file"), true);
160 $ilCtrl->redirect($this, "editSettings");
161 }
162 if ($this->checkPermissionBool("write")) {
163 $this->object->uploadHelpModule($_FILES["help_file"]);
164 $this->tpl->setOnScreenMessage('success', $lng->txt("help_module_uploaded"), true);
165 }
166
167 $ilCtrl->redirect($this, "editSettings");
168 }
169
170 public function confirmHelpModulesDeletion(): void
171 {
172 $ilCtrl = $this->ctrl;
175
176 $this->checkPermission("write");
177
178 $ids = $this->help_request->getIds();
179
180 if (count($ids) === 0) {
181 $this->tpl->setOnScreenMessage('info', $lng->txt("no_checkbox"), true);
182 $ilCtrl->redirect($this, "editSettings");
183 } else {
184 $cgui = new ilConfirmationGUI();
185 $cgui->setFormAction($ilCtrl->getFormAction($this));
186 $cgui->setHeaderText($lng->txt("help_sure_delete_help_modules"));
187 $cgui->setCancel($lng->txt("cancel"), "editSettings");
188 $cgui->setConfirm($lng->txt("delete"), "deleteHelpModules");
189
190 foreach ($ids as $i) {
191 $cgui->addItem("id[]", $i, $this->object::lookupModuleTitle($i));
192 }
193
194 $tpl->setContent($cgui->getHTML());
195 }
196 }
197
198 public function deleteHelpModules(): void
199 {
200 $ilCtrl = $this->ctrl;
201
202 $this->checkPermission("write");
203
204 $ids = $this->help_request->getIds();
205 foreach ($ids as $i) {
206 $this->object->deleteModule((int) $i);
207 }
208
209 $ilCtrl->redirect($this, "editSettings");
210 }
211
212 public function activateModule(): void
213 {
216 $ilCtrl = $this->ctrl;
217
218 $this->checkPermission("write");
219
220 $ilSetting->set("help_module", $this->help_request->getHelpModuleId());
221 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
222 $ilCtrl->redirect($this, "editSettings");
223 }
224
225 public function deactivateModule(): void
226 {
229 $ilCtrl = $this->ctrl;
230
231 $this->checkPermission("write");
232
233 if ((int) $ilSetting->get("help_module") === $this->help_request->getHelpModuleId()) {
234 $ilSetting->set("help_module", "");
235 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
236 }
237 $ilCtrl->redirect($this, "editSettings");
238 }
239
240 public function setMode(): void
241 {
243 $ilCtrl = $this->ctrl;
245
246 $this->checkPermission("write");
247
248 if ($this->checkPermissionBool("write")) {
249 $ilSetting->set(
250 "help_mode",
251 $this->help_request->getHelpMode()
252 );
253 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
254 }
255
256 $ilCtrl->redirect($this, "editSettings");
257 }
258}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
@inheritDoc
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...
loadLanguageModule(string $a_module)
Load language module.
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...
Help settings gui class.
__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.
New implementation of ilObjectGUI.
ilGlobalTemplateInterface $tpl
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
prepareOutput(bool $show_sub_objects=true)
checkPermission(string $perm, string $cmd="", string $type="", int $ref_id=null)
ilToolbarGUI $toolbar
ilSetting $settings
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
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...
global $DIC
Definition: feed.php:28
setContent(string $a_html)
Sets content for standard template.
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17