ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilRemoteObjectBaseGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24abstract class ilRemoteObjectBaseGUI extends ilObject2GUI
25{
27
28 public const TAB_ID_PERMISSIONS = "id_permissions";
29
30 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
31 {
32 global $DIC;
33
34 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
35
36 $this->logger = $DIC->logger()->wsrv();
37
38 $this->lng->loadLanguageModule('ecs');
39 }
40
41 public function executeCommand(): void
42 {
43 $next_class = $this->ctrl->getNextClass($this);
44 $cmd = $this->ctrl->getCmd();
45
46 $this->prepareOutput();
47 $this->logger->info("Can write:" . print_r($this->checkPermissionBool('write'), true));
48
49 switch ($next_class) {
50 case 'ilinfoscreengui':
51 // forwards command
52 $this->infoScreen();
53 break;
54
55 case 'ilpermissiongui':
56 $this->tabs_gui->activateTab('id_permissions');
57 $this->ctrl->forwardCommand(new ilPermissionGUI($this));
58 break;
59
60 case "ilcommonactiondispatchergui":
62 $this->ctrl->forwardCommand($gui);
63 break;
64
65 case strtolower(ilECSUserConsentModalGUI::class):
66 $consent_gui = new ilECSUserConsentModalGUI(
67 $this->user->getId(),
68 $this->ref_id,
69 $this
70 );
71 $this->ctrl->setReturn($this, 'call');
72 $this->ctrl->forwardCommand($consent_gui);
73 break;
74
75 default:
76 if (!$cmd || $cmd === 'view') {
77 $cmd = "infoScreen";
78 }
79 $cmd .= "Object";
80 $this->logger->info("cmd before call:" . print_r($cmd, true));
81 $this->$cmd();
82 break;
83 }
84 $this->logger->info("cmd:" . print_r($cmd, true));
85 }
86
90 public function showObject(): void
91 {
92 if ($this->user->getId() === ANONYMOUS_USER_ID ||
93 $this->object->isLocalObject()) {
94 $this->ctrl->redirectToURL($this->object->getRemoteLink());
95 } else {
96 $link = $this->object->getFullRemoteLink();
97 $this->ctrl->redirectToURL($link);
98 }
99 }
100
104 protected function setTabs(): void
105 {
106 if ($this->checkPermissionBool('visible')) {
107 $this->tabs_gui->addTab(
108 "info",
109 $this->lng->txt("info_short"),
110 $this->ctrl->getLinkTarget($this, "infoScreen")
111 );
112 }
113
114 if ($this->checkPermissionBool('write')) {
115 $this->tabs_gui->addTab(
116 "edit",
117 $this->lng->txt("edit"),
118 $this->ctrl->getLinkTarget($this, "edit")
119 );
120 }
121 if ($this->checkPermissionBool("edit_permission")) {
122 $this->tabs_gui->addTab(
123 self::TAB_ID_PERMISSIONS,
124 $this->lng->txt("perm_settings"),
125 $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
126 );
127 }
128 }
129
135 public function callObject(): bool
136 {
138 $this->getType(),
139 $this->object->getRefId(),
140 $this->object->getId(),
141 $this->user->getId()
142 );
143
144
145 // check if the assigned object is hosted on the same installation
146 $link = $this->object->getFullRemoteLink();
147 if ($link) {
148 $this->ctrl->redirectToURL($link);
149 return true;
150 }
151
152 $this->tpl->setOnScreenMessage('failure', 'Cannot call remote object.');
153 $this->infoScreenObject();
154 return false;
155 }
156
160 public function infoScreenObject(): void
161 {
162 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
163 }
164
168 public function infoScreen(): void
169 {
170 if (!$this->access->checkAccess("visible", "", $this->object->getRefId())) {
171 $this->error->raiseError(
172 $this->lng->txt('msg_no_perm_read'),
173 $this->error->MESSAGE
174 );
175 }
176
177 $this->ctrl->setReturn($this, 'call');
178 $consent_gui = new ilECSUserConsentModalGUI(
179 $this->user->getId(),
180 $this->ref_id,
181 $this
182 );
183 $consent_gui->addLinkToToolbar($this->toolbar);
184
185 $this->tabs_gui->activateTab('info');
186
187 $info = new ilInfoScreenGUI($this);
188
189 $info->addSection($this->lng->txt('ecs_general_info'));
190 $info->addProperty($this->lng->txt('title'), $this->object->getTitle());
191 if ($this->object->getOrganization()) {
192 $info->addProperty($this->lng->txt('organization'), $this->object->getOrganization());
193 }
194 if ($this->object->getDescription()) {
195 $info->addProperty($this->lng->txt('description'), $this->object->getDescription());
196 }
197 if ($this->object->getLocalInformation()) {
198 $info->addProperty($this->lng->txt('ecs_local_information'), $this->object->getLocalInformation());
199 }
200
202
203 $record_gui = new ilAdvancedMDRecordGUI(
205 $this->getType(),
206 $this->object->getId()
207 );
208 $record_gui->setInfoObject($info);
209 $record_gui->parse();
210
211 $this->ctrl->forwardCommand($info);
212 }
213
219 protected function addCustomInfoFields(ilInfoScreenGUI $a_info): void
220 {
221 // can be overwritten by subclasses
222 }
223
227 public function editObject(?ilPropertyFormGUI $form = null): void
228 {
229 if (!$this->access->checkAccess("write", "", $this->object->getRefId())) {
230 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
231 }
232 $this->logger->info("Can write:" . print_r($this->checkPermissionBool('write'), true));
233 $this->tabs_gui->activateTab('edit');
234
235 if (!$form) {
236 $form = $this->initEditForm();
237 }
238 $this->tpl->setContent($form->getHTML());
239 }
240
244 protected function initEditForm(): ilPropertyFormGUI
245 {
246 $form = new ilPropertyFormGUI();
247 $form->setFormAction($this->ctrl->getFormAction($this));
248 $form->setTitle($this->lng->txt('ecs_general_info'));
249 $form->addCommandButton('update', $this->lng->txt('save'));
250 $form->addCommandButton('edit', $this->lng->txt('cancel'));
251
252 $text = new ilTextInputGUI($this->lng->txt('title'), 'title');
253 $text->setValue($this->object->getTitle());
254 $text->setSize(min(40, ilObject::TITLE_LENGTH));
255 $text->setMaxLength(ilObject::TITLE_LENGTH);
256 $text->setDisabled(true);
257 $form->addItem($text);
258
259 $area = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
260 $area->setValue($this->object->getDescription());
261 $area->setRows(3);
262 $area->setCols(80);
263 $area->setDisabled(true);
264 $form->addItem($area);
265
266 $area = new ilTextAreaInputGUI($this->lng->txt('ecs_local_information'), 'local_info');
267 $area->setValue($this->object->getLocalInformation());
268 $area->setRows(3);
269 $area->setCols(80);
270 $form->addItem($area);
271
272 $this->addCustomEditForm($form);
273
274 $record_gui = new ilAdvancedMDRecordGUI(
276 $this->getType(),
277 $this->object->getId()
278 );
279 $record_gui->setPropertyForm($form);
280 $record_gui->parse();
281
282 return $form;
283 }
284
290 protected function addCustomEditForm(ilPropertyFormGUI $a_form): void
291 {
292 }
293
294 public function updateObject(): void
295 {
296 if (!$this->checkPermissionBool('write')) {
297 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
298 }
299
300 $form = $this->initEditForm();
301 if ($form->checkInput()) {
302 $this->object->setLocalInformation($form->getInput('local_info'));
303
304 $this->updateCustomValues($form);
305
306 $this->object->update();
307
308 // Save advanced meta data
309 $record_gui = new ilAdvancedMDRecordGUI(
311 $this->getType(),
312 $this->object->getId()
313 );
314 $record_gui->importEditFormPostValues();
315 $record_gui->writeEditForm();
316
317 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"));
318 $this->editObject();
319 }
320
321 $form->setValuesByPost();
322 $this->editObject($form);
323 }
324
330 protected function updateCustomValues(ilPropertyFormGUI $a_form): void
331 {
332 }
333
334 public static function _goto(string $a_target): void
335 {
336 global $DIC;
337
338 $ilAccess = $DIC->access();
339 $ilErr = $DIC["ilErr"];
340 $lng = $DIC->language();
341 if ($ilAccess->checkAccess("read", "", (int) $a_target)) {
342 ilObjectGUI::_gotoRepositoryNode((int) $a_target);
343 }
344
345 if ($ilAccess->checkAccess("visible", "", (int) $a_target)) {
346 ilObjectGUI::_gotoRepositoryNode((int) $a_target, "infoScreen");
347 }
348 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
349 }
350}
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
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
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
$info
Definition: entry_point.php:21
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ilErr
Definition: raiseError.php:33
global $DIC
Definition: shib_login.php:26