ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilRemoteObjectBaseGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('Services/Object/classes/class.ilObject2GUI.php');
5
13abstract class ilRemoteObjectBaseGUI extends ilObject2GUI
14{
15 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
16 {
17 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
18
19 $this->lng->loadLanguageModule('ecs');
20 }
21
22 public function executeCommand()
23 {
24 global $DIC;
25
26 $ilTabs = $DIC['ilTabs'];
27
28 $next_class = $this->ctrl->getNextClass($this);
29 $cmd = $this->ctrl->getCmd();
30
31 $this->prepareOutput();
32
33 switch ($next_class) {
34 case 'ilinfoscreengui':
35 // forwards command
36 $this->infoScreen();
37 break;
38
39 case 'ilpermissiongui':
40 $ilTabs->activateTab('id_permissions');
41 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
42 $this->ctrl->forwardCommand(new ilPermissionGUI($this));
43 break;
44
45 case "ilcommonactiondispatchergui":
46 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
48 $this->ctrl->forwardCommand($gui);
49 break;
50
51 default:
52 if (!$cmd || $cmd == 'view') {
53 $cmd = "editSettings";
54 }
55 $cmd .= "Object";
56 $this->$cmd();
57 break;
58 }
59 return true;
60 }
61
65 public function showObject()
66 {
67 global $DIC;
68
69 $ilUser = $DIC['ilUser'];
70
71 if ($ilUser->getId() == ANONYMOUS_USER_ID ||
72 $this->object->isLocalObject()) {
73 ilUtil::redirect($this->object->getRemoteLink());
74 } else {
75 $link = $this->object->getFullRemoteLink();
76 ilUtil::redirect($link);
77 }
78 }
79
83 public function setTabs()
84 {
85 global $DIC;
86
87 $ilTabs = $DIC['ilTabs'];
88
89 if ($this->checkPermissionBool('visible')) {
90 $ilTabs->addTab(
91 "info",
92 $this->lng->txt("info_short"),
93 $this->ctrl->getLinkTarget($this, "infoScreen")
94 );
95 }
96
97 if ($this->checkPermissionBool('write')) {
98 $ilTabs->addTab(
99 "edit",
100 $this->lng->txt("edit"),
101 $this->ctrl->getLinkTarget($this, "edit")
102 );
103 }
104
105 // will add permissions if needed
106 parent::setTabs();
107 }
108
114 public function callObject()
115 {
116 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
118 $this->getType(),
119 $this->object->getRefId(),
120 $this->object->getId(),
121 $GLOBALS['DIC']['ilUser']->getId()
122 );
123
124
125 // check if the assigned object is hosted on the same installation
126 $link = $this->object->getFullRemoteLink();
127 if ($link) {
128 ilUtil::redirect($link);
129 return true;
130 } else {
131 ilUtil::sendFailure('Cannot call remote object.');
132 $this->infoScreenObject();
133 return false;
134 }
135 }
136
142 public function infoScreenObject()
143 {
144 $this->ctrl->setCmd("showSummary");
145 $this->ctrl->setCmdClass("ilinfoscreengui");
146 $this->infoScreen();
147 }
148
152 public function infoScreen()
153 {
154 global $DIC;
155
156 $ilErr = $DIC['ilErr'];
157 $ilUser = $DIC['ilUser'];
158 $ilTabs = $DIC['ilTabs'];
159
160 if (!$this->checkPermissionBool('visible')) {
161 $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
162 }
163
164 $ilTabs->activateTab('info');
165
166 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
167 $info = new ilInfoScreenGUI($this);
168
169 if ($ilUser->getId() == ANONYMOUS_USER_ID ||
170 $this->object->isLocalObject()) {
171 $info->addButton(
172 $this->lng->txt($this->getType() . '_call'),
173 $this->object->getRemoteLink(),
174 'target="_blank"'
175 );
176 } else {
177 $info->addButton(
178 $this->lng->txt($this->getType() . '_call'),
179 $this->ctrl->getLinkTarget($this, 'call'),
180 'target="_blank"'
181 );
182 }
183
184 $info->addSection($this->lng->txt('ecs_general_info'));
185 $info->addProperty($this->lng->txt('title'), $this->object->getTitle());
186 if (strlen($this->object->getOrganization())) {
187 $info->addProperty($this->lng->txt('organization'), $this->object->getOrganization());
188 }
189 if (strlen($this->object->getDescription())) {
190 $info->addProperty($this->lng->txt('description'), $this->object->getDescription());
191 }
192 if (strlen($loc = $this->object->getLocalInformation())) {
193 $info->addProperty($this->lng->txt('ecs_local_information'), $this->object->getLocalInformation());
194 }
195
196 $this->addCustomInfoFields($info);
197
198 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
199 $record_gui = new ilAdvancedMDRecordGUI(
201 $this->getType(),
202 $this->object->getId()
203 );
204 $record_gui->setInfoObject($info);
205 $record_gui->parse();
206
207 $this->ctrl->forwardCommand($info);
208 }
209
215 protected function addCustomInfoFields(ilInfoScreenGUI $a_info)
216 {
217 }
218
224 public function editObject(ilPropertyFormGUI $a_form = null)
225 {
226 global $DIC;
227
228 $ilErr = $DIC['ilErr'];
229 $ilTabs = $DIC['ilTabs'];
230
231 if (!$this->checkPermissionBool('write')) {
232 $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
233 }
234
235 $ilTabs->activateTab('edit');
236
237 if (!$a_form) {
238 $a_form = $this->initEditForm();
239 }
240 $this->tpl->setContent($a_form->getHTML());
241 }
242
248 protected function initEditForm()
249 {
250 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
251 $form = new ilPropertyFormGUI();
252 $form->setFormAction($this->ctrl->getFormAction($this));
253 $form->setTitle($this->lng->txt('ecs_general_info'));
254 $form->addCommandButton('update', $this->lng->txt('save'));
255 $form->addCommandButton('edit', $this->lng->txt('cancel'));
256
257 $text = new ilTextInputGUI($this->lng->txt('title'), 'title');
258 $text->setValue($this->object->getTitle());
259 $text->setSize(min(40, ilObject::TITLE_LENGTH));
260 $text->setMaxLength(ilObject::TITLE_LENGTH);
261 $text->setDisabled(true);
262 $form->addItem($text);
263
264 $area = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
265 $area->setValue($this->object->getDescription());
266 $area->setRows(3);
267 $area->setCols(80);
268 $area->setDisabled(true);
269 $form->addItem($area);
270
271 $area = new ilTextAreaInputGUI($this->lng->txt('ecs_local_information'), 'local_info');
272 $area->setValue($this->object->getLocalInformation());
273 $area->setRows(3);
274 $area->setCols(80);
275 $form->addItem($area);
276
277 $this->addCustomEditForm($form);
278
279 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
280 $record_gui = new ilAdvancedMDRecordGUI(
282 $this->getType(),
283 $this->object->getId()
284 );
285 $record_gui->setPropertyForm($form);
286 $record_gui->parse();
287
288 return $form;
289 }
290
296 protected function addCustomEditForm(ilPropertyFormGUI $a_form)
297 {
298 }
299
303 public function updateObject()
304 {
305 global $DIC;
306
307 $ilErr = $DIC['ilErr'];
308
309 if (!$this->checkPermissionBool('write')) {
310 $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
311 }
312
313 $form = $this->initEditForm();
314 if ($form->checkInput()) {
315 $this->object->setLocalInformation($a_form->getInput('local_info'));
316
317 $this->updateCustomValues($form);
318
319 $this->object->update();
320
321 // Save advanced meta data
322 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
323 $record_gui = new ilAdvancedMDRecordGUI(
325 $this->getType(),
326 $this->object->getId()
327 );
328 $record_gui->loadFromPost();
329 $record_gui->saveValues();
330
331 ilUtil::sendSuccess($this->lng->txt("settings_saved"));
332 $this->editObject();
333 }
334
335 $form->setValuesByPost();
336 $this->editObject($form);
337 }
338
344 protected function updateCustomValues(ilPropertyFormGUI $a_form)
345 {
346 }
347
353 public static function _goto($a_target)
354 {
355 global $DIC;
356
357 $ilErr = $DIC['ilErr'];
358 $lng = $DIC['lng'];
359 $ilAccess = $DIC['ilAccess'];
360
361 //static if ($this->checkPermissionBool("visible", "", "", $a_target))
362 if ($ilAccess->checkAccess('visible', '', $a_target)) {
363 $_GET["cmd"] = "infoScreen";
364 $_GET["ref_id"] = $a_target;
365 $_GET["baseClass"] = "ilRepositoryGUI";
366 include("ilias.php");
367 exit;
368 }
369 //static else if ($this->checkPermissionBool("read", "", "", ROOT_FOLDER_ID))
370 if ($ilAccess->checkAccess('read', '', ROOT_FOLDER_ID)) {
371 $_GET["cmd"] = "frameset";
372 $_GET["target"] = "";
373 $_GET["ref_id"] = ROOT_FOLDER_ID;
374 ilUtil::sendFailure(sprintf(
375 $lng->txt("msg_no_perm_read_item"),
377 ), true);
378 $_GET["baseClass"] = "ilRepositoryGUI";
379 include("ilias.php");
380 exit;
381 }
382
383 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
384 }
385}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Class ilInfoScreenGUI.
New implementation of ilObjectGUI.
getType()
Functions that must be overwritten.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
editObject()
edit object
static _lookupObjId($a_id)
const TITLE_LENGTH
max length of object title
static _lookupTitle($a_id)
lookup object title
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)
Constructor.
static _goto($a_target)
redirect script
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
addCustomEditForm(ilPropertyFormGUI $a_form)
Add custom fields to edit form.
editObject(ilPropertyFormGUI $a_form=null)
Edit settings.
addCustomInfoFields(ilInfoScreenGUI $a_info)
Add custom fields to info screen.
initEditForm()
Init edit settings form.
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.
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const ANONYMOUS_USER_ID
Definition: constants.php:25
const ROOT_FOLDER_ID
Definition: constants.php:30
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc