ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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->ctrl->forwardCommand($gui);
82 break;
83
84 case strtolower(ilPermissionGUI::class):
85 $this->tabs_gui->setTabActive('perm_settings');
86 $perm_gui = new ilPermissionGUI($this);
87 $this->ctrl->forwardCommand($perm_gui);
88 break;
89
90 default:
91 if (!$cmd || $cmd === 'view') {
92 $cmd = "editSettings";
93 }
94 $this->$cmd();
95 break;
96 }
97 }
98
99 public function editSettings(): void
100 {
101 $this->tabs->activateTab("settings");
102
103 if ($this->domain->module()->isAuthoringMode()) {
104 $this->tpl->setOnScreenMessage('info', "This installation is used for online help authoring. Help modules cannot be imported.");
105 return;
106 }
107
108 if ($this->checkPermissionBool("write")) {
109 // help file
110 $fi = new ilFileInputGUI($this->lng->txt("help_help_file"), "help_file");
111 $fi->setSuffixes(array("zip"));
112 $this->toolbar->addInputItem($fi, true);
113 $this->toolbar->addFormButton($this->lng->txt("upload"), "uploadHelpFile");
114 $this->toolbar->addSeparator();
115
116 // help mode
117 $options = array(
118 "" => $this->lng->txt("help_tooltips_and_help"),
119 "1" => $this->lng->txt("help_help_only"),
120 "2" => $this->lng->txt("help_tooltips_only")
121 );
122 $si = new ilSelectInputGUI($this->lng->txt("help_mode"), "help_mode");
123 $si->setOptions($options);
124 $si->setValue($this->settings->get("help_mode"));
125 $this->toolbar->addInputItem($si);
126
127 $this->toolbar->addFormButton($this->lng->txt("help_set_mode"), "setMode");
128 }
129 $this->toolbar->setFormAction($this->ctrl->getFormAction($this), true);
130
131 $table = new ilHelpModuleTableGUI($this, "editSettings", $this->checkPermissionBool("write"));
132
133 $this->tpl->setContent($table->getHTML());
134 }
135
136 public function getAdminTabs(): void
137 {
138 if ($this->checkPermissionBool("read")) {
139 $this->tabs_gui->addTab(
140 "settings",
141 $this->lng->txt("settings"),
142 $this->ctrl->getLinkTarget($this, "editSettings")
143 );
144 $this->tabs_gui->addTab(
145 "guided_tour",
146 $this->lng->txt("guided_tour"),
147 $this->ctrl->getLinkTargetByClass(ilGuidedTourAdminGUI::class)
148 );
149 }
150
151 if ($this->checkPermissionBool("edit_permission")) {
152 $this->tabs_gui->addTab(
153 "perm_settings",
154 $this->lng->txt("perm_settings"),
155 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
156 );
157 }
158 }
159
160 public function uploadHelpFile(): void
161 {
162 if (!isset($_FILES["help_file"]["tmp_name"]) || $_FILES["help_file"]["tmp_name"] === "") {
163 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("help_select_a_file"), true);
164 $this->ctrl->redirect($this, "editSettings");
165 }
166 if ($this->checkPermissionBool("write")) {
167 $this->domain->module()->upload($_FILES["help_file"]);
168 $this->tpl->setOnScreenMessage('success', $this->lng->txt("help_module_uploaded"), true);
169 }
170
171 $this->ctrl->redirect($this, "editSettings");
172 }
173
174 public function confirmHelpModulesDeletion(): void
175 {
176 $this->checkPermission("write");
177
178 $ids = $this->help_request->getIds();
179
180 if (count($ids) === 0) {
181 $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_checkbox"), true);
182 $this->ctrl->redirect($this, "editSettings");
183 } else {
184 $cgui = new ilConfirmationGUI();
185 $cgui->setFormAction($this->ctrl->getFormAction($this));
186 $cgui->setHeaderText($this->lng->txt("help_sure_delete_help_modules"));
187 $cgui->setCancel($this->lng->txt("cancel"), "editSettings");
188 $cgui->setConfirm($this->lng->txt("delete"), "deleteHelpModules");
189
190 foreach ($ids as $i) {
191 $cgui->addItem("id[]", $i, $this->domain->module()->lookupModuleLmId($i));
192 }
193
194 $this->tpl->setContent($cgui->getHTML());
195 }
196 }
197
198 public function deleteHelpModules(): void
199 {
200 $this->checkPermission("write");
201 $ids = $this->help_request->getIds();
202 foreach ($ids as $i) {
203 $this->domain->module()->deleteModule((int) $i);
204 }
205 $this->ctrl->redirect($this, "editSettings");
206 }
207
208 public function activateModule(): void
209 {
210 $this->checkPermission("write");
211 $this->domain->module()->activate($this->help_request->getHelpModuleId());
212 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
213 $this->ctrl->redirect($this, "editSettings");
214 }
215
216 public function deactivateModule(): void
217 {
218 $this->checkPermission("write");
219 $this->domain->module()->deactivate($this->help_request->getHelpModuleId());
220 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
221 $this->ctrl->redirect($this, "editSettings");
222 }
223
224 public function setMode(): void
225 {
226 $this->checkPermission("write");
227 if ($this->checkPermissionBool("write")) {
228 $this->settings->set(
229 "help_mode",
230 $this->help_request->getHelpMode()
231 );
232 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
233 }
234
235 $this->ctrl->redirect($this, "editSettings");
236 }
237
238 public function saveOrdering(): void
239 {
240 $this->checkPermission("write");
241 $this->domain->module()->saveOrder($this->help_request->getOrder());
242 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
243 $this->ctrl->redirect($this, "editSettings");
244 }
245
246}
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