ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_once('Services/Object/classes/class.ilObject2GUI.php');
5 
13 abstract 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 $ilTabs;
25 
26  $next_class = $this->ctrl->getNextClass($this);
27  $cmd = $this->ctrl->getCmd();
28 
29  $this->prepareOutput();
30 
31  switch($next_class)
32  {
33  case 'ilinfoscreengui':
34  // forwards command
35  $this->infoScreen();
36  break;
37 
38  case 'ilpermissiongui':
39  $ilTabs->activateTab('id_permissions');
40  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
41  $this->ctrl->forwardCommand(new ilPermissionGUI($this));
42  break;
43 
44  case "ilcommonactiondispatchergui":
45  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
47  $this->ctrl->forwardCommand($gui);
48  break;
49 
50  default:
51  if(!$cmd || $cmd == 'view')
52  {
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 $ilUser;
68 
69  if($ilUser->getId() == ANONYMOUS_USER_ID ||
70  $this->object->isLocalObject())
71  {
72  ilUtil::redirect($this->object->getRemoteLink());
73  }
74  else
75  {
76  $link = $this->object->getFullRemoteLink();
77  ilUtil::redirect($link);
78  }
79  }
80 
84  public function setTabs()
85  {
86  global $ilTabs;
87 
88  if($this->checkPermissionBool('visible'))
89  {
90  $ilTabs->addTab("info", $this->lng->txt("info_short"),
91  $this->ctrl->getLinkTarget($this, "infoScreen"));
92  }
93 
94  if($this->checkPermissionBool('write'))
95  {
96  $ilTabs->addTab("edit", $this->lng->txt("edit"),
97  $this->ctrl->getLinkTarget($this, "edit"));
98  }
99 
100  // will add permissions if needed
101  parent::setTabs();
102  }
103 
109  public function callObject()
110  {
111  // check if the assigned object is hosted on the same installation
112  $link = $this->object->getFullRemoteLink();
113  if($link)
114  {
115  ilUtil::redirect($link);
116  return true;
117  }
118  else
119  {
120  ilUtil::sendFailure('Cannot call remote object.');
121  $this->infoScreenObject();
122  return false;
123  }
124  }
125 
131  function infoScreenObject()
132  {
133  $this->ctrl->setCmd("showSummary");
134  $this->ctrl->setCmdClass("ilinfoscreengui");
135  $this->infoScreen();
136  }
137 
141  public function infoScreen()
142  {
143  global $ilErr,$ilUser,$ilTabs;
144 
145  if(!$this->checkPermissionBool('visible'))
146  {
147  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
148  }
149 
150  $ilTabs->activateTab('info');
151 
152  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
153  $info = new ilInfoScreenGUI($this);
154 
155  if($ilUser->getId() == ANONYMOUS_USER_ID ||
156  $this->object->isLocalObject())
157  {
158  $info->addButton($this->lng->txt($this->getType().'_call'),
159  $this->object->getRemoteLink(),
160  'target="_blank"');
161  }
162  else
163  {
164  $info->addButton($this->lng->txt($this->getType().'_call'),
165  $this->ctrl->getLinkTarget($this,'call'),
166  'target="_blank"');
167  }
168 
169  $info->addSection($this->lng->txt('ecs_general_info'));
170  $info->addProperty($this->lng->txt('title'),$this->object->getTitle());
171  if(strlen($this->object->getOrganization()))
172  {
173  $info->addProperty($this->lng->txt('organization'),$this->object->getOrganization());
174  }
175  if(strlen($this->object->getDescription()))
176  {
177  $info->addProperty($this->lng->txt('description'),$this->object->getDescription());
178  }
179  if(strlen($loc = $this->object->getLocalInformation()))
180  {
181  $info->addProperty($this->lng->txt('ecs_local_information'),$this->object->getLocalInformation());
182  }
183 
184  $this->addCustomInfoFields($info);
185 
186  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
188  $this->getType(),$this->object->getId());
189  $record_gui->setInfoObject($info);
190  $record_gui->parse();
191 
192  $this->ctrl->forwardCommand($info);
193  }
194 
200  protected function addCustomInfoFields(ilInfoScreenGUI $a_info)
201  {
202 
203  }
204 
210  public function editObject(ilPropertyFormGUI $a_form = null)
211  {
212  global $ilErr,$ilTabs;
213 
214  if(!$this->checkPermissionBool('write'))
215  {
216  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
217  }
218 
219  $ilTabs->activateTab('edit');
220 
221  if(!$a_form)
222  {
223  $a_form = $this->initEditForm();
224  }
225  $this->tpl->setContent($a_form->getHTML());
226  }
227 
233  protected function initEditForm()
234  {
235  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
236  $form = new ilPropertyFormGUI();
237  $form->setFormAction($this->ctrl->getFormAction($this));
238  $form->setTitle($this->lng->txt('ecs_general_info'));
239  $form->addCommandButton('update',$this->lng->txt('save'));
240  $form->addCommandButton('edit',$this->lng->txt('cancel'));
241 
242  $text = new ilTextInputGUI($this->lng->txt('title'),'title');
243  $text->setValue($this->object->getTitle());
244  $text->setSize(40);
245  $text->setMaxLength(128);
246  $text->setDisabled(true);
247  $form->addItem($text);
248 
249  $area = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
250  $area->setValue($this->object->getDescription());
251  $area->setRows(3);
252  $area->setCols(80);
253  $area->setDisabled(true);
254  $form->addItem($area);
255 
256  $area = new ilTextAreaInputGUI($this->lng->txt('ecs_local_information'),'local_info');
257  $area->setValue($this->object->getLocalInformation());
258  $area->setRows(3);
259  $area->setCols(80);
260  $form->addItem($area);
261 
262  $this->addCustomEditForm($form);
263 
264  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
266  $this->getType(),$this->object->getId());
267  $record_gui->setPropertyForm($form);
268  $record_gui->parse();
269 
270  return $form;
271  }
272 
278  protected function addCustomEditForm(ilPropertyFormGUI $a_form)
279  {
280 
281  }
282 
286  public function updateObject()
287  {
288  global $ilErr;
289 
290  if(!$this->checkPermissionBool('write'))
291  {
292  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
293  }
294 
295  $form = $this->initEditForm();
296  if($form->checkInput())
297  {
298  $this->object->setLocalInformation($a_form->getInput('local_info'));
299 
300  $this->updateCustomValues($form);
301 
302  $this->object->update();
303 
304  // Save advanced meta data
305  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
307  $this->getType(), $this->object->getId());
308  $record_gui->loadFromPost();
309  $record_gui->saveValues();
310 
311  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
312  $this->editObject();
313  }
314 
315  $form->setValuesByPost();
316  $this->editObject($form);
317  }
318 
324  protected function updateCustomValues(ilPropertyFormGUI $a_form)
325  {
326 
327  }
328 
334  public static function _goto($a_target)
335  {
336  global $ilErr, $lng, $ilAccess;
337 
338  //static if ($this->checkPermissionBool("visible", "", "", $a_target))
339  if($ilAccess->checkAccess('visible','',$a_target))
340  {
341  $_GET["cmd"] = "infoScreen";
342  $_GET["ref_id"] = $a_target;
343  $_GET["baseClass"] = "ilRepositoryGUI";
344  include("ilias.php");
345  exit;
346  }
347  //static else if ($this->checkPermissionBool("read", "", "", ROOT_FOLDER_ID))
348  if($ilAccess->checkAccess('read','',ROOT_FOLDER_ID))
349  {
350  $_GET["cmd"] = "frameset";
351  $_GET["target"] = "";
352  $_GET["ref_id"] = ROOT_FOLDER_ID;
353  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
355  $_GET["baseClass"] = "ilRepositoryGUI";
356  include("ilias.php");
357  exit;
358  }
359 
360  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
361  }
362 }
363 
364 ?>