ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCourseContentGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
17 {
21 
22  var $tpl;
23  var $ctrl;
24  var $lng;
25  var $tabs_gui;
26 
31  function ilCourseContentGUI(&$container_gui_obj)
32  {
33  global $tpl,$ilCtrl,$lng,$ilObjDataCache,$ilTabs;
34 
35  $this->tpl =& $tpl;
36  $this->ctrl =& $ilCtrl;
37  $this->lng =& $lng;
38  $this->lng->loadLanguageModule('crs');
39  $this->tabs_gui =& $ilTabs;
40 
41  $this->container_gui =& $container_gui_obj;
42  $this->container_obj =& $this->container_gui->object;
43 
44  $this->__initCourseObject();
45  }
46 
47  function &executeCommand()
48  {
49  global $ilAccess, $ilErr, $ilTabs, $ilCtrl;
50 
51  if(!$ilAccess->checkAccess('read','',$this->container_obj->getRefId()))
52  {
53  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->WARNING);
54  }
55 
56  // Handle timings view
57  $_SESSION['crs_timings'] = true;
58 
59  $this->__setSubTabs();
60  $this->tabs_gui->setTabActive('view_content');
61  $cmd = $this->ctrl->getCmd();
62 
63  switch($this->ctrl->getNextClass($this))
64  {
65  case 'ilcoursearchivesgui':
66  $this->__forwardToArchivesGUI();
67  break;
68 
69  case "ilcolumngui":
70  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
71  $ilTabs->setSubTabActive("crs_content");
72  $this->view();
73  break;
74 
75  default:
76  if(!$this->__checkStartObjects())
77  {
78  $this->showStartObjects();
79  break;
80  }
81 
82  // forward if archives enabled and not tutor
83  if(!$this->is_tutor = $ilAccess->checkAccess('write','',$this->course_obj->getRefId()) and
84  $this->course_obj->isArchived())
85  {
86  $this->__forwardToArchivesGUI();
87  break;
88  }
89 
90  // forward to objective presentation
91  if((!$this->is_tutor and
92  $this->container_obj->getType() == 'crs' and
93  $this->container_obj->enabledObjectiveView()) ||
94  $_GET["col_return"] == "objectives")
95  {
96  $this->use_objective_presentation = true;
97  $this->view();
98  //$this->__forwardToObjectivePresentation();
99  break;
100  }
101 
102 
103  if(!$cmd)
104  {
105  $cmd = $this->__getDefaultCommand();
106  }
107  $this->$cmd();
108  break;
109  }
110  }
111 
113  {
114  global $ilAccess;
115 
116  // edit timings if panel is on
117  if($_SESSION['crs_timings_panel'][$this->course_obj->getId()])
118  {
119  return 'editTimings';
120  }
121  if($ilAccess->checkAccess('write','',$this->container_obj->getRefId()))
122  {
123  return 'view';
124  }
125  if($this->container_obj->getType() == 'crs' and
126  $this->course_obj->getViewMode() == IL_CRS_VIEW_TIMING)
127  {
128  return 'editUserTimings';
129  }
130  return 'view';
131  }
132 
134  {
135  include_once 'Modules/Course/classes/class.ilCourseArchivesGUI.php';
136 
137  $this->ctrl->setReturn($this,'');
138  $archives_gui = new ilCourseArchivesGUI($this->container_gui);
139  $this->ctrl->forwardCommand($archives_gui);
140 
141  $this->tabs_gui->setTabActive('view_content');
142  $this->tabs_gui->setSubTabActive('crs_archives');
143 
144  return true;
145  }
146 
148  {
149  include_once './Modules/Course/classes/class.ilCourseStart.php';
150 
151  global $ilAccess,$ilUser;
152 
153  if($ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
154  {
155  return true;
156  }
157  $this->start_obj = new ilCourseStart($this->course_obj->getRefId(),$this->course_obj->getId());
158  if(count($this->start_obj->getStartObjects()) and !$this->start_obj->allFullfilled($ilUser->getId()))
159  {
160  return false;
161  }
162  return true;
163  }
164 
165  function showStartObjects()
166  {
167  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
168  include_once './Services/Repository/classes/class.ilRepositoryExplorer.php';
169  include_once './Services/Link/classes/class.ilLink.php';
170 
171  global $rbacsystem,$ilias,$ilUser,$ilAccess,$ilObjDataCache;
172 
173  $this->tabs_gui->setSubTabActive('crs_content');
174 
175  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_start_view.html",'Modules/Course');
176  $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_info_start'));
177  $this->tpl->setVariable("TBL_TITLE_START",$this->lng->txt('crs_table_start_objects'));
178  $this->tpl->setVariable("HEADER_NR",$this->lng->txt('crs_nr'));
179  $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('description'));
180  $this->tpl->setVariable("HEADER_EDITED",$this->lng->txt('crs_objective_accomplished'));
181 
182 
183  $lm_continue =& new ilCourseLMHistory($this->course_obj->getRefId(),$ilUser->getId());
184  $continue_data = $lm_continue->getLMHistory();
185 
186  $counter = 0;
187  foreach($this->start_obj->getStartObjects() as $start)
188  {
189  $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']);
190  $ref_id = $start['item_ref_id'];
191  $type = $ilObjDataCache->lookupType($obj_id);
192 
194 
195  $obj_link = ilLink::_getLink($ref_id,$type);
197  $obj_frame = $obj_frame ? $obj_frame : '';
198 
199  // Tmp fix for tests
200  $obj_frame = $type == 'tst' ? '' : $obj_frame;
201 
202  $contentObj = false;
203 
204  if($ilAccess->checkAccess('read','',$ref_id))
205  {
206  $this->tpl->setCurrentBlock("start_read");
207  $this->tpl->setVariable("READ_TITLE_START",$ilObjDataCache->lookupTitle($obj_id));
208  $this->tpl->setVariable("READ_TARGET_START",$obj_frame);
209  $this->tpl->setVariable("READ_LINK_START", $obj_link.'&crs_show_result='.$this->course_obj->getRefId());
210  $this->tpl->parseCurrentBlock();
211  }
212  else
213  {
214  $this->tpl->setCurrentBlock("start_visible");
215  $this->tpl->setVariable("VISIBLE_LINK_START",$ilObjDataCache->lookupTitle($obj_id));
216  $this->tpl->parseCurrentBlock();
217  }
218 
219  // CONTINUE LINK
220  if(isset($continue_data[$ref_id]))
221  {
222  $this->tpl->setCurrentBlock("link");
223  $this->tpl->setVariable("LINK_HREF",ilLink::_getLink($ref_id,'',array('obj_id',
224  $continue_data[$ref_id]['lm_page_id'])));
225  #$this->tpl->setVariable("CONTINUE_LINK_TARGET",$target);
226  $this->tpl->setVariable("LINK_NAME",$this->lng->txt('continue_work'));
227  $this->tpl->parseCurrentBlock();
228  }
229 
230  // add to desktop link
231  if(!$ilUser->isDesktopItem($ref_id,$type) and
232  $this->course_obj->getAboStatus())
233  {
234  if ($ilAccess->checkAccess('read','',$ref_id))
235  {
236  $this->tpl->setCurrentBlock("link");
237  $this->ctrl->setParameterByClass(get_class($this->container_gui),'item_ref_id',$ref_id);
238  $this->ctrl->setParameterByClass(get_class($this->container_gui),'item_id',$ref_id);
239  $this->ctrl->setParameterByClass(get_class($this->container_gui),'type',$type);
240 
241  $this->tpl->setVariable("LINK_HREF",$this->ctrl->getLinkTarget($this->container_gui,'addToDesk'));
242  $this->tpl->setVariable("LINK_NAME", $this->lng->txt("to_desktop"));
243  $this->tpl->parseCurrentBlock();
244  }
245  }
246  elseif($this->course_obj->getAboStatus())
247  {
248  $this->tpl->setCurrentBlock("link");
249  $this->ctrl->setParameterByClass(get_class($this->container_gui),'item_ref_id',$ref_id);
250  $this->ctrl->setParameterByClass(get_class($this->container_gui),'item_id',$ref_id);
251  $this->ctrl->setParameterByClass(get_class($this->container_gui),'type',$type);
252 
253  $this->tpl->setVariable("LINK_HREF",$this->ctrl->getLinkTarget($this->container_gui,'removeFromDesk'));
254  $this->tpl->setVariable("LINK_NAME", $this->lng->txt("unsubscribe"));
255  $this->tpl->parseCurrentBlock();
256  }
257 
258 
259  // Description
260  if(strlen($ilObjDataCache->lookupDescription($obj_id)))
261  {
262  $this->tpl->setCurrentBlock("start_description");
263  $this->tpl->setVariable("DESCRIPTION_START",$ilObjDataCache->lookupDescription($obj_id));
264  $this->tpl->parseCurrentBlock();
265  }
266 
267 
268  if($this->start_obj->isFullfilled($ilUser->getId(),$ref_id))
269  {
270  $accomplished = 'accomplished';
271  $icon = ilUtil::getImagePath("icon_ok.svg");
272  }
273  else
274  {
275  $accomplished = 'not_accomplished';
276  $icon = ilUtil::getImagePath("icon_not_ok.svg");
277  }
278  $this->tpl->setCurrentBlock("start_row");
279  $this->tpl->setVariable("EDITED_IMG", $icon);
280  $this->tpl->setVariable("EDITED_ALT",$this->lng->txt('crs_objective_'.$accomplished));
281  $this->tpl->setVariable("ROW_CLASS",'option_value');
282  $this->tpl->setVariable("ROW_CLASS_CENTER",'option_value_center');
283  $this->tpl->setVariable("OBJ_NR_START",++$counter.'.');
284  $this->tpl->parseCurrentBlock();
285  }
286  return true;
287  }
288 
292  function view()
293  {
294  // BEGIN ChangeEvent: record read event.
295  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
296  global $ilUser;
297  $obj_id = ilObject::_lookupObjId($this->container_obj->getRefId());
299  $this->container_obj->getType(), $this->container_obj->getRefId(),
300  $obj_id, $ilUser->getId());
301  // END ChangeEvent: record read event.
302 
303  $this->getCenterColumnHTML();
304 
305  if (!$this->no_right_column)
306  {
307  $this->tpl->setRightContent($this->getRightColumnHTML());
308  }
309  }
310 
315  {
316  global $ilUser, $lng, $ilCtrl, $ilAccess;
317 
318  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
319 
320  $obj_id = ilObject::_lookupObjId($this->container_obj->getRefId());
321  $obj_type = ilObject::_lookupType($obj_id);
322 
323  include_once("Services/Block/classes/class.ilColumnGUI.php");
324  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
325 
326  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
327  {
328  return "";
329  }
330 
331  $this->setColumnSettings($column_gui);
332 
333  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
334  $column_gui->getCmdSide() == IL_COL_RIGHT &&
335  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
336  {
337 
338  $html = $ilCtrl->forwardCommand($column_gui);
339  }
340  else
341  {
342  if (!$ilCtrl->isAsynch())
343  {
344  $html = $ilCtrl->getHTML($column_gui);
345  }
346  }
347 
348  return $html;
349  }
350 
351  function setColumnSettings($column_gui)
352  {
353  global $ilAccess, $lng;
354 
355  $column_gui->setRepositoryMode(true);
356  $column_gui->setEnableEdit(false);
357  $column_gui->setBlockProperty("news", "title",
358  $lng->txt("crs_news"));
359 
360  include_once "Services/Object/classes/class.ilObjectActivation.php";
361  $grouped_items = array();
362  foreach(ilObjectActivation::getItems($this->container_obj->getRefId()) as $item)
363  {
364  $grouped_items[$item["type"]][] = $item;
365  }
366 
367  $column_gui->setRepositoryItems($grouped_items);
368  if ($ilAccess->checkAccess("write", "", $this->container_obj->getRefId()))
369  {
370  $column_gui->setEnableEdit(true);
371  }
372 
373  // Allow movement of blocks for tutors
374  if ($this->is_tutor &&
375  $this->container_gui->isActiveAdministrationPanel())
376  {
377  $column_gui->setEnableMovement(true);
378  }
379 
380  // Configure Settings, if administration panel is on
381  if ($this->is_tutor)
382  {
383  $column_gui->setBlockProperty("news", "settings", true);
384  //$column_gui->setBlockProperty("news", "public_notifications_option", true);
385  $column_gui->setBlockProperty("news", "default_visibility_option", true);
386  $column_gui->setBlockProperty("news", "hide_news_block_option", true);
387  }
388 
389  if ($this->container_gui->isActiveAdministrationPanel())
390  {
391  $column_gui->setAdminCommands(true);
392  }
393  }
394 
395 
400  {
401  global $ilCtrl, $ilAccess;
402 
403  include_once("Services/Block/classes/class.ilColumnGUI.php");
404 
405  $obj_id = ilObject::_lookupObjId($this->container_obj->getRefId());
406  $obj_type = ilObject::_lookupType($obj_id);
407 
408  if (!$ilCtrl->isAsynch())
409  {
410  //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
412  {
413  // right column wants center
415  {
416  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
417  $this->setColumnSettings($column_gui);
418  $html = $ilCtrl->forwardCommand($column_gui);
419  }
420  // left column wants center
422  {
423  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
424  $this->setColumnSettings($column_gui);
425  $html = $ilCtrl->forwardCommand($column_gui);
426  }
427  }
428  else
429  {
430  {
431  $this->getDefaultView();
432  }
433  }
434  }
435 
436  return $html;
437  }
438 
439  function editTimings()
440  {
441  global $ilAccess,$ilErr;
442 
443  include_once 'Services/MetaData/classes/class.ilMDEducational.php';
444  include_once './Services/Link/classes/class.ilLink.php';
445 
446  $this->lng->loadLanguageModule('meta');
447 
448  if(!$ilAccess->checkAccess('write','',$this->container_obj->getRefId()))
449  {
450  $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->WARNING);
451  }
452  $this->__showTimingsPanel();
453  $this->tabs_gui->setSubTabActive('timings_timings');
454 
455  include_once 'Services/Object/classes/class.ilObjectActivation.php';
456  $this->cont_arr = ilObjectActivation::getTimingsAdministrationItems($this->container_obj->getRefId());
457 
458  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.crs_edit_items.html','Modules/Course');
459  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
460  $this->tpl->setVariable("HEADER_IMG",ilUtil::getImagePath('icon_crs.svg'));
461  $this->tpl->setVariable("HEADER_ALT",$this->lng->txt('crs_materials'));
462  $this->tpl->setVariable("BLOCK_HEADER_CONTENT",$this->lng->txt('edit_timings_list'));
463  $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
464 
465 
466  $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('crs_timings_time_frame'));
467  $this->tpl->setVariable("TXT_INFO_DURATION",$this->lng->txt('crs_timings_in_days'));
468 
469  $this->tpl->setVariable("TXT_START_END",$this->lng->txt('crs_timings_short_start_end'));
470  $this->tpl->setVariable("TXT_INFO_START_END",$this->lng->txt('crs_timings_start_end_info'));
471 
472  $this->tpl->setVariable("TXT_CHANGEABLE",$this->lng->txt('crs_timings_short_changeable'));
473 
474  $this->tpl->setVariable("TXT_INFO_LIMIT",$this->lng->txt('crs_timings_from_until'));
475  $this->tpl->setVariable("TXT_LIMIT",$this->lng->txt('crs_timings_short_limit_start_end'));
476  $this->tpl->setVariable("TXT_ACTIVE",$this->lng->txt('crs_timings_short_active'));
477  $this->tpl->setVariable("TXT_INFO_ACTIVE",$this->lng->txt('crs_timings_info_active'));
478 
479  $counter = 0;
480  foreach($this->cont_arr as $item)
481  {
482  if($item['type'] == 'itgr')
483  {
484  continue;
485  }
486  $item = $this->__loadFromPost($item);
487  $item_prefix = "item[$item[ref_id]]";
488  $item_change_prefix = "item_change[$item[ref_id]]";
489  $item_active_prefix = "item_active[$item[ref_id]]";
490 
491  if($item['type'] == 'grp' or
492  $item['type'] == 'fold')
493  {
494  $this->tpl->setVariable("TITLE_LINK",ilLink::_getLink($item['ref_id'],$item['type']));
495  $this->tpl->setVariable("TITLE_FRAME",ilFrameTargetInfo::_getFrame('MainContent',$item['type']));
496  $this->tpl->setVariable("TITLE_LINK_NAME",$item['title']);
497  }
498  else
499  {
500  if(!$item['title'] &&
501  $item['type'] == 'sess')
502  {
503  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
505  $item['title'] = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'],$app_info['fullday']);
506  }
507 
508  $this->tpl->setVariable("TITLE",$item['title']);
509  }
510 
511  if(strlen($item['description']))
512  {
513  $this->tpl->setCurrentBlock("item_description");
514  $this->tpl->setVariable("DESC",$item['description']);
515  $this->tpl->parseCurrentBlock();
516  }
517 
518  if($tlt = ilMDEducational::_getTypicalLearningTimeSeconds($item['obj_id']))
519  {
520  $this->tpl->setCurrentBlock("tlt");
521  $this->tpl->setVariable("TXT_TLT",$this->lng->txt('meta_typical_learning_time'));
522  $this->tpl->setVariable("TLT_VAL",ilFormat::_secondsToString($tlt));
523  $this->tpl->parseCurrentBlock();
524  }
525 
526  $this->tpl->setCurrentBlock("container_standard_row");
527 
528  // Suggested
529  if(is_array($_POST['item']["$item[ref_id]"]['sug_start']))
530  {
531  $start = $this->__toUnix($_POST['item']["$item[ref_id]"]['sug_start']);
532  }
533  else
534  {
535  $start = $item['suggestion_start'];
536  }
537  $end = $item['suggestion_end'];
538  $date = $this->__prepareDateSelect($start);
539  $this->tpl->setVariable("SUG_START",
540  ilUtil::makeDateSelect($item_prefix."[sug_start]",
541  $date['y'],$date['m'],$date['d'],date('Y',time()),false));
542 
543  $this->tpl->setVariable("NAME_DURATION_A",$item_prefix."[duration_a]");
544  if(isset($_POST['item']["$item[ref_id]"]['duration_a']))
545  {
546  $this->tpl->setVariable("VAL_DURATION_A",abs($_POST['item']["$item[ref_id]"]['duration_a']));
547  }
548  else
549  {
550  $this->tpl->setVariable("VAL_DURATION_A",intval(($end-$start)/(60*60*24)));
551  }
552 
553  $this->tpl->setVariable('SUG_END',ilDatePresentation::formatDate(new ilDate($item['suggestion_end'],IL_CAL_UNIX)));
554 
555  // Limit
556  if(is_array($_POST['item']["$item[ref_id]"]['lim_end']))
557  {
558  $end = $this->__toUnix($_POST['item']["$item[ref_id]"]['lim_end']);
559  }
560  else
561  {
562  $end = $item['latest_end'];
563  }
564 
565  $date = $this->__prepareDateSelect($end);
566  $this->tpl->setVariable("LIM_END",
567  ilUtil::makeDateSelect($item_prefix."[lim_end]",
568  $date['y'],$date['m'],$date['d'],date('Y',time()),false));
569 
570  $this->tpl->setVariable("NAME_CHANGE",$item_change_prefix."[change]");
571  $this->tpl->setVariable("NAME_ACTIVE",$item_active_prefix."[active]");
572 
573  if(isset($_POST['item']))
574  {
575  $change = $_POST['item_change']["$item[ref_id]"]['change'];
576  $active = $_POST['item_active']["$item[ref_id]"]['active'];
577  }
578  else
579  {
580  $change = $item['changeable'];
581  $active = ($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING);
582  }
583 
584  $this->tpl->setVariable("CHECKED_ACTIVE",$active ? 'checked="checked"' : '');
585  $this->tpl->setVariable("CHECKED_CHANGE",$change ? 'checked="checked"' : '');
586 
587  if(isset($this->failed["$item[ref_id]"]))
588  {
589  $this->tpl->setVariable("ROWCLASS",'tblrowmarked');
590  }
591  else
592  {
593  $this->tpl->setVariable("ROWCLASS",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
594  }
595  $this->tpl->parseCurrentBlock();
596  }
597 
598  // Select all
599  $this->tpl->setVariable("CHECKCLASS",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
600  $this->tpl->setVariable("SELECT_ALL",$this->lng->txt('select_all'));
601 
602  $this->tpl->setVariable("BTN_SAVE",$this->lng->txt('save'));
603  $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt('cancel'));
604 
605  }
606 
608  {
609  global $ilUser;
610 
611  include_once 'Modules/Course/classes/Timings/class.ilTimingAccepted.php';
612  $accept_obj = new ilTimingAccepted($this->course_obj->getId(),$ilUser->getId());
613 
614  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
615  $form = new ilPropertyFormGUI();
616  $form->setFormAction($this->ctrl->getFormAction($this, 'saveAcceptance'));
617  $form->setTitle($this->lng->txt('timing_accept_table'));
618 
619  $accept = new ilCheckboxInputGUI($this->lng->txt('timing_user_accept'), "accepted");
620  $accept->setChecked($accept_obj->isAccepted());
621  $form->addItem($accept);
622 
623  $remark = new ilTextAreaInputGUI($this->lng->txt('timing_remark'), "remark");
624  $remark->setValue($accept_obj->getRemark());
625  $form->addItem($remark);
626 
627  $tutor = new ilCheckboxInputGUI($this->lng->txt('timing_tutor_visible'), "tutor");
628  $tutor->setChecked($accept_obj->isVisible());
629  $form->addItem($tutor);
630 
631  $form->addCommandButton('saveAcceptance', $this->lng->txt('save'));
632  $this->tpl->setVariable("FORM", $form->getHTML());
633  }
634 
635  function saveAcceptance()
636  {
637  global $ilUser;
638 
639  include_once 'Modules/Course/classes/Timings/class.ilTimingAccepted.php';
640  $accept_obj = new ilTimingAccepted($this->course_obj->getId(),$ilUser->getId());
641 
642  $accept_obj->setRemark(ilUtil::stripSlashes($_POST['remark']));
643  $accept_obj->accept($_POST['accepted']);
644  $accept_obj->setVisible($_POST['tutor']);
645  $accept_obj->update();
646  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
647  $this->editUserTimings();
648  }
649 
650  function editUserTimings()
651  {
652  if($_SESSION['crs_timings_panel'][$this->course_obj->getId()])
653  {
654  return $this->editTimings();
655  }
656  global $ilAccess,$ilErr;
657 
658  if(!$ilAccess->checkAccess('read','',$this->container_obj->getRefId()))
659  {
660  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->WARNING);
661  }
662  $this->tabs_gui->setSubTabActive('timings_timings');
663 
664  $_SESSION['crs_timings_user_hidden'] = isset($_GET['show_details']) ? $_GET['show_details'] : $_SESSION['crs_timings_user_hidden'];
665 
666  include_once 'Services/Object/classes/class.ilObjectActivation.php';
667  if(ilObjectActivation::hasChangeableTimings($this->course_obj->getRefId()))
668  {
669  $this->__editAdvancedUserTimings();
670  }
671  else
672  {
673  $this->__editUserTimings();
674  }
675  }
676 
677  function returnToMembers()
678  {
679  $this->ctrl->returnToParent($this);
680  }
681 
682  function showUserTimings()
683  {
684  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.crs_user_timings.html','Modules/Course');
685  $this->tabs_gui->clearSubTabs();
686  $this->tabs_gui->setTabActive('members');
687 
688  if(!$_GET['member_id'])
689  {
690  ilUtil::sendFailure($this->lng->txt('no_checkbox'),true);
691  $this->ctrl->returnToParent($this);
692  }
693 
694 
695  // Back button
696  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
697  $this->tpl->setCurrentBlock("btn_cell");
698  $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,'returnToMembers'));
699  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("back"));
700  $this->tpl->parseCurrentBlock();
701 
702  include_once 'Modules/Course/classes/Timings/class.ilTimingAccepted.php';
703  $usr_accepted = new ilTimingAccepted($this->course_obj->getId(),(int) $_GET['member_id']);
704 
705  if($usr_accepted->isAccepted())
706  {
707  $this->tpl->setVariable("ACC_IMG",ilUtil::getImagePath('icon_ok.svg'));
708  $this->tpl->setVariable("ACC_ALT",$this->lng->txt('timing_accepted'));
709  }
710  else
711  {
712  $this->tpl->setVariable("ACC_IMG",ilUtil::getImagePath('icon_not_ok.svg'));
713  $this->tpl->setVariable("ACC_ALT",$this->lng->txt('timing_not_accepted'));
714  }
715  if($usr_accepted->isVisible() and strlen($usr_accepted->getRemark()))
716  {
717  $this->tpl->setVariable("REMARK",nl2br($usr_accepted->getRemark()));
718  }
719  else
720  {
721  $this->tpl->setVariable("REMARK",$this->lng->txt('not_available'));
722  }
723 
724  $this->tpl->setVariable("TIMING_ACCEPT",$this->lng->txt('timing_accept_table'));
725  $this->tpl->setVariable("TXT_ACCEPTED",$this->lng->txt('timing_user_accepted'));
726  $this->tpl->setVariable("TXT_REMARK",$this->lng->txt('timing_remark'));
727 
728  $this->tpl->setVariable("HEADER_IMG",ilUtil::getImagePath('icon_usr.svg'));
729  $this->tpl->setVariable("HEADER_ALT",$this->lng->txt('obj_usr'));
730  $this->tpl->setVariable("TABLE_HEADER",$this->lng->txt('timings_of'));
731  $name = ilObjUser::_lookupName($_GET['member_id']);
732  $this->tpl->setVariable("USER_NAME",$name['lastname'].', '.$name['firstname']);
733 
734  $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
735  $this->tpl->setVariable("TXT_START_END",$this->lng->txt('crs_timings_short_start_end'));
736  $this->tpl->setVariable("TXT_INFO_START_END",$this->lng->txt('crs_timings_start_end_info'));
737  $this->tpl->setVariable("TXT_CHANGED",$this->lng->txt('crs_timings_changed'));
738  $this->tpl->setVariable("TXT_OWN_PRESETTING",$this->lng->txt('crs_timings_planed_start'));
739  $this->tpl->setVariable("TXT_INFO_OWN_PRESETTING",$this->lng->txt('crs_timings_from_until'));
740 
741  include_once 'Services/Object/classes/class.ilObjectActivation.php';
742  $items = ilObjectActivation::getTimingsAdministrationItems($this->course_obj->getRefId());
743  foreach($items as $item)
744  {
745  if(($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) or
747  {
748  $this->__renderUserItem($item,0);
749  }
750  }
751  }
752 
753  function __renderUserItem($item,$level)
754  {
755  include_once 'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
756  include_once './Services/MetaData/classes/class.ilMDEducational.php';
757 
758  $this->lng->loadLanguageModule('meta');
759 
760  $usr_planed = new ilTimingPlaned($item['ref_id'],$_GET['member_id']);
761  for($i = 0;$i < $level;$i++)
762  {
763  $this->tpl->touchBlock('start_indent');
764  $this->tpl->touchBlock('end_indent');
765  }
766  if(strlen($item['description']))
767  {
768  $this->tpl->setCurrentBlock("item_description");
769  $this->tpl->setVariable("DESC",$item['description']);
770  $this->tpl->parseCurrentBlock();
771  }
772  if($tlt = ilMDEducational::_getTypicalLearningTimeSeconds($item['obj_id']))
773  {
774  $this->tpl->setCurrentBlock("tlt");
775  $this->tpl->setVariable("TXT_TLT",$this->lng->txt('meta_typical_learning_time'));
776  $this->tpl->setVariable("TLT_VAL",ilFormat::_secondsToString($tlt));
777  $this->tpl->parseCurrentBlock();
778  }
779 
780  if(!$item['title'] &&
781  $item['type'] == 'sess')
782  {
783  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
785  $item['title'] = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'],$app_info['fullday']);
786  }
787 
788  $this->tpl->setCurrentBlock("title_plain");
789  $this->tpl->setVariable("TITLE",$item['title']);
790  $this->tpl->parseCurrentBlock();
791 
792  $this->tpl->setCurrentBlock("container_standard_row");
793 
794  $this->tpl->setVariable("ROWCLASS",ilUtil::switchColor($this->counter++,'tblrow1','tblrow2'));
795  #$this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$item['type'].'.svg'));
796  $this->tpl->setVariable('TYPE_IMG',ilUtil::getTypeIconPath($item['type'],$item['obj_id'],'tiny'));
797  $this->tpl->setVariable("TYPE_ALT_IMG",$this->lng->txt('obj_'.$item['type']));
798 
799  if($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING)
800  {
801  $this->tpl->setVariable('SUG_START',ilDatePresentation::formatDate(new ilDate($item['suggestion_start'],IL_CAL_UNIX)));
802  $this->tpl->setVariable('SUG_END',ilDatePresentation::formatDate(new ilDate($item['suggestion_end'],IL_CAL_UNIX)));
803  }
804 
805  if($item['changeable'] and $item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING)
806  {
807  if($usr_planed->getPlanedStartingTime())
808  {
809  $start = $usr_planed->getPlanedStartingTime();
810  }
811  else
812  {
813  $start = $item['suggestion_start'];
814  }
815  $this->tpl->setVariable('OWN_START',ilDatePresentation::formatDate(new ilDate($start,IL_CAL_UNIX)));
816 
817  if($usr_planed->getPlanedEndingTime())
818  {
819  $end = $usr_planed->getPlanedEndingTime();
820  }
821  else
822  {
823  $end = $item['suggestion_end'];
824  }
825  if($start != $item['suggestion_start'] or $end != $item['suggestion_end'])
826  {
827  $this->tpl->setVariable("OK_IMG",ilUtil::getImagePath('icon_ok.svg'));
828  $this->tpl->setVariable("OK_ALT",$this->lng->txt('crs_timings_changed'));
829  }
830  else
831  {
832  $this->tpl->setVariable("OK_IMG",ilUtil::getImagePath('icon_not_ok.svg'));
833  $this->tpl->setVariable("OK_ALT",$this->lng->txt('crs_timings_not_changed'));
834  }
835  $this->tpl->setVariable('OWN_END',ilDatePresentation::formatDate(new ilDate($end,IL_CAL_UNIX)));
836  }
837 
838  $this->tpl->parseCurrentBlock();
839 
840  foreach(ilObjectActivation::getTimingsAdministrationItems($item['ref_id']) as $item_data)
841  {
842  if(($item_data['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) or
843  ilObjectActivation::hasChangeableTimings($item_data['ref_id']))
844  {
845  $this->__renderUserItem($item_data,$level+1);
846  }
847  }
848  }
849 
850 
851 
853  {
854  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.crs_usr_edit_timings_adv.html','Modules/Course');
855  $this->__showTimingsPanel();
856  $this->__showUserAcceptanceTable();
857 
858  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
859  $this->tpl->setVariable("HEADER_IMG",ilUtil::getImagePath('icon_crs.svg'));
860  $this->tpl->setVariable("HEADER_ALT",$this->lng->txt('obj_crs'));
861  $this->tpl->setVariable("BLOCK_HEADER_CONTENT",$this->lng->txt('timings_usr_edit'));
862 
863  if(!$_SESSION['crs_timings_user_hidden'])
864  {
865  $this->tpl->setVariable("SHOW_HIDE_TEXT",$this->lng->txt('show_details'));
866  $this->ctrl->setParameter($this,'show_details',1);
867  $this->tpl->setVariable("SHOW_HIDE_LINK",$this->ctrl->getLinkTarget($this,'editUserTimings'));
868  }
869  else
870  {
871  $this->tpl->setVariable("SHOW_HIDE_TEXT",$this->lng->txt('hide_details'));
872  $this->ctrl->setParameter($this,'show_details',0);
873  $this->tpl->setVariable("SHOW_HIDE_LINK",$this->ctrl->getLinkTarget($this,'editUserTimings'));
874  }
875  $this->ctrl->clearParameters($this);
876  $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
877  $this->tpl->setVariable("TXT_START_END",$this->lng->txt('crs_timings_short_start_end'));
878  $this->tpl->setVariable("TXT_INFO_START_END",$this->lng->txt('crs_timings_start_end_info'));
879 
880  $this->tpl->setVariable("TXT_LIMIT",$this->lng->txt('crs_timings_short_limit_start_end'));
881  $this->tpl->setVariable("TXT_INFO_LIMIT",$this->lng->txt('crs_timings_from_until'));
882 
883  $this->tpl->setVariable("TXT_OWN_PRESETTING",$this->lng->txt('crs_timings_planed_start'));
884  $this->tpl->setVariable("TXT_INFO_OWN_PRESETTING",$this->lng->txt('crs_timings_start_end_info'));
885 
886  $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('crs_timings_time_frame'));
887  $this->tpl->setVariable("TXT_INFO_DURATION",$this->lng->txt('crs_timings_in_days'));
888 
889  $this->tpl->setVariable("TXT_BTN_UPDATE",$this->lng->txt('save'));
890  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
891 
892  include_once 'Services/Object/classes/class.ilObjectActivation.php';
893  $sorted_items = ilObjectActivation::getTimingsItems($this->course_obj->getRefId());
894 
895  $this->counter = 0;
896  foreach($sorted_items as $item)
897  {
898  switch($item['type'])
899  {
900  case 'itgr':
901  break;
902 
903  default:
904  $this->__renderItem($item,0);
905  break;
906  }
907  }
908  }
909 
910  function __editUserTimings()
911  {
912  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.crs_usr_edit_timings.html','Modules/Course');
913 
914  $this->__showTimingsPanel();
915  $this->__showUserAcceptanceTable();
916 
917  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
918  $this->tpl->setVariable("HEADER_IMG",ilUtil::getImagePath('icon_crs.svg'));
919  $this->tpl->setVariable("HEADER_ALT",$this->lng->txt('obj_crs'));
920 
921  if(!$_SESSION['crs_timings_user_hidden'])
922  {
923  $this->tpl->setVariable("SHOW_HIDE_TEXT",$this->lng->txt('show_details'));
924  $this->ctrl->setParameter($this,'show_details',1);
925  $this->tpl->setVariable("SHOW_HIDE_LINK",$this->ctrl->getLinkTarget($this,'editUserTimings'));
926  }
927  else
928  {
929  $this->tpl->setVariable("SHOW_HIDE_TEXT",$this->lng->txt('hide_details'));
930  $this->ctrl->setParameter($this,'show_details',0);
931  $this->tpl->setVariable("SHOW_HIDE_LINK",$this->ctrl->getLinkTarget($this,'editUserTimings'));
932  }
933  $this->ctrl->clearParameters($this);
934 
935  $this->tpl->setVariable("BLOCK_HEADER_CONTENT",$this->lng->txt('timings_timings'));
936  $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
937  $this->tpl->setVariable("TXT_START",$this->lng->txt('crs_timings_sug_begin'));
938  $this->tpl->setVariable("TXT_END",$this->lng->txt('crs_timings_sug_end'));
939 
940  include_once 'Services/Object/classes/class.ilObjectActivation.php';
941  $sorted_items = ilObjectActivation::getTimingsItems($this->course_obj->getRefId());
942 
943  $this->counter = 0;
944  foreach($sorted_items as $item)
945  {
946  switch($item['type'])
947  {
948  case 'itgr':
949  break;
950 
951  default:
952  $this->__renderItem($item,0);
953  break;
954  }
955  }
956  }
957 
958  function __renderItem($item,$level)
959  {
960  global $ilUser,$ilAccess;
961 
962  include_once 'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
963  include_once './Services/Link/classes/class.ilLink.php';
964  include_once './Services/MetaData/classes/class.ilMDEducational.php';
965 
966  if(!$ilAccess->checkAccess('visible','',$item['ref_id']))
967  {
968  return false;
969  }
970 
971  $this->lng->loadLanguageModule('meta');
972 
973  $usr_planed = new ilTimingPlaned($item['ref_id'],$ilUser->getId());
974 
975  for($i = 0;$i < $level;$i++)
976  {
977  $this->tpl->touchBlock('start_indent');
978  $this->tpl->touchBlock('end_indent');
979  }
980  if(strlen($item['description']))
981  {
982  $this->tpl->setCurrentBlock("item_description");
983  $this->tpl->setVariable("DESC",$item['description']);
984  $this->tpl->parseCurrentBlock();
985  }
986  if($tlt = ilMDEducational::_getTypicalLearningTimeSeconds($item['obj_id']))
987  {
988  $this->tpl->setCurrentBlock("tlt");
989  $this->tpl->setVariable("TXT_TLT",$this->lng->txt('meta_typical_learning_time'));
990  $this->tpl->setVariable("TLT_VAL",ilFormat::_secondsToString($tlt));
991  $this->tpl->parseCurrentBlock();
992  }
993 
994  if(!$item['title'] &&
995  $item['type'] == 'sess')
996  {
997  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
999  $item['title'] = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'],$app_info['fullday']);
1000  }
1001 
1002  if($ilAccess->checkAccess('read','',$item['ref_id']))
1003  {
1004  $this->tpl->setCurrentBlock("title_as_link");
1005  $this->tpl->setVariable("TITLE_LINK",ilLink::_getLink($item['ref_id'],$item['type']));
1006  $this->tpl->setVariable("TITLE_NAME",$item['title']);
1007  $this->tpl->parseCurrentBlock();
1008  }
1009  else
1010  {
1011  $this->tpl->setCurrentBlock("title_plain");
1012  $this->tpl->setVariable("TITLE",$item['title']);
1013  $this->tpl->parseCurrentBlock();
1014  }
1015  $this->tpl->setCurrentBlock("container_standard_row");
1016 
1017  if(isset($this->invalid["$item[ref_id]"]))
1018  {
1019  $this->tpl->setVariable("ROWCLASS",'tblrowmarked');
1020  }
1021  else
1022  {
1023  $this->tpl->setVariable("ROWCLASS",ilUtil::switchColor($this->counter++,'tblrow1','tblrow2'));
1024  }
1025  #$this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$item['type'].'.svg'));
1026  $this->tpl->setVariable('TYPE_IMG',ilUtil::getTypeIconPath($item['type'],$item['obj_id'],'small'));
1027  $this->tpl->setVariable("TYPE_ALT_IMG",$this->lng->txt('obj_'.$item['type']));
1028 
1029 
1030  if($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING)
1031  {
1032  $this->tpl->setVariable('SUG_START',ilDatePresentation::formatDate(new ilDate($item['suggestion_start'],IL_CAL_UNIX)));
1033  $this->tpl->setVariable('SUG_END',ilDatePresentation::formatDate(new ilDate($item['suggestion_end'],IL_CAL_UNIX)));
1034  }
1035 
1036  if($item['changeable'])
1037  {
1038  $item_prefix = "item[".$item['ref_id'].']';
1039 
1040  if(is_array($_POST['item']["$item[ref_id]"]['own_start']))
1041  {
1042  #echo "Start post<br>";
1043  $start = $this->__toUnix($_POST['item']["$item[ref_id]"]['own_start']);
1044  }
1045  elseif($usr_planed->getPlanedStartingTime())
1046  {
1047  #echo "Own start<br>";
1048  $start = $usr_planed->getPlanedStartingTime();
1049  }
1050  else
1051  {
1052  #echo "Empfehlung start<br>";
1053  $start = $item['suggestion_start'];
1054  }
1055 
1056  $date = $this->__prepareDateSelect($start);
1057  $this->tpl->setVariable("OWN_START",
1058  ilUtil::makeDateSelect($item_prefix."[own_start]",
1059  $date['y'],$date['m'],$date['d'],date('Y',time()),false));
1060 
1061  if($usr_planed->getPlanedEndingTime())
1062  {
1063  #echo "Own End<br>";
1064  $end = $usr_planed->getPlanedEndingTime();
1065  }
1066  else
1067  {
1068  #echo "Empfehlung end<br>";
1069  $end = $item['suggestion_end'];
1070  }
1071  $this->tpl->setVariable('OWN_END',ilDatePresentation::formatDate(new ilDate($end,IL_CAL_UNIX)));
1072  $this->tpl->setVariable("NAME_DURATION",$item_prefix."[duration]");
1073 
1074  // Duration
1075  if(isset($_POST['item']["$item[ref_id]"]['duration']))
1076  {
1077  $this->tpl->setVariable("VAL_DURATION",$_POST['item']["$item[ref_id]"]['duration']);
1078  }
1079  else
1080  {
1081  $this->tpl->setVariable("VAL_DURATION",intval(($end - $start) / (60 * 60 * 24)));
1082  }
1083  $this->tpl->setVariable('LIM_START',ilDatePresentation::formatDate(new ilDate($item['earliest_start'],IL_CAL_UNIX)));
1084  $this->tpl->setVariable('LIM_END',ilDatePresentation::formatDate(new ilDate($item['latest_end'],IL_CAL_UNIX)));
1085  }
1086 
1087  $this->tpl->parseCurrentBlock();
1088 
1089  if(!$_SESSION['crs_timings_user_hidden'])
1090  {
1091  return true;
1092  }
1093 
1094  foreach(ilObjectActivation::getTimingsItems($item['ref_id']) as $item_data)
1095  {
1096  $this->__renderItem($item_data,$level+1);
1097  }
1098  }
1099 
1101  {
1102  global $ilAccess, $ilToolbar;
1103 
1104  if(!$ilAccess->checkAccess('write','',$this->container_obj->getRefId()))
1105  {
1106  return true;
1107  }
1108 
1109  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
1110  $btn = ilLinkButton::getInstance();
1111 
1112  if(!$_SESSION['crs_timings_panel'][$this->course_obj->getId()])
1113  {
1114  $btn->setCaption("timings_timings_on");
1115  $btn->setUrl($this->ctrl->getLinkTarget($this,'timingsOn'));
1116  }
1117  else
1118  {
1119  $btn->setCaption("timings_timings_off");
1120  $btn->setUrl($this->ctrl->getLinkTarget($this,'timingsOff'));
1121  }
1122 
1123  $ilToolbar->addButtonInstance($btn);
1124  }
1125 
1126  function timingsOn()
1127  {
1128  global $ilTabs;
1129  $_SESSION['crs_timings_panel'][$this->course_obj->getId()] = 1;
1130 
1131  $ilTabs->clearSubTabs();
1132  $this->__setSubTabs();
1133  $this->editTimings();
1134  }
1135 
1136  function timingsOff()
1137  {
1138  global $ilTabs;
1139  $_SESSION['crs_timings_panel'][$this->course_obj->getId()] = 0;
1140 
1141  $ilTabs->clearSubTabs();
1142  $this->__setSubTabs();
1143  $this->editUserTimings();
1144  }
1145 
1146 
1148  {
1149  global $ilUser,$ilObjDataCache;
1150  include_once 'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
1151 
1152  // Validate
1153  $this->invalid = array();
1154  foreach($_POST['item'] as $ref_id => $data)
1155  {
1156  $tmp_planed = new ilTimingPlaned($ref_id,$ilUser->getId());
1157 
1158  $tmp_planed->setPlanedStartingTime($this->__toUnix($data['own_start']));
1159  if(isset($data['duration']))
1160  {
1161  $data['own_start']['d'] += $data['duration'];
1162  $tmp_planed->setPlanedEndingTime($this->__toUnix($data['own_start'],array('h' => 23,'m' => 55)));
1163  }
1164  else
1165  {
1166  $tmp_planed->setPlanedEndingTime($this->__toUnix($data['own_start']),array('h' => 23,'m' => 55));
1167  }
1168  if(!$tmp_planed->validate())
1169  {
1170  $this->invalid[$ref_id] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($ref_id));
1171  }
1172  $all_items[] = $tmp_planed;
1173  }
1174  if(count($this->invalid))
1175  {
1176  $message = $this->lng->txt('crs_timings_update_error');
1177  $message .= ("<br />".$this->lng->txt('crs_materials').': ');
1178  $message .= (implode(',',$this->invalid));
1179  ilUtil::sendFailure($message);
1180  $this->editUserTimings();
1181  return false;
1182  }
1183  foreach($all_items as $new_item_obj)
1184  {
1185  $new_item_obj->update();
1186  }
1187  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1188  $this->editUserTimings();
1189  return true;
1190 
1191  }
1192 
1193 
1194  function &__loadFromPost(&$item)
1195  {
1196  $obj_id = $item['obj_id'];
1197 
1198  if(!isset($_POST['item'][$obj_id]))
1199  {
1200  return $item;
1201  }
1202  $item['suggestion_start'] = $this->__toUnix($_POST['item'][$obj_id]['sug_start']);
1203  if(isset($_POST['item'][$obj_id]['sug_end']))
1204  {
1205  // #9325
1206  $item['suggestion_end'] = $this->__toUnix($_POST['item'][$obj_id]['sug_end']);
1207  }
1208  $item['earliest_start'] = $this->__toUnix($_POST['item'][$obj_id]['lim_start']);
1209  $item['latest_end'] = $this->__toUnix($_POST['item'][$obj_id]['lim_end']);
1210  $item['changeable'] = $_POST['item'][$obj_id]['change'];
1211  $item['timing_type'] = $_POST['item'][$obj_id]['active'] ? ilObjectActivation::TIMINGS_PRESETTING : $item['timing_type'];
1212  $item['duration_a'] = $_POST['item'][$obj_id]['duration_a'];
1213  $item['duration_b'] = $_POST['item'][$obj_id]['duration_b'];
1214 
1215  return $item;
1216  }
1217 
1218  function updateTimings()
1219  {
1220  include_once 'Services/Object/classes/class.ilObjectActivation.php';
1221 
1222  global $ilAccess,$ilErr;
1223 
1224  if(!$ilAccess->checkAccess('write','',$this->container_obj->getRefId()))
1225  {
1226  $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->WARNING);
1227  }
1228  $this->failed = array();
1229  // Validate
1230 
1231  $_POST['item'] = is_array($_POST['item']) ? $_POST['item'] : array();
1232  $all_items = array();
1233 
1234  foreach($_POST['item'] as $ref_id => $data)
1235  {
1236  $item_obj = new ilObjectActivation();
1237  $old_data = ilObjectActivation::getItem($ref_id);
1238 
1239  $item_obj->setTimingType($_POST['item_active'][$ref_id]['active'] ?
1242  $item_obj->setTimingStart($old_data['timing_start']);
1243  $item_obj->setTimingEnd($old_data['timing_end']);
1244  $item_obj->setSuggestionStart($this->__toUnix($data["sug_start"]));
1245 
1246  // add duration
1247  $data['sug_start']['d'] += abs($data['duration_a']);
1248  $item_obj->setSuggestionEnd($this->__toUnix($data['sug_start'],array('h' => 23,'m' => 55)));
1249 
1250  $item_obj->setEarliestStart(time());
1251  $item_obj->setLatestEnd($this->__toUnix($data['lim_end'],array('h' => 23,'m' => 55)));
1252 
1253  $item_obj->toggleVisible($old_data['visible']);
1254  $item_obj->toggleChangeable($_POST['item_change'][$ref_id]['change']);
1255 
1256  if(!$item_obj->validateActivation())
1257  {
1258  $this->failed[$ref_id] = $old_data['title'];
1259  }
1260  $all_items[$ref_id] =& $item_obj;
1261  unset($item_obj);
1262  }
1263 
1264  if(count($this->failed))
1265  {
1266  $message = $this->lng->txt('crs_timings_update_error');
1267  $message .= ("<br />".$this->lng->txt('crs_materials').': ');
1268  $message .= (implode(',',$this->failed));
1269  ilUtil::sendFailure($message);
1270  $this->editTimings();
1271  return false;
1272  }
1273 
1274  // No do update
1275  foreach($all_items as $ref_id => $item_obj_new)
1276  {
1277  $item_obj_new->update($ref_id);
1278  }
1279  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1280  $this->editTimings();
1281  return false;
1282  }
1283 
1284  function __setSubTabs()
1285  {
1286  if($this->container_obj->getType() == 'crs')
1287  {
1288  $this->container_gui->setContentSubTabs();
1289  }
1290  }
1291 
1293  {
1294  global $tree;
1295 
1296  if($this->container_obj->getType() == 'crs')
1297  {
1298  // Container is course
1299  $this->course_obj =& $this->container_obj;
1300  }
1301  else
1302  {
1303 
1304  $course_ref_id = $tree->checkForParentType($this->container_obj->getRefId(),'crs');
1305  $this->course_obj =& ilObjectFactory::getInstanceByRefId($course_ref_id);
1306  }
1307  return true;
1308  }
1309 
1310  function __toUnix($date,$time = array())
1311  {
1312  return gmmktime($time['h'],$time['m'],0,$date['m'],$date['d'],$date['y']);
1313  }
1314 
1315  function __prepareDateSelect($a_unix_time)
1316  {
1317  return array('y' => date('Y',$a_unix_time),
1318  'm' => date('m',$a_unix_time),
1319  'd' => date('d',$a_unix_time));
1320  }
1321 
1322  function __prepareTimeSelect($a_unix_time)
1323  {
1324  return array('h' => date('G',$a_unix_time),
1325  'm' => date('i',$a_unix_time),
1326  's' => date('s',$a_unix_time));
1327  }
1328 
1329 
1330  function __buildPath($a_ref_id)
1331  {
1332  global $tree;
1333 
1334  $path_arr = $tree->getPathFull($a_ref_id,$this->course_obj->getRefId());
1335  $counter = 0;
1336  foreach($path_arr as $data)
1337  {
1338  if($counter++)
1339  {
1340  $path .= " -> ";
1341  }
1342  $path .= $data['title'];
1343  }
1344 
1345  return $path;
1346  }
1347 
1348 
1349 } // END class.ilCourseContentGUI
1350 ?>