ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjRemoteCourseGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2009 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('classes/class.ilObjectGUI.php');
25 
37 {
43  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
44  {
45  $this->type = 'rcrs';
46  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
47 
48  $this->lng->loadLanguageModule('rcrs');
49  $this->lng->loadLanguageModule('crs');
50  }
51 
58  public static function _goto($a_target)
59  {
60  global $rbacsystem, $ilErr, $lng, $ilAccess;
61 
62  if ($ilAccess->checkAccess("visible", "", $a_target))
63  {
64  $_GET["cmd"] = "infoScreen";
65  $_GET["ref_id"] = $a_target;
66  include("repository.php");
67  exit;
68  }
69  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
70  {
71  $_GET["cmd"] = "frameset";
72  $_GET["target"] = "";
73  $_GET["ref_id"] = ROOT_FOLDER_ID;
74  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
76  include("repository.php");
77  exit;
78  }
79 
80  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
81  }
82 
83 
90  public function executeCommand()
91  {
92  global $rbacsystem,$ilErr,$ilAccess;
93 
94  $next_class = $this->ctrl->getNextClass($this);
95  $cmd = $this->ctrl->getCmd();
96 
97  $this->prepareOutput();
98 
99  switch($next_class)
100  {
101  case 'ilinfoscreengui':
102  $this->infoScreen(); // forwards command
103  break;
104 
105  case 'ilpermissiongui':
106  $this->tabs_gui->setTabActive('perm_settings');
107  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
108  $this->ctrl->forwardCommand(new ilPermissionGUI($this));
109  break;
110 
111  default:
112  if(!$cmd || $cmd == 'view')
113  {
114  $cmd = "editSettings";
115  }
116  $cmd .= "Object";
117  $this->$cmd();
118  break;
119  }
120  return true;
121  }
122 
130  public function showObject()
131  {
132  global $ilUser;
133 
134  include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
135  include_once('./Services/WebServices/ECS/classes/class.ilECSImport.php');
136 
137  if($ilUser->getId() == ANONYMOUS_USER_ID)
138  {
139  ilUtil::redirect($this->object->getRemoteLink());
140  }
141  elseif(ilECSExport::_isRemote(
142  ilECSImport::lookupServerId($this->object->getId()),
143  ilECSImport::_lookupEContentId($this->object->getId())
144  ))
145  {
146  $this->object->createAuthResource();
147  ilUtil::redirect($this->object->getFullRemoteLink());
148  }
149  else
150  {
151  ilUtil::redirect($this->object->getRemoteLink());
152  }
153  }
154 
161  public function getTabs($tabs_gui)
162  {
163  global $ilAccess;
164 
165  if($ilAccess->checkAccess('visible','',$this->object->getRefId()))
166  {
167  $tabs_gui->addTarget("info_short",
168  $this->ctrl->getLinkTarget($this, "infoScreen"));
169  }
170 
171  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
172  {
173  $tabs_gui->addTarget("edit",
174  $this->ctrl->getLinkTarget($this, "edit"),
175  array(),
176  "");
177  }
178  if ($ilAccess->checkAccess('edit_permission','',$this->object->getRefId()))
179  {
180  $tabs_gui->addTarget("perm_settings",
181  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
182  array("perm","info","owner"), 'ilpermissiongui');
183  }
184  }
185 
192  public function callObject()
193  {
194  // check if the assigned course is hosted on the same installation
195  if($this->object->createAuthResource())
196  {
197  ilUtil::redirect($this->object->getFullRemoteLink());
198  return true;
199  }
200  else
201  {
202  ilUtil::sendFailure('Cannot call remote course.');
203  $this->infoScreenObject();
204  return false;
205  }
206  }
207 
213  function infoScreenObject()
214  {
215  $this->ctrl->setCmd("showSummary");
216  $this->ctrl->setCmdClass("ilinfoscreengui");
217  $this->infoScreen();
218  }
219 
220 
228  public function infoScreen()
229  {
230  global $ilErr,$ilAccess,$ilUser;
231 
232  if(!$ilAccess->checkAccess('visible','',$this->object->getRefId()))
233  {
234  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
235  }
236 
237  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
238  $info = new ilInfoScreenGUI($this);
239 
240  include_once('./Services/WebServices/ECS/classes/class.ilECSImport.php');
241  include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
242 
243  if($ilUser->getId() == ANONYMOUS_USER_ID)
244  {
245  $info->addButton($this->lng->txt('rcrs_call'),
246  $this->object->getRemoteLink(),
247  'target="_blank"');
248  }
249  elseif(ilECSExport::_isRemote(
250  ilECSImport::lookupServerId($this->object->getId()),
251  ilECSImport::_lookupEContentId($this->object->getId())))
252  {
253  $info->addButton($this->lng->txt('rcrs_call'),
254  $this->ctrl->getLinkTarget($this,'call'),
255  'target="_blank"');
256  }
257  else
258  {
259  $info->addButton($this->lng->txt('rcrs_call'),
260  $this->object->getRemoteLink());
261  }
262 
263  $info->addSection($this->lng->txt('crs_general_info'));
264  $info->addProperty($this->lng->txt('title'),$this->object->getTitle());
265  if(strlen($this->object->getOrganization()))
266  {
267  $info->addProperty($this->lng->txt('organization'),$this->object->getOrganization());
268  }
269  if(strlen($this->object->getDescription()))
270  {
271  $info->addProperty($this->lng->txt('description'),$this->object->getDescription());
272  }
273  if(strlen($loc = $this->object->getLocalInformation()))
274  {
275  $info->addProperty($this->lng->txt('rcrs_local_informations'),$this->object->getLocalInformation());
276  }
277 
278  // Access
279  $info->addProperty($this->lng->txt('crs_visibility'),$this->availabilityToString());
280 
281 
282  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
284  'rcrs',$this->object->getId());
285  $record_gui->setInfoObject($info);
286  $record_gui->parse();
287 
288  $this->ctrl->forwardCommand($info);
289  }
290 
296  public function editObject()
297  {
298  global $ilErr,$ilAccess;
299 
300  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
301  {
302  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
303  }
304  $this->tabs_gui->setTabActive('edit');
305 
306  $this->initEditTable();
307  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.edit.html','Modules/RemoteCourse');
308  $this->tpl->setVariable('EDIT_TABLE',$this->form->getHTML());
309  }
310 
318  public function updateObject()
319  {
320  global $ilErr,$ilAccess;
321 
322  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
323  {
324  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
325  }
326 
327  $this->object->setLocalInformation(ilUtil::stripSlashes($_POST['local_info']));
328  #$this->object->setAvailabilityType($_POST['activation_type']);
329  #$this->object->setStartingTime($_POST['start']);
330  #$this->object->setEndingTime($_POST['end']);
331  $this->object->update();
332 
333  // Save advanced meta data
334  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
336  'rcrs',$this->object->getId());
337  $record_gui->loadFromPost();
338  $record_gui->saveValues();
339 
340  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
341  $this->editObject();
342  return true;
343  }
344 
350  protected function initEditTable()
351  {
352  if(is_object($this->form))
353  {
354  return true;
355  }
356 
357  $this->lng->loadLanguageModule('crs');
358 
359  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
360  $this->form = new ilPropertyFormGUI();
361  $this->form->setFormAction($this->ctrl->getFormAction($this));
362  $this->form->setTitle($this->lng->txt('rcrs_general_info'));
363  $this->form->addCommandButton('update',$this->lng->txt('save'));
364  $this->form->addCommandButton('edit',$this->lng->txt('cancel'));
365 
366  $text = new ilTextInputGUI($this->lng->txt('title'),'title');
367  $text->setValue($this->object->getTitle());
368  $text->setSize(40);
369  $text->setMaxLength(128);
370  $text->setDisabled(true);
371  $this->form->addItem($text);
372 
373 
374  /*
375  $area = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
376  $area->setValue($this->object->getDescription());
377  $area->setRows(3);
378  $area->setCols(80);
379  $area->setDisabled(true);
380  $this->form->addItem($area);
381  */
382  $area = new ilTextAreaInputGUI($this->lng->txt('rcrs_local_informations'),'local_info');
383  $area->setValue($this->object->getLocalInformation());
384  $area->setRows(3);
385  $area->setCols(80);
386  $this->form->addItem($area);
387 
388  $radio_grp = new ilRadioGroupInputGUI($this->lng->txt('crs_visibility'),'activation_type');
389  $radio_grp->setValue($this->object->getAvailabilityType());
390  $radio_grp->setDisabled(true);
391 
392  $radio_opt = new ilRadioOption($this->lng->txt('crs_visibility_unvisible'),ilObjRemoteCourse::ACTIVATION_OFFLINE);
393  $radio_grp->addOption($radio_opt);
394 
395  $radio_opt = new ilRadioOption($this->lng->txt('crs_visibility_limitless'),ilObjRemoteCourse::ACTIVATION_UNLIMITED);
396  $radio_grp->addOption($radio_opt);
397 
398  $radio_opt = new ilRadioOption($this->lng->txt('crs_visibility_until'),ilObjRemoteCourse::ACTIVATION_LIMITED);
399 
400  $start = new ilDateTimeInputGUI($this->lng->txt('crs_start'),'start');
401  $start->setDate(new ilDateTime(time(),IL_CAL_UNIX));
402  $start->setDisabled(true);
403  $start->setShowTime(true);
404  $radio_opt->addSubItem($start);
405  $end = new ilDateTimeInputGUI($this->lng->txt('crs_end'),'end');
406  $end->setDate(new ilDateTime(time(),IL_CAL_UNIX));
407  $end->setDisabled(true);
408  $end->setShowTime(true);
409  $radio_opt->addSubItem($end);
410 
411  $radio_grp->addOption($radio_opt);
412  $this->form->addItem($radio_grp);
413 
414  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
415  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR,'rcrs',$this->object->getId());
416  $record_gui->setPropertyForm($this->form);
417  $record_gui->parse();
418  }
419 
427  public function availabilityToString()
428  {
429  switch($this->object->getAvailabilityType())
430  {
432  return $this->lng->txt('offline');
433 
435  return $this->lng->txt('crs_unlimited');
436 
439  new ilDateTime($this->object->getStartingTime(),IL_CAL_UNIX),
440  new ilDateTime($this->object->getEndingTime(),IL_CAL_UNIX));
441  }
442  return '';
443  }
444 }
445 ?>