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