ILIAS  eassessment Revision 61809
 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(ilECSImport::_lookupEContentId($this->object->getId())))
142  {
143  $this->object->createAuthResource();
144  ilUtil::redirect($this->object->getFullRemoteLink());
145  }
146  else
147  {
148  ilUtil::redirect($this->object->getRemoteLink());
149  }
150  }
151 
158  public function getTabs($tabs_gui)
159  {
160  global $ilAccess;
161 
162  if($ilAccess->checkAccess('visible','',$this->object->getRefId()))
163  {
164  $tabs_gui->addTarget("info_short",
165  $this->ctrl->getLinkTarget($this, "infoScreen"));
166  }
167 
168  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
169  {
170  $tabs_gui->addTarget("edit",
171  $this->ctrl->getLinkTarget($this, "edit"),
172  array(),
173  "");
174  }
175  if ($ilAccess->checkAccess('edit_permission','',$this->object->getRefId()))
176  {
177  $tabs_gui->addTarget("perm_settings",
178  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
179  array("perm","info","owner"), 'ilpermissiongui');
180  }
181  }
182 
189  public function callObject()
190  {
191  // check if the assigned course is hosted on the same installation
192  if($this->object->createAuthResource())
193  {
194  ilUtil::redirect($this->object->getFullRemoteLink());
195  return true;
196  }
197  else
198  {
199  ilUtil::sendFailure('Cannot call remote course.');
200  $this->infoScreenObject();
201  return false;
202  }
203  }
204 
210  function infoScreenObject()
211  {
212  $this->ctrl->setCmd("showSummary");
213  $this->ctrl->setCmdClass("ilinfoscreengui");
214  $this->infoScreen();
215  }
216 
217 
225  public function infoScreen()
226  {
227  global $ilErr,$ilAccess,$ilUser;
228 
229  if(!$ilAccess->checkAccess('visible','',$this->object->getRefId()))
230  {
231  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
232  }
233 
234  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
235  $info = new ilInfoScreenGUI($this);
236 
237  include_once('./Services/WebServices/ECS/classes/class.ilECSImport.php');
238  include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
239 
240  if($ilUser->getId() == ANONYMOUS_USER_ID)
241  {
242  $info->addButton($this->lng->txt('rcrs_call'),
243  $this->object->getRemoteLink(),
244  'target="_blank"');
245  }
246  elseif(ilECSExport::_isRemote(ilECSImport::_lookupEContentId($this->object->getId())))
247  {
248  $info->addButton($this->lng->txt('rcrs_call'),
249  $this->ctrl->getLinkTarget($this,'call'),
250  'target="_blank"');
251  }
252  else
253  {
254  $info->addButton($this->lng->txt('rcrs_call'),
255  $this->object->getRemoteLink());
256  }
257 
258  $info->addSection($this->lng->txt('crs_general_info'));
259  $info->addProperty($this->lng->txt('title'),$this->object->getTitle());
260  if(strlen($this->object->getOrganization()))
261  {
262  $info->addProperty($this->lng->txt('organization'),$this->object->getOrganization());
263  }
264  if(strlen($this->object->getDescription()))
265  {
266  $info->addProperty($this->lng->txt('description'),$this->object->getDescription());
267  }
268  if(strlen($loc = $this->object->getLocalInformation()))
269  {
270  $info->addProperty($this->lng->txt('rcrs_local_informations'),$this->object->getLocalInformation());
271  }
272 
273  // Access
274  $info->addProperty($this->lng->txt('crs_visibility'),$this->availabilityToString());
275 
276 
277  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
279  'rcrs',$this->object->getId());
280  $record_gui->setInfoObject($info);
281  $record_gui->parse();
282 
283  $this->ctrl->forwardCommand($info);
284  }
285 
291  public function editObject()
292  {
293  global $ilErr,$ilAccess;
294 
295  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
296  {
297  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
298  }
299  $this->tabs_gui->setTabActive('edit');
300 
301  $this->initEditTable();
302  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.edit.html','Modules/RemoteCourse');
303  $this->tpl->setVariable('EDIT_TABLE',$this->form->getHTML());
304  }
305 
313  public function updateObject()
314  {
315  global $ilErr,$ilAccess;
316 
317  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
318  {
319  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
320  }
321 
322  $this->object->setLocalInformation(ilUtil::stripSlashes($_POST['local_info']));
323  #$this->object->setAvailabilityType($_POST['activation_type']);
324  #$this->object->setStartingTime($_POST['start']);
325  #$this->object->setEndingTime($_POST['end']);
326  $this->object->update();
327 
328  // Save advanced meta data
329  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
331  'rcrs',$this->object->getId());
332  $record_gui->loadFromPost();
333  $record_gui->saveValues();
334 
335  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
336  $this->editObject();
337  return true;
338  }
339 
345  protected function initEditTable()
346  {
347  if(is_object($this->form))
348  {
349  return true;
350  }
351 
352  $this->lng->loadLanguageModule('crs');
353 
354  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
355  $this->form = new ilPropertyFormGUI();
356  $this->form->setFormAction($this->ctrl->getFormAction($this));
357  $this->form->setTitle($this->lng->txt('rcrs_general_info'));
358  $this->form->addCommandButton('update',$this->lng->txt('save'));
359  $this->form->addCommandButton('edit',$this->lng->txt('cancel'));
360 
361  $text = new ilTextInputGUI($this->lng->txt('title'),'title');
362  $text->setValue($this->object->getTitle());
363  $text->setSize(40);
364  $text->setMaxLength(128);
365  $text->setDisabled(true);
366  $this->form->addItem($text);
367 
368 
369  /*
370  $area = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
371  $area->setValue($this->object->getDescription());
372  $area->setRows(3);
373  $area->setCols(80);
374  $area->setDisabled(true);
375  $this->form->addItem($area);
376  */
377  $area = new ilTextAreaInputGUI($this->lng->txt('rcrs_local_informations'),'local_info');
378  $area->setValue($this->object->getLocalInformation());
379  $area->setRows(3);
380  $area->setCols(80);
381  $this->form->addItem($area);
382 
383  $radio_grp = new ilRadioGroupInputGUI($this->lng->txt('crs_visibility'),'activation_type');
384  $radio_grp->setValue($this->object->getAvailabilityType());
385  $radio_grp->setDisabled(true);
386 
387  $radio_opt = new ilRadioOption($this->lng->txt('crs_visibility_unvisible'),ilObjRemoteCourse::ACTIVATION_OFFLINE);
388  $radio_grp->addOption($radio_opt);
389 
390  $radio_opt = new ilRadioOption($this->lng->txt('crs_visibility_limitless'),ilObjRemoteCourse::ACTIVATION_UNLIMITED);
391  $radio_grp->addOption($radio_opt);
392 
393  $radio_opt = new ilRadioOption($this->lng->txt('crs_visibility_until'),ilObjRemoteCourse::ACTIVATION_LIMITED);
394 
395  $start = new ilDateTimeInputGUI($this->lng->txt('crs_start'),'start');
396  $start->setDate(new ilDateTime(time(),IL_CAL_UNIX));
397  $start->setDisabled(true);
398  $start->setShowTime(true);
399  $radio_opt->addSubItem($start);
400  $end = new ilDateTimeInputGUI($this->lng->txt('crs_end'),'end');
401  $end->setDate(new ilDateTime(time(),IL_CAL_UNIX));
402  $end->setDisabled(true);
403  $end->setShowTime(true);
404  $radio_opt->addSubItem($end);
405 
406  $radio_grp->addOption($radio_opt);
407  $this->form->addItem($radio_grp);
408 
409  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
410  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR,'rcrs',$this->object->getId());
411  $record_gui->setPropertyForm($this->form);
412  $record_gui->parse();
413  }
414 
422  public function availabilityToString()
423  {
424  switch($this->object->getAvailabilityType())
425  {
427  return $this->lng->txt('offline');
428 
430  return $this->lng->txt('crs_unlimited');
431 
434  new ilDateTime($this->object->getStartingTime(),IL_CAL_UNIX),
435  new ilDateTime($this->object->getEndingTime(),IL_CAL_UNIX));
436  }
437  return '';
438  }
439 }
440 ?>