ILIAS  release_8 Revision v8.24
class.ilRemoteObjectBaseGUI.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
23abstract class ilRemoteObjectBaseGUI extends ilObject2GUI
24{
26
27 public const TAB_ID_PERMISSIONS = "id_permissions";
28
29 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
30 {
31 global $DIC;
32
33 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
34
35 $this->logger = $DIC->logger()->wsrv();
36
37 $this->lng->loadLanguageModule('ecs');
38 }
39
40 public function executeCommand(): void
41 {
42 $next_class = $this->ctrl->getNextClass($this);
43 $cmd = $this->ctrl->getCmd();
44
45 $this->prepareOutput();
46 $this->logger->info("Can write:" . print_r($this->checkPermissionBool('write'), true));
47
48 switch ($next_class) {
49 case 'ilinfoscreengui':
50 // forwards command
51 $this->infoScreen();
52 break;
53
54 case 'ilpermissiongui':
55 $this->tabs_gui->activateTab('id_permissions');
56 $this->ctrl->forwardCommand(new ilPermissionGUI($this));
57 break;
58
59 case "ilcommonactiondispatchergui":
61 $this->ctrl->forwardCommand($gui);
62 break;
63
64 case strtolower(ilECSUserConsentModalGUI::class):
65 $consent_gui = new ilECSUserConsentModalGUI(
66 $this->user->getId(),
67 $this->ref_id,
68 $this
69 );
70 $this->ctrl->setReturn($this, 'call');
71 $this->ctrl->forwardCommand($consent_gui);
72 break;
73
74 default:
75 if (!$cmd || $cmd === 'view') {
76 $cmd = "infoScreen";
77 }
78 $cmd .= "Object";
79 $this->logger->info("cmd before call:" . print_r($cmd, true));
80 $this->$cmd();
81 break;
82 }
83 $this->logger->info("cmd:" . print_r($cmd, true));
84 }
85
89 public function showObject(): void
90 {
91 if ($this->user->getId() === ANONYMOUS_USER_ID ||
92 $this->object->isLocalObject()) {
93 $this->ctrl->redirectToURL($this->object->getRemoteLink());
94 } else {
95 $link = $this->object->getFullRemoteLink();
96 $this->ctrl->redirectToURL($link);
97 }
98 }
99
103 protected function setTabs(): void
104 {
105 if ($this->checkPermissionBool('visible')) {
106 $this->tabs_gui->addTab(
107 "info",
108 $this->lng->txt("info_short"),
109 $this->ctrl->getLinkTarget($this, "infoScreen")
110 );
111 }
112
113 if ($this->checkPermissionBool('write')) {
114 $this->tabs_gui->addTab(
115 "edit",
116 $this->lng->txt("edit"),
117 $this->ctrl->getLinkTarget($this, "edit")
118 );
119 }
120 if ($this->checkPermissionBool("edit_permission")) {
121 $this->tabs_gui->addTab(
122 self::TAB_ID_PERMISSIONS,
123 $this->lng->txt("perm_settings"),
124 $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
125 );
126 }
127 }
128
134 public function callObject(): bool
135 {
137 $this->getType(),
138 $this->object->getRefId(),
139 $this->object->getId(),
140 $this->user->getId()
141 );
142
143
144 // check if the assigned object is hosted on the same installation
145 $link = $this->object->getFullRemoteLink();
146 if ($link) {
147 $this->ctrl->redirectToURL($link);
148 return true;
149 }
150
151 $this->tpl->setOnScreenMessage('failure', 'Cannot call remote object.');
152 $this->infoScreenObject();
153 return false;
154 }
155
161 public function infoScreenObject(): void
162 {
163 $this->ctrl->setCmd("showSummary");
164 $this->ctrl->setCmdClass("ilinfoscreengui");
165 $this->infoScreen();
166 }
167
171 public function infoScreen(): void
172 {
173 if (!$this->access->checkAccess("visible", "", $this->object->getRefId())) {
174 $this->error->raiseError(
175 $this->lng->txt('msg_no_perm_read'),
176 $this->error->MESSAGE
177 );
178 }
179
180 $this->ctrl->setReturn($this, 'call');
181 $consent_gui = new ilECSUserConsentModalGUI(
182 $this->user->getId(),
183 $this->ref_id,
184 $this
185 );
186 $consent_gui->addLinkToToolbar($this->toolbar);
187
188 $this->tabs_gui->activateTab('info');
189
190 $info = new ilInfoScreenGUI($this);
191
192 $info->addSection($this->lng->txt('ecs_general_info'));
193 $info->addProperty($this->lng->txt('title'), $this->object->getTitle());
194 if ($this->object->getOrganization()) {
195 $info->addProperty($this->lng->txt('organization'), $this->object->getOrganization());
196 }
197 if ($this->object->getDescription()) {
198 $info->addProperty($this->lng->txt('description'), $this->object->getDescription());
199 }
200 if ($this->object->getLocalInformation()) {
201 $info->addProperty($this->lng->txt('ecs_local_information'), $this->object->getLocalInformation());
202 }
203
204 $this->addCustomInfoFields($info);
205
206 $record_gui = new ilAdvancedMDRecordGUI(
208 $this->getType(),
209 $this->object->getId()
210 );
211 $record_gui->setInfoObject($info);
212 $record_gui->parse();
213
214 $this->ctrl->forwardCommand($info);
215 }
216
222 protected function addCustomInfoFields(ilInfoScreenGUI $a_info): void
223 {
224 // can be overwritten by subclasses
225 }
226
230 public function editObject(ilPropertyFormGUI $form = null): void
231 {
232 if (!$this->access->checkAccess("write", "", $this->object->getRefId())) {
233 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
234 }
235 $this->logger->info("Can write:" . print_r($this->checkPermissionBool('write'), true));
236 $this->tabs_gui->activateTab('edit');
237
238 if (!$form) {
239 $form = $this->initEditForm();
240 }
241 $this->tpl->setContent($form->getHTML());
242 }
243
247 protected function initEditForm(): ilPropertyFormGUI
248 {
249 $form = new ilPropertyFormGUI();
250 $form->setFormAction($this->ctrl->getFormAction($this));
251 $form->setTitle($this->lng->txt('ecs_general_info'));
252 $form->addCommandButton('update', $this->lng->txt('save'));
253 $form->addCommandButton('edit', $this->lng->txt('cancel'));
254
255 $text = new ilTextInputGUI($this->lng->txt('title'), 'title');
256 $text->setValue($this->object->getTitle());
257 $text->setSize(min(40, ilObject::TITLE_LENGTH));
258 $text->setMaxLength(ilObject::TITLE_LENGTH);
259 $text->setDisabled(true);
260 $form->addItem($text);
261
262 $area = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
263 $area->setValue($this->object->getDescription());
264 $area->setRows(3);
265 $area->setCols(80);
266 $area->setDisabled(true);
267 $form->addItem($area);
268
269 $area = new ilTextAreaInputGUI($this->lng->txt('ecs_local_information'), 'local_info');
270 $area->setValue($this->object->getLocalInformation());
271 $area->setRows(3);
272 $area->setCols(80);
273 $form->addItem($area);
274
275 $this->addCustomEditForm($form);
276
277 $record_gui = new ilAdvancedMDRecordGUI(
279 $this->getType(),
280 $this->object->getId()
281 );
282 $record_gui->setPropertyForm($form);
283 $record_gui->parse();
284
285 return $form;
286 }
287
293 protected function addCustomEditForm(ilPropertyFormGUI $a_form): void
294 {
295 }
296
297 public function updateObject(): void
298 {
299 if (!$this->checkPermissionBool('write')) {
300 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
301 }
302
303 $form = $this->initEditForm();
304 if ($form->checkInput()) {
305 $this->object->setLocalInformation($form->getInput('local_info'));
306
307 $this->updateCustomValues($form);
308
309 $this->object->update();
310
311 // Save advanced meta data
312 $record_gui = new ilAdvancedMDRecordGUI(
314 $this->getType(),
315 $this->object->getId()
316 );
317 $record_gui->importEditFormPostValues();
318 $record_gui->writeEditForm();
319
320 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"));
321 $this->editObject();
322 }
323
324 $form->setValuesByPost();
325 $this->editObject($form);
326 }
327
333 protected function updateCustomValues(ilPropertyFormGUI $a_form): void
334 {
335 }
336
337 public static function _goto(string $a_target): void
338 {
339 global $DIC;
340
341 $ilAccess = $DIC->access();
342 $ilErr = $DIC["ilErr"];
343 $lng = $DIC->language();
344 if ($ilAccess->checkAccess("read", "", (int) $a_target)) {
345 ilObjectGUI::_gotoRepositoryNode((int) $a_target);
346 }
347
348 if ($ilAccess->checkAccess("visible", "", (int) $a_target)) {
349 ilObjectGUI::_gotoRepositoryNode((int) $a_target, "infoScreen");
350 }
351 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
352 }
353}
error(string $a_errmsg)
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Class ilInfoScreenGUI.
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...
Component logger with individual log levels by component id.
New implementation of ilObjectGUI.
getType()
Functions that must be overwritten.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
prepareOutput(bool $show_sub_objects=true)
static _gotoRepositoryNode(int $ref_id, string $cmd="")
const TITLE_LENGTH
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
updateObject()
updates object entry in object_data
addCustomEditForm(ilPropertyFormGUI $a_form)
Add custom fields to edit form.
static _goto(string $a_target)
addCustomInfoFields(ilInfoScreenGUI $a_info)
Add custom fields to info screen.
initEditForm()
Init edit settings form.
editObject(ilPropertyFormGUI $form=null)
Edit settings.
updateCustomValues(ilPropertyFormGUI $a_form)
Update object custom values.
This class represents a text area property in a property form.
This class represents a text property in a property form.
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ilErr
Definition: raiseError.php:17