ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
16 {
19  public $course_obj;
20 
21  public $tpl;
22  public $ctrl;
23  public $lng;
24  public $tabs_gui;
25 
31  public function __construct($container_gui_obj)
32  {
33  global $DIC;
34 
35  $tpl = $DIC['tpl'];
36  $ilCtrl = $DIC['ilCtrl'];
37  $lng = $DIC['lng'];
38  $ilObjDataCache = $DIC['ilObjDataCache'];
39  $ilTabs = $DIC['ilTabs'];
40 
41  $this->tpl = $tpl;
42  $this->ctrl = $ilCtrl;
43  $this->lng = $lng;
44  $this->lng->loadLanguageModule('crs');
45  $this->tabs_gui = $ilTabs;
46 
47  $this->container_gui = &$container_gui_obj;
48  $this->container_obj = &$this->container_gui->object;
49 
50  $this->__initCourseObject();
51  }
52 
53  public function executeCommand()
54  {
55  global $DIC;
56 
57  $ilAccess = $DIC['ilAccess'];
58  $ilErr = $DIC['ilErr'];
59  $ilTabs = $DIC['ilTabs'];
60  $ilCtrl = $DIC['ilCtrl'];
61 
62  if (!$ilAccess->checkAccess('read', '', $this->container_obj->getRefId())) {
63  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->WARNING);
64  }
65 
66 
67  $this->__setSubTabs();
68  $this->tabs_gui->setTabActive('view_content');
69  $cmd = $this->ctrl->getCmd();
70 
71  switch ($this->ctrl->getNextClass($this)) {
72  case 'ilcoursearchivesgui':
73  $this->__forwardToArchivesGUI();
74  break;
75 
76  case "ilcolumngui":
77  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
78  $ilTabs->setSubTabActive("crs_content");
79  $this->view();
80  break;
81 
82  default:
83  if (!$this->__checkStartObjects()) {
84  $this->showStartObjects();
85  break;
86  }
87 
88  // forward to objective presentation
89  if ((!$this->is_tutor and
90  $this->container_obj->getType() == 'crs' and
91  $this->container_obj->enabledObjectiveView()) ||
92  $_GET["col_return"] == "objectives") {
93  $this->use_objective_presentation = true;
94  $this->view();
95  //$this->__forwardToObjectivePresentation();
96  break;
97  }
98 
99 
100  if (!$cmd) {
101  $cmd = $this->__getDefaultCommand();
102  }
103  $this->$cmd();
104  break;
105  }
106  }
107 
111  public function getContainerObject()
112  {
113  return $this->container_obj;
114  }
115 
116  public function __getDefaultCommand()
117  {
118  global $DIC;
119 
120  $ilAccess = $DIC['ilAccess'];
121 
122  // edit timings if panel is on
123  if ($_SESSION['crs_timings_panel'][$this->course_obj->getId()]) {
124  return 'manageTimings';
125  }
126  if ($ilAccess->checkAccess('write', '', $this->container_obj->getRefId())) {
127  return 'view';
128  }
129  if ($this->container_obj->getType() == 'crs' and
130  $this->course_obj->getViewMode() == IL_CRS_VIEW_TIMING) {
131  return 'editUserTimings';
132  }
133  return 'view';
134  }
135 
136  public function __checkStartObjects()
137  {
138  include_once './Modules/Course/classes/class.ilCourseStart.php';
139 
140  global $DIC;
141 
142  $ilAccess = $DIC['ilAccess'];
143  $ilUser = $DIC['ilUser'];
144 
145  if ($ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
146  return true;
147  }
148  $this->start_obj = new ilCourseStart($this->course_obj->getRefId(), $this->course_obj->getId());
149  if (count($this->start_obj->getStartObjects()) and !$this->start_obj->allFullfilled($ilUser->getId())) {
150  return false;
151  }
152  return true;
153  }
154 
155  public function showStartObjects()
156  {
157  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
158  include_once './Services/Repository/classes/class.ilRepositoryExplorer.php';
159  include_once './Services/Link/classes/class.ilLink.php';
160 
161  global $DIC;
162 
163  $rbacsystem = $DIC['rbacsystem'];
164  $ilias = $DIC['ilias'];
165  $ilUser = $DIC['ilUser'];
166  $ilAccess = $DIC['ilAccess'];
167  $ilObjDataCache = $DIC['ilObjDataCache'];
168 
169  $this->tabs_gui->setSubTabActive('crs_content');
170 
171  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_start_view.html", 'Modules/Course');
172  $this->tpl->setVariable("INFO_STRING", $this->lng->txt('crs_info_start'));
173  $this->tpl->setVariable("TBL_TITLE_START", $this->lng->txt('crs_table_start_objects'));
174  $this->tpl->setVariable("HEADER_NR", $this->lng->txt('crs_nr'));
175  $this->tpl->setVariable("HEADER_DESC", $this->lng->txt('description'));
176  $this->tpl->setVariable("HEADER_EDITED", $this->lng->txt('crs_objective_accomplished'));
177 
178 
179  $lm_continue = new ilCourseLMHistory($this->course_obj->getRefId(), $ilUser->getId());
180  $continue_data = $lm_continue->getLMHistory();
181 
182  $counter = 0;
183  foreach ($this->start_obj->getStartObjects() as $start) {
184  $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']);
185  $ref_id = $start['item_ref_id'];
186  $type = $ilObjDataCache->lookupType($obj_id);
187 
189 
190  $obj_link = ilLink::_getLink($ref_id, $type);
192  $obj_frame = $obj_frame ? $obj_frame : '';
193 
194  // Tmp fix for tests
195  $obj_frame = $type == 'tst' ? '' : $obj_frame;
196 
197  $contentObj = false;
198 
199  if ($ilAccess->checkAccess('read', '', $ref_id)) {
200  $this->tpl->setCurrentBlock("start_read");
201  $this->tpl->setVariable("READ_TITLE_START", $ilObjDataCache->lookupTitle($obj_id));
202  $this->tpl->setVariable("READ_TARGET_START", $obj_frame);
203  $this->tpl->setVariable("READ_LINK_START", $obj_link . '&crs_show_result=' . $this->course_obj->getRefId());
204  $this->tpl->parseCurrentBlock();
205  } else {
206  $this->tpl->setCurrentBlock("start_visible");
207  $this->tpl->setVariable("VISIBLE_LINK_START", $ilObjDataCache->lookupTitle($obj_id));
208  $this->tpl->parseCurrentBlock();
209  }
210 
211  // CONTINUE LINK
212  if (isset($continue_data[$ref_id])) {
213  $this->tpl->setCurrentBlock("link");
214  $this->tpl->setVariable("LINK_HREF", ilLink::_getLink($ref_id, '', array('obj_id',
215  $continue_data[$ref_id]['lm_page_id'])));
216  #$this->tpl->setVariable("CONTINUE_LINK_TARGET",$target);
217  $this->tpl->setVariable("LINK_NAME", $this->lng->txt('continue_work'));
218  $this->tpl->parseCurrentBlock();
219  }
220 
221  // add to desktop link
222  if (!$ilUser->isDesktopItem($ref_id, $type) and
223  $this->course_obj->getAboStatus()) {
224  if ($ilAccess->checkAccess('read', '', $ref_id)) {
225  $this->tpl->setCurrentBlock("link");
226  $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_ref_id', $ref_id);
227  $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_id', $ref_id);
228  $this->ctrl->setParameterByClass(get_class($this->container_gui), 'type', $type);
229 
230  $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTarget($this->container_gui, 'addToDesk'));
231  $this->tpl->setVariable("LINK_NAME", $this->lng->txt("to_desktop"));
232  $this->tpl->parseCurrentBlock();
233  }
234  } elseif ($this->course_obj->getAboStatus()) {
235  $this->tpl->setCurrentBlock("link");
236  $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_ref_id', $ref_id);
237  $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_id', $ref_id);
238  $this->ctrl->setParameterByClass(get_class($this->container_gui), 'type', $type);
239 
240  $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTarget($this->container_gui, 'removeFromDesk'));
241  $this->tpl->setVariable("LINK_NAME", $this->lng->txt("unsubscribe"));
242  $this->tpl->parseCurrentBlock();
243  }
244 
245 
246  // Description
247  if (strlen($ilObjDataCache->lookupDescription($obj_id))) {
248  $this->tpl->setCurrentBlock("start_description");
249  $this->tpl->setVariable("DESCRIPTION_START", $ilObjDataCache->lookupDescription($obj_id));
250  $this->tpl->parseCurrentBlock();
251  }
252 
253 
254  if ($this->start_obj->isFullfilled($ilUser->getId(), $ref_id)) {
255  $accomplished = 'accomplished';
256  $icon = ilUtil::getImagePath("icon_ok.svg");
257  } else {
258  $accomplished = 'not_accomplished';
259  $icon = ilUtil::getImagePath("icon_not_ok.svg");
260  }
261  $this->tpl->setCurrentBlock("start_row");
262  $this->tpl->setVariable("EDITED_IMG", $icon);
263  $this->tpl->setVariable("EDITED_ALT", $this->lng->txt('crs_objective_' . $accomplished));
264  $this->tpl->setVariable("ROW_CLASS", 'option_value');
265  $this->tpl->setVariable("ROW_CLASS_CENTER", 'option_value_center');
266  $this->tpl->setVariable("OBJ_NR_START", ++$counter . '.');
267  $this->tpl->parseCurrentBlock();
268  }
269  return true;
270  }
271 
275  public function view()
276  {
277  // BEGIN ChangeEvent: record read event.
278  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
279  global $DIC;
280 
281  $ilUser = $DIC['ilUser'];
282  $obj_id = ilObject::_lookupObjId($this->container_obj->getRefId());
284  $this->container_obj->getType(),
285  $this->container_obj->getRefId(),
286  $obj_id,
287  $ilUser->getId()
288  );
289  // END ChangeEvent: record read event.
290 
291  $this->getCenterColumnHTML();
292 
293  if (!$this->no_right_column) {
294  $this->tpl->setRightContent($this->getRightColumnHTML());
295  }
296  }
297 
301  public function getRightColumnHTML()
302  {
303  global $DIC;
304 
305  $ilUser = $DIC['ilUser'];
306  $lng = $DIC['lng'];
307  $ilCtrl = $DIC['ilCtrl'];
308  $ilAccess = $DIC['ilAccess'];
309 
310  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
311 
312  $obj_id = ilObject::_lookupObjId($this->container_obj->getRefId());
313  $obj_type = ilObject::_lookupType($obj_id);
314 
315  include_once("Services/Block/classes/class.ilColumnGUI.php");
316  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
317 
318  if ($column_gui->getScreenMode() == IL_SCREEN_FULL) {
319  return "";
320  }
321 
322  $this->setColumnSettings($column_gui);
323 
324  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
325  $column_gui->getCmdSide() == IL_COL_RIGHT &&
326  $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
327  $html = $ilCtrl->forwardCommand($column_gui);
328  } else {
329  if (!$ilCtrl->isAsynch()) {
330  $html = $ilCtrl->getHTML($column_gui);
331  }
332  }
333 
334  return $html;
335  }
336 
337  public function setColumnSettings($column_gui)
338  {
339  global $DIC;
340 
341  $ilAccess = $DIC['ilAccess'];
342  $lng = $DIC['lng'];
343 
344  $column_gui->setRepositoryMode(true);
345  $column_gui->setEnableEdit(false);
346  $column_gui->setBlockProperty(
347  "news",
348  "title",
349  $lng->txt("crs_news")
350  );
351 
352  include_once "Services/Object/classes/class.ilObjectActivation.php";
353  $grouped_items = array();
354  foreach (ilObjectActivation::getItems($this->container_obj->getRefId()) as $item) {
355  $grouped_items[$item["type"]][] = $item;
356  }
357 
358  $column_gui->setRepositoryItems($grouped_items);
359  if ($ilAccess->checkAccess("write", "", $this->container_obj->getRefId())) {
360  $column_gui->setEnableEdit(true);
361  }
362 
363  // Allow movement of blocks for tutors
364  if ($this->is_tutor &&
365  $this->container_gui->isActiveAdministrationPanel()) {
366  $column_gui->setEnableMovement(true);
367  }
368 
369  // Configure Settings, if administration panel is on
370  if ($this->is_tutor) {
371  $column_gui->setBlockProperty("news", "settings", true);
372  //$column_gui->setBlockProperty("news", "public_notifications_option", true);
373  $column_gui->setBlockProperty("news", "default_visibility_option", true);
374  $column_gui->setBlockProperty("news", "hide_news_block_option", true);
375  }
376 
377  if ($this->container_gui->isActiveAdministrationPanel()) {
378  $column_gui->setAdminCommands(true);
379  }
380  }
381 
382 
386  public function __forwardToColumnGUI()
387  {
388  global $DIC;
389 
390  $ilCtrl = $DIC['ilCtrl'];
391  $ilAccess = $DIC['ilAccess'];
392 
393  include_once("Services/Block/classes/class.ilColumnGUI.php");
394 
395  $obj_id = ilObject::_lookupObjId($this->container_obj->getRefId());
396  $obj_type = ilObject::_lookupType($obj_id);
397 
398  if (!$ilCtrl->isAsynch()) {
399  //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
401  // right column wants center
403  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
404  $this->setColumnSettings($column_gui);
405  $html = $ilCtrl->forwardCommand($column_gui);
406  }
407  // left column wants center
409  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
410  $this->setColumnSettings($column_gui);
411  $html = $ilCtrl->forwardCommand($column_gui);
412  }
413  } else {
414  {
415  $this->getDefaultView();
416  }
417  }
418  }
419 
420  return $html;
421  }
422 
423 
430  protected function manageTimings($failed_items = array())
431  {
432  global $DIC;
433 
434  $ilAccess = $DIC->access();
435  $ilErr = $DIC['ilErr'];
436  $mainTemplate = $DIC->ui()->mainTemplate();
437 
438  if (!$ilAccess->checkAccess('write', '', $this->container_obj->getRefId())) {
439  $ilErr->raiseError($this->lng->txt('msg_no_perm_write'), $ilErr->WARNING);
440  }
441  $GLOBALS['DIC']['ilTabs']->setTabActive('timings_timings');
442  $GLOBALS['DIC']['ilTabs']->clearSubTabs();
443 
445  $this,
446  'manageTimings',
447  $this->getContainerObject(),
448  $this->course_obj
449  );
450  if (count($failed_items)) {
451  $table->setFailureStatus(true);
452  }
453  $table->init();
454  $table->parse(ilObjectActivation::getTimingsAdministrationItems($this->getContainerObject()->getRefId()), $failed_items);
455 
456 
457  $mainTemplate->setContent($table->getHTML());
458  }
459 
463  protected function managePersonalTimings($failed = array())
464  {
465  global $ilErr, $ilAccess;
466 
467  if (!$ilAccess->checkAccess('read', '', $this->container_obj->getRefId())) {
468  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->WARNING);
469  }
470  $GLOBALS['ilTabs']->setTabActive('timings_timings');
471  $GLOBALS['ilTabs']->clearSubTabs();
472 
473  include_once './Modules/Course/classes/Timings/class.ilTimingsPersonalTableGUI.php';
475  $this,
476  'managePersonalTimings',
477  $this->getContainerObject(),
478  $this->course_obj
479  );
480  $table->setFailureStatus(count($failed));
481  $table->setUserId($GLOBALS['ilUser']->getId());
482  $table->init();
483  $table->parse(
485  $this->getContainerObject()->getRefId(),
486  false
487  ),
488  $failed
489  );
490  $GLOBALS['tpl']->setContent($table->getHTML());
491  }
492 
493 
499  protected function updatePersonalTimings()
500  {
501  global $ilAccess,$ilErr;
502 
503  if (!$ilAccess->checkAccess('read', '', $this->container_obj->getRefId())) {
504  $ilErr->raiseError($this->lng->txt('msg_no_perm_write'), $ilErr->WARNING);
505  }
506 
507  $this->tabs_gui->clearSubTabs();
508 
509  $failed = array();
510  include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
511  foreach ((array) $_POST['item'] as $ref_id => $data) {
512  $sug_start_dt = ilCalendarUtil::parseIncomingDate($data['sug_start']);
513  $sug_end_dt = ilCalendarUtil::parseIncomingDate($data['sug_end']);
514 
515  if (($sug_start_dt instanceof ilDate) and ($sug_end_dt instanceof ilDate)) {
516  include_once './Services/Calendar/classes/class.ilDateTime.php';
517  if (ilDateTime::_after($sug_start_dt, $sug_end_dt)) {
518  $failed[$ref_id] = 'crs_timing_err_start_end';
519  continue;
520  }
521  // update user date
522  include_once './Modules/Course/classes/Timings/class.ilTimingUser.php';
523  $tu = new ilTimingUser($ref_id, $GLOBALS['ilUser']->getId());
524  $tu->getStart()->setDate($sug_start_dt->get(IL_CAL_UNIX), IL_CAL_UNIX);
525  $tu->getEnd()->setDate($sug_end_dt->get(IL_CAL_UNIX), IL_CAL_UNIX);
526  $tu->update();
527  } else {
528  $failed['ref_id'] = 'crs_timing_err_valid_dates';
529  continue;
530  }
531  }
532  // cognos-blu-patch: begin
533  if (!$failed) {
534  ilUtil::sendSuccess($GLOBALS['lng']->txt('settings_saved'));
535  $this->managePersonalTimings();
536  return true;
537  } else {
538  ilUtil::sendFailure($this->lng->txt('err_check_input'));
540  return true;
541  }
542  // cognos-blu-patch: end
543  }
544 
545 
546 
547 
548 
549 
550 
551  public function editTimings()
552  {
553  global $DIC;
554 
555  $ilAccess = $DIC['ilAccess'];
556  $ilErr = $DIC['ilErr'];
557 
558  $this->lng->loadLanguageModule('meta');
559 
560  if (!$ilAccess->checkAccess('write', '', $this->container_obj->getRefId())) {
561  $ilErr->raiseError($this->lng->txt('msg_no_perm_write'), $ilErr->WARNING);
562  }
563  $this->tabs_gui->setTabActive('timings_timings');
564  $this->tabs_gui->clearSubTabs();
565 
566  $this->cont_arr = ilObjectActivation::getTimingsAdministrationItems($this->container_obj->getRefId());
567 
568  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.crs_edit_items.html', 'Modules/Course');
569  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
570  $this->tpl->setVariable("HEADER_IMG", ilUtil::getImagePath('icon_crs.svg'));
571  $this->tpl->setVariable("HEADER_ALT", $this->lng->txt('crs_materials'));
572  $this->tpl->setVariable("BLOCK_HEADER_CONTENT", $this->lng->txt('edit_timings_list'));
573  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt('title'));
574 
575 
576  $this->tpl->setVariable("TXT_DURATION", $this->lng->txt('crs_timings_time_frame'));
577  $this->tpl->setVariable("TXT_INFO_DURATION", $this->lng->txt('crs_timings_in_days'));
578 
579  $this->tpl->setVariable("TXT_START_END", $this->lng->txt('crs_timings_short_start_end'));
580  $this->tpl->setVariable("TXT_INFO_START_END", $this->lng->txt('crs_timings_start_end_info'));
581 
582  $this->tpl->setVariable("TXT_CHANGEABLE", $this->lng->txt('crs_timings_short_changeable'));
583 
584  $this->tpl->setVariable("TXT_INFO_LIMIT", $this->lng->txt('crs_timings_from_until'));
585  $this->tpl->setVariable("TXT_LIMIT", $this->lng->txt('crs_timings_short_limit_start_end'));
586  $this->tpl->setVariable("TXT_ACTIVE", $this->lng->txt('crs_timings_short_active'));
587  $this->tpl->setVariable("TXT_INFO_ACTIVE", $this->lng->txt('crs_timings_info_active'));
588 
589  $counter = 0;
590  foreach ($this->cont_arr as $item) {
591  if ($item['type'] == 'itgr') {
592  continue;
593  }
594  $item = $this->__loadFromPost($item);
595  $item_prefix = "item[$item[ref_id]]";
596  $item_change_prefix = "item_change[$item[ref_id]]";
597  $item_active_prefix = "item_active[$item[ref_id]]";
598 
599  if ($item['type'] == 'grp' or
600  $item['type'] == 'fold') {
601  $this->tpl->setVariable("TITLE_LINK", ilLink::_getLink($item['ref_id'], $item['type']));
602  $this->tpl->setVariable("TITLE_FRAME", ilFrameTargetInfo::_getFrame('MainContent', $item['type']));
603  $this->tpl->setVariable("TITLE_LINK_NAME", $item['title']);
604  } else {
605  if (!$item['title'] &&
606  $item['type'] == 'sess') {
607  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
609  $item['title'] = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'], $app_info['fullday']);
610  }
611 
612  $this->tpl->setVariable("TITLE", $item['title']);
613  }
614 
615  if (strlen($item['description'])) {
616  $this->tpl->setCurrentBlock("item_description");
617  $this->tpl->setVariable("DESC", $item['description']);
618  $this->tpl->parseCurrentBlock();
619  }
620 
621  if ($tlt = ilMDEducational::_getTypicalLearningTimeSeconds($item['obj_id'])) {
622  $this->tpl->setCurrentBlock("tlt");
623  $this->tpl->setVariable("TXT_TLT", $this->lng->txt('meta_typical_learning_time'));
624  $this->tpl->setVariable("TLT_VAL", ilDatePresentation::secondsToString($tlt));
625  $this->tpl->parseCurrentBlock();
626  }
627 
628  $this->tpl->setCurrentBlock("container_standard_row");
629 
630  // Suggested
631  if (is_array($_POST['item']["$item[ref_id]"]['sug_start'])) {
632  $start = $this->__toUnix($_POST['item']["$item[ref_id]"]['sug_start']);
633  } else {
634  $start = $item['suggestion_start'];
635  }
636  $end = $item['suggestion_end'];
637  $date = $this->__prepareDateSelect($start);
638  $this->tpl->setVariable(
639  "SUG_START",
641  $item_prefix . "[sug_start]",
642  $date['y'],
643  $date['m'],
644  $date['d'],
645  date('Y', time()),
646  false
647  )
648  );
649 
650  $this->tpl->setVariable("NAME_DURATION_A", $item_prefix . "[duration_a]");
651  if (isset($_POST['item']["$item[ref_id]"]['duration_a'])) {
652  $this->tpl->setVariable("VAL_DURATION_A", abs($_POST['item']["$item[ref_id]"]['duration_a']));
653  } else {
654  $this->tpl->setVariable("VAL_DURATION_A", intval(($end - $start) / (60 * 60 * 24)));
655  }
656 
657  $this->tpl->setVariable('SUG_END', ilDatePresentation::formatDate(new ilDate($item['suggestion_end'], IL_CAL_UNIX)));
658 
659 
660  $date = $this->__prepareDateSelect($end);
661  $this->tpl->setVariable(
662  "LIM_END",
664  $item_prefix . "[lim_end]",
665  $date['y'],
666  $date['m'],
667  $date['d'],
668  date('Y', time()),
669  false
670  )
671  );
672 
673  $this->tpl->setVariable("NAME_CHANGE", $item_change_prefix . "[change]");
674  $this->tpl->setVariable("NAME_ACTIVE", $item_active_prefix . "[active]");
675 
676  if (isset($_POST['item'])) {
677  $change = $_POST['item_change']["$item[ref_id]"]['change'];
678  $active = $_POST['item_active']["$item[ref_id]"]['active'];
679  } else {
680  $change = $item['changeable'];
681  $active = ($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING);
682  }
683 
684  $this->tpl->setVariable("CHECKED_ACTIVE", $active ? 'checked="checked"' : '');
685  $this->tpl->setVariable("CHECKED_CHANGE", $change ? 'checked="checked"' : '');
686 
687  if (isset($this->failed["$item[ref_id]"])) {
688  $this->tpl->setVariable("ROWCLASS", 'tblrowmarked');
689  } else {
690  $this->tpl->setVariable("ROWCLASS", ilUtil::switchColor($counter++, 'tblrow1', 'tblrow2'));
691  }
692  $this->tpl->parseCurrentBlock();
693  }
694 
695  // Select all
696  $this->tpl->setVariable("CHECKCLASS", ilUtil::switchColor($counter++, 'tblrow1', 'tblrow2'));
697  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt('select_all'));
698 
699  $this->tpl->setVariable("BTN_SAVE", $this->lng->txt('save'));
700  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt('cancel'));
701  }
702 
703  public function editUserTimings()
704  {
705  global $DIC;
706 
707  $ilAccess = $DIC['ilAccess'];
708  $ilErr = $DIC['ilErr'];
709 
710  if (!$ilAccess->checkAccess('read', '', $this->container_obj->getRefId())) {
711  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->WARNING);
712  }
713  $this->tabs_gui->clearSubTabs();
714  $this->tabs_gui->setTabActive('timings_timings');
715 
716  $_SESSION['crs_timings_user_hidden'] = isset($_GET['show_details']) ? $_GET['show_details'] : $_SESSION['crs_timings_user_hidden'];
717 
718  include_once 'Services/Object/classes/class.ilObjectActivation.php';
719  if (ilObjectActivation::hasChangeableTimings($this->course_obj->getRefId())) {
720  $this->__editAdvancedUserTimings();
721  } else {
722  $this->__editUserTimings();
723  }
724  }
725 
726  public function returnToMembers()
727  {
728  $this->ctrl->returnToParent($this);
729  }
730 
731  public function showUserTimings()
732  {
733  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.crs_user_timings.html', 'Modules/Course');
734  $this->tabs_gui->clearSubTabs();
735  $this->tabs_gui->setTabActive('members');
736 
737  if (!$_GET['member_id']) {
738  ilUtil::sendFailure($this->lng->txt('no_checkbox'), true);
739  $this->ctrl->returnToParent($this);
740  }
741 
742 
743  // Back button
744  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
745  $this->tpl->setCurrentBlock("btn_cell");
746  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, 'returnToMembers'));
747  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("back"));
748  $this->tpl->parseCurrentBlock();
749 
750 
751  $this->tpl->setVariable("HEADER_IMG", ilUtil::getImagePath('icon_usr.svg'));
752  $this->tpl->setVariable("HEADER_ALT", $this->lng->txt('obj_usr'));
753  $this->tpl->setVariable("TABLE_HEADER", $this->lng->txt('timings_of'));
754  $name = ilObjUser::_lookupName($_GET['member_id']);
755  $this->tpl->setVariable("USER_NAME", $name['lastname'] . ', ' . $name['firstname']);
756 
757  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt('title'));
758  $this->tpl->setVariable("TXT_START_END", $this->lng->txt('crs_timings_short_start_end'));
759  $this->tpl->setVariable("TXT_INFO_START_END", $this->lng->txt('crs_timings_start_end_info'));
760  $this->tpl->setVariable("TXT_CHANGED", $this->lng->txt('crs_timings_changed'));
761  $this->tpl->setVariable("TXT_OWN_PRESETTING", $this->lng->txt('crs_timings_planed_start'));
762  $this->tpl->setVariable("TXT_INFO_OWN_PRESETTING", $this->lng->txt('crs_timings_from_until'));
763 
764  include_once 'Services/Object/classes/class.ilObjectActivation.php';
765  $items = ilObjectActivation::getTimingsAdministrationItems($this->course_obj->getRefId());
766  foreach ($items as $item) {
767  if (($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) or
768  ilObjectActivation::hasChangeableTimings($item['ref_id'])) {
769  $this->__renderUserItem($item, 0);
770  }
771  }
772  }
773 
774  public function __renderUserItem($item, $level)
775  {
776  include_once 'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
777  include_once './Services/MetaData/classes/class.ilMDEducational.php';
778 
779  $this->lng->loadLanguageModule('meta');
780 
781  include_once './Modules/Course/classes/Timings/class.ilTimingUser.php';
782  $usr_planed = new ilTimingUser($item['ref_id'], (int) $_GET['member_id']);
783 
784  for ($i = 0;$i < $level;$i++) {
785  $this->tpl->touchBlock('start_indent');
786  $this->tpl->touchBlock('end_indent');
787  }
788  if (strlen($item['description'])) {
789  $this->tpl->setCurrentBlock("item_description");
790  $this->tpl->setVariable("DESC", $item['description']);
791  $this->tpl->parseCurrentBlock();
792  }
793  if ($tlt = ilMDEducational::_getTypicalLearningTimeSeconds($item['obj_id'])) {
794  $this->tpl->setCurrentBlock("tlt");
795  $this->tpl->setVariable("TXT_TLT", $this->lng->txt('meta_typical_learning_time'));
796  $this->tpl->setVariable("TLT_VAL", ilDatePresentation::secondsToString($tlt));
797  $this->tpl->parseCurrentBlock();
798  }
799 
800  if (!$item['title'] &&
801  $item['type'] == 'sess') {
802  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
804  $item['title'] = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'], $app_info['fullday']);
805  }
806 
807  $this->tpl->setCurrentBlock("title_plain");
808  $this->tpl->setVariable("TITLE", $item['title']);
809  $this->tpl->parseCurrentBlock();
810 
811  $this->tpl->setCurrentBlock("container_standard_row");
812 
813  $this->tpl->setVariable("ROWCLASS", ilUtil::switchColor($this->counter++, 'tblrow1', 'tblrow2'));
814  #$this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$item['type'].'.svg'));
815  $this->tpl->setVariable('TYPE_IMG', ilUtil::getTypeIconPath($item['type'], $item['obj_id'], 'tiny'));
816  $this->tpl->setVariable("TYPE_ALT_IMG", $this->lng->txt('obj_' . $item['type']));
817 
818  if ($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) {
819  if ($usr_planed->getStart()->get(IL_CAL_UNIX)) {
820  $this->tpl->setVariable('SUG_START', $usr_planed->getStart()->get(IL_CAL_DATE));
821  }
822  if ($usr_planed->getEnd()->get(IL_CAL_UNIX)) {
823  $this->tpl->setVariable('SUG_END', $usr_planed->getEnd()->get(IL_CAL_DATE));
824  }
825  }
826 
827 
828  if (0 and $item['changeable'] and $item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) {
829  if ($usr_planed->getPlanedStartingTime()) {
830  $start = $usr_planed->getPlanedStartingTime();
831  } else {
832  $start = $item['suggestion_start'];
833  }
834  $this->tpl->setVariable('OWN_START', ilDatePresentation::formatDate(new ilDate($start, IL_CAL_UNIX)));
835 
836  if ($usr_planed->getPlanedEndingTime() and 0) {
837  $end = $usr_planed->getPlanedEndingTime();
838  } else {
839  $end = $item['suggestion_end'];
840  }
841  if ($start != $item['suggestion_start'] or $end != $item['suggestion_end']) {
842  $this->tpl->setVariable("OK_IMG", ilUtil::getImagePath('icon_ok.svg'));
843  $this->tpl->setVariable("OK_ALT", $this->lng->txt('crs_timings_changed'));
844  } else {
845  $this->tpl->setVariable("OK_IMG", ilUtil::getImagePath('icon_not_ok.svg'));
846  $this->tpl->setVariable("OK_ALT", $this->lng->txt('crs_timings_not_changed'));
847  }
848  $this->tpl->setVariable('OWN_END', ilDatePresentation::formatDate(new ilDate($end, IL_CAL_UNIX)));
849  }
850 
851  $this->tpl->parseCurrentBlock();
852 
853  foreach (ilObjectActivation::getTimingsAdministrationItems($item['ref_id']) as $item_data) {
854  if (($item_data['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) or
855  ilObjectActivation::hasChangeableTimings($item_data['ref_id'])) {
856  $this->__renderUserItem($item_data, $level + 1);
857  }
858  }
859  }
860 
861 
862 
863  public function __editAdvancedUserTimings()
864  {
865  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.crs_usr_edit_timings_adv.html', 'Modules/Course');
866 
867  $this->tabs_gui->clearSubTabs();
868 
869  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
870  $this->tpl->setVariable("HEADER_IMG", ilUtil::getImagePath('icon_crs.svg'));
871  $this->tpl->setVariable("HEADER_ALT", $this->lng->txt('obj_crs'));
872  $this->tpl->setVariable("BLOCK_HEADER_CONTENT", $this->lng->txt('timings_usr_edit'));
873 
874  if (!$_SESSION['crs_timings_user_hidden']) {
875  $this->tpl->setVariable("SHOW_HIDE_TEXT", $this->lng->txt('show_details'));
876  $this->ctrl->setParameter($this, 'show_details', 1);
877  $this->tpl->setVariable("SHOW_HIDE_LINK", $this->ctrl->getLinkTarget($this, 'editUserTimings'));
878  } else {
879  $this->tpl->setVariable("SHOW_HIDE_TEXT", $this->lng->txt('hide_details'));
880  $this->ctrl->setParameter($this, 'show_details', 0);
881  $this->tpl->setVariable("SHOW_HIDE_LINK", $this->ctrl->getLinkTarget($this, 'editUserTimings'));
882  }
883  $this->ctrl->clearParameters($this);
884  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt('title'));
885  $this->tpl->setVariable("TXT_START_END", $this->lng->txt('crs_timings_short_start_end'));
886  $this->tpl->setVariable("TXT_INFO_START_END", $this->lng->txt('crs_timings_start_end_info'));
887 
888 
889  $this->tpl->setVariable("TXT_OWN_PRESETTING", $this->lng->txt('crs_timings_planed_start'));
890  $this->tpl->setVariable("TXT_INFO_OWN_PRESETTING", $this->lng->txt('crs_timings_start_end_info'));
891 
892  $this->tpl->setVariable("TXT_DURATION", $this->lng->txt('crs_timings_time_frame'));
893  $this->tpl->setVariable("TXT_INFO_DURATION", $this->lng->txt('crs_timings_in_days'));
894 
895  $this->tpl->setVariable("TXT_BTN_UPDATE", $this->lng->txt('save'));
896  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt('cancel'));
897 
898  include_once 'Services/Object/classes/class.ilObjectActivation.php';
899  $sorted_items = ilObjectActivation::getTimingsItems($this->course_obj->getRefId());
900 
901  $this->counter = 0;
902  foreach ($sorted_items as $item) {
903  switch ($item['type']) {
904  case 'itgr':
905  break;
906 
907  default:
908  $this->__renderItem($item, 0);
909  break;
910  }
911  }
912  }
913 
914  public function __editUserTimings()
915  {
916  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.crs_usr_edit_timings.html', 'Modules/Course');
917 
918  $this->tabs_gui->clearSubTabs();
919 
920  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
921  $this->tpl->setVariable("HEADER_IMG", ilUtil::getImagePath('icon_crs.svg'));
922  $this->tpl->setVariable("HEADER_ALT", $this->lng->txt('obj_crs'));
923 
924  if (!$_SESSION['crs_timings_user_hidden']) {
925  $this->tpl->setVariable("SHOW_HIDE_TEXT", $this->lng->txt('show_details'));
926  $this->ctrl->setParameter($this, 'show_details', 1);
927  $this->tpl->setVariable("SHOW_HIDE_LINK", $this->ctrl->getLinkTarget($this, 'editUserTimings'));
928  } else {
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  switch ($item['type']) {
946  case 'itgr':
947  break;
948 
949  default:
950  $this->__renderItem($item, 0);
951  break;
952  }
953  }
954  }
955 
956  public function __renderItem($item, $level)
957  {
958  global $DIC;
959 
960  $ilUser = $DIC['ilUser'];
961  $ilAccess = $DIC['ilAccess'];
962 
963  include_once 'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
964  include_once './Services/Link/classes/class.ilLink.php';
965  include_once './Services/MetaData/classes/class.ilMDEducational.php';
966 
967  if (!$ilAccess->checkAccess('visible', '', $item['ref_id'])) {
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  $this->tpl->touchBlock('start_indent');
977  $this->tpl->touchBlock('end_indent');
978  }
979  if (strlen($item['description'])) {
980  $this->tpl->setCurrentBlock("item_description");
981  $this->tpl->setVariable("DESC", $item['description']);
982  $this->tpl->parseCurrentBlock();
983  }
984  if ($tlt = ilMDEducational::_getTypicalLearningTimeSeconds($item['obj_id'])) {
985  $this->tpl->setCurrentBlock("tlt");
986  $this->tpl->setVariable("TXT_TLT", $this->lng->txt('meta_typical_learning_time'));
987  $this->tpl->setVariable("TLT_VAL", ilDatePresentation::secondsToString($tlt));
988  $this->tpl->parseCurrentBlock();
989  }
990 
991  if (!$item['title'] &&
992  $item['type'] == 'sess') {
993  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
995  $item['title'] = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'], $app_info['fullday']);
996  }
997 
998  if ($ilAccess->checkAccess('read', '', $item['ref_id'])) {
999  $this->tpl->setCurrentBlock("title_as_link");
1000  $this->tpl->setVariable("TITLE_LINK", ilLink::_getLink($item['ref_id'], $item['type']));
1001  $this->tpl->setVariable("TITLE_NAME", $item['title']);
1002  $this->tpl->parseCurrentBlock();
1003  } else {
1004  $this->tpl->setCurrentBlock("title_plain");
1005  $this->tpl->setVariable("TITLE", $item['title']);
1006  $this->tpl->parseCurrentBlock();
1007  }
1008  $this->tpl->setCurrentBlock("container_standard_row");
1009 
1010  if (isset($this->invalid["$item[ref_id]"])) {
1011  $this->tpl->setVariable("ROWCLASS", 'tblrowmarked');
1012  } else {
1013  $this->tpl->setVariable("ROWCLASS", ilUtil::switchColor($this->counter++, 'tblrow1', 'tblrow2'));
1014  }
1015  #$this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$item['type'].'.svg'));
1016  $this->tpl->setVariable('TYPE_IMG', ilUtil::getTypeIconPath($item['type'], $item['obj_id'], 'small'));
1017  $this->tpl->setVariable("TYPE_ALT_IMG", $this->lng->txt('obj_' . $item['type']));
1018 
1019 
1020  if ($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) {
1021  $this->tpl->setVariable('SUG_START', ilDatePresentation::formatDate(new ilDate($item['suggestion_start'], IL_CAL_UNIX)));
1022  $this->tpl->setVariable('SUG_END', ilDatePresentation::formatDate(new ilDate($item['suggestion_end'], IL_CAL_UNIX)));
1023  }
1024 
1025  if ($item['changeable']) {
1026  $item_prefix = "item[" . $item['ref_id'] . ']';
1027 
1028  if (is_array($_POST['item']["$item[ref_id]"]['own_start'])) {
1029  #echo "Start post<br>";
1030  $start = $this->__toUnix($_POST['item']["$item[ref_id]"]['own_start']);
1031  } elseif ($usr_planed->getPlanedStartingTime()) {
1032  #echo "Own start<br>";
1033  $start = $usr_planed->getPlanedStartingTime();
1034  } else {
1035  #echo "Empfehlung start<br>";
1036  $start = $item['suggestion_start'];
1037  }
1038 
1039  $date = $this->__prepareDateSelect($start);
1040  $this->tpl->setVariable(
1041  "OWN_START",
1043  $item_prefix . "[own_start]",
1044  $date['y'],
1045  $date['m'],
1046  $date['d'],
1047  date('Y', time()),
1048  false
1049  )
1050  );
1051 
1052  if ($usr_planed->getPlanedEndingTime()) {
1053  #echo "Own End<br>";
1054  $end = $usr_planed->getPlanedEndingTime();
1055  } else {
1056  #echo "Empfehlung end<br>";
1057  $end = $item['suggestion_end'];
1058  }
1059  $this->tpl->setVariable('OWN_END', ilDatePresentation::formatDate(new ilDate($end, IL_CAL_UNIX)));
1060  $this->tpl->setVariable("NAME_DURATION", $item_prefix . "[duration]");
1061 
1062  // Duration
1063  if (isset($_POST['item']["$item[ref_id]"]['duration'])) {
1064  $this->tpl->setVariable("VAL_DURATION", $_POST['item']["$item[ref_id]"]['duration']);
1065  } else {
1066  $this->tpl->setVariable("VAL_DURATION", intval(($end - $start) / (60 * 60 * 24)));
1067  }
1068  }
1069 
1070  $this->tpl->parseCurrentBlock();
1071 
1072  if (!$_SESSION['crs_timings_user_hidden']) {
1073  return true;
1074  }
1075 
1076  foreach (ilObjectActivation::getTimingsItems($item['ref_id']) as $item_data) {
1077  $this->__renderItem($item_data, $level + 1);
1078  }
1079  }
1080 
1081 
1082  public function updateUserTimings()
1083  {
1084  global $DIC;
1085 
1086  $ilUser = $DIC['ilUser'];
1087  $ilObjDataCache = $DIC['ilObjDataCache'];
1088  include_once 'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
1089 
1090  $this->tabs_gui->clearSubTabs();
1091 
1092  // Validate
1093  $this->invalid = array();
1094  foreach ($_POST['item'] as $ref_id => $data) {
1095  $tmp_planed = new ilTimingPlaned($ref_id, $ilUser->getId());
1096 
1097  $tmp_planed->setPlanedStartingTime($this->__toUnix($data['own_start']));
1098  if (isset($data['duration'])) {
1099  $data['own_start']['d'] += $data['duration'];
1100  $tmp_planed->setPlanedEndingTime($this->__toUnix($data['own_start'], array('h' => 23,'m' => 55)));
1101  } else {
1102  $tmp_planed->setPlanedEndingTime($this->__toUnix($data['own_start']), array('h' => 23,'m' => 55));
1103  }
1104  if (!$tmp_planed->validate()) {
1105  $this->invalid[$ref_id] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($ref_id));
1106  }
1107  $all_items[] = $tmp_planed;
1108  }
1109  if (count($this->invalid)) {
1110  $message = $this->lng->txt('crs_timings_update_error');
1111  $message .= ("<br />" . $this->lng->txt('crs_materials') . ': ');
1112  $message .= (implode(',', $this->invalid));
1114  $this->editUserTimings();
1115  return false;
1116  }
1117  foreach ($all_items as $new_item_obj) {
1118  $new_item_obj->update();
1119  }
1120  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1121  $this->editUserTimings();
1122  return true;
1123  }
1124 
1125 
1126  public function &__loadFromPost(&$item)
1127  {
1128  $obj_id = $item['obj_id'];
1129 
1130  if (!isset($_POST['item'][$obj_id])) {
1131  return $item;
1132  }
1133  $item['suggestion_start'] = $this->__toUnix($_POST['item'][$obj_id]['sug_start']);
1134  if (isset($_POST['item'][$obj_id]['sug_end'])) {
1135  // #9325
1136  $item['suggestion_end'] = $this->__toUnix($_POST['item'][$obj_id]['sug_end']);
1137  }
1138  $item['changeable'] = $_POST['item'][$obj_id]['change'];
1139  $item['timing_type'] = $_POST['item'][$obj_id]['active'] ? ilObjectActivation::TIMINGS_PRESETTING : $item['timing_type'];
1140  $item['duration_a'] = $_POST['item'][$obj_id]['duration_a'];
1141  $item['duration_b'] = $_POST['item'][$obj_id]['duration_b'];
1142 
1143  return $item;
1144  }
1145 
1150  protected function updateManagedTimings()
1151  {
1152  global $DIC;
1153 
1154  $ilAccess = $DIC->access();
1155  $ilErr = $DIC['ilErr'];
1156 
1157  if (!$ilAccess->checkAccess('write', '', $this->container_obj->getRefId())) {
1158  $ilErr->raiseError($this->lng->txt('msg_no_perm_write'), $ilErr->WARNING);
1159  }
1160 
1161  $this->tabs_gui->clearSubTabs();
1162 
1163  $failed = array();
1164  $all_items = array();
1165  include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
1166  foreach ((array) $_POST['item'] as $ref_id => $data) {
1167  $item_obj = new ilObjectActivation();
1168  $item_obj->read($ref_id);
1169 
1171  #$item_obj->setTimingStart($old_data['timing_start']);
1172  #$item_obj->setTimingEnd($old_data['timing_end']);
1173  #$item_obj->toggleVisible($old_data['visible']);
1174  $item_obj->toggleChangeable((int) $data['change']);
1175 
1176  if ($this->course_obj->getTimingMode() == ilCourseConstants::IL_CRS_VIEW_TIMING_ABSOLUTE) {
1177  $sug_start_dt = ilCalendarUtil::parseIncomingDate($data['sug_start']);
1178  $sug_end_dt = ilCalendarUtil::parseIncomingDate($data['sug_end']);
1179 
1180 
1181  if (($sug_start_dt instanceof ilDate) and ($sug_end_dt instanceof ilDate)) {
1182  include_once './Services/Calendar/classes/class.ilDateTime.php';
1183  if (ilDateTime::_after($sug_start_dt, $sug_end_dt)) {
1184  $failed[$ref_id] = 'crs_timing_err_start_end';
1185  continue;
1186  }
1187  $item_obj->setSuggestionStart($sug_start_dt->get(IL_CAL_UNIX));
1188  $item_obj->setSuggestionEnd($sug_end_dt->get(IL_CAL_UNIX));
1189  } else {
1190  $failed['ref_id'] = 'crs_timing_err_valid_dates';
1191  continue;
1192  }
1193  } else {
1194  if (
1195  ((int) $data['sug_start_rel'] < 0) or
1196  ((int) $data['duration_a'] < 0)
1197  ) {
1198  $failed[$ref_id] = 'crs_timing_err_start_dur_rel';
1199  continue;
1200  }
1201  $item_obj->setSuggestionStartRelative($data['sug_start_rel']);
1202  $item_obj->setSuggestionEndRelative($data['sug_start_rel'] + $data['duration_a']);
1203 
1204  // add default values for start/end (relative to now)
1205  $start = new ilDate(time(), IL_CAL_UNIX);
1206  $start->increment(IL_CAL_DAY, $data['sug_start_rel']);
1207  $item_obj->setSuggestionStart($start->get(IL_CAL_UNIX));
1208 
1209  $start->increment(IL_CAL_DAY, $data['duration_a']);
1210  $item_obj->setSuggestionEnd($start->get(IL_CAL_UNIX));
1211  }
1212 
1213  $item_obj->update($ref_id);
1214  }
1215  if (!$failed) {
1216  // update course => create calendar entries
1217  $this->course_obj->update();
1218 
1219  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1220  $this->manageTimings();
1221 
1222  return true;
1223  } else {
1224  ilUtil::sendFailure($this->lng->txt('err_check_input'));
1225  $this->manageTimings($failed);
1226  return true;
1227  }
1228  }
1229 
1230  public function updateTimings()
1231  {
1232  global $DIC;
1233 
1234  $ilAccess = $DIC['ilAccess'];
1235  $ilErr = $DIC['ilErr'];
1236 
1237  if (!$ilAccess->checkAccess('write', '', $this->container_obj->getRefId())) {
1238  $ilErr->raiseError($this->lng->txt('msg_no_perm_write'), $ilErr->WARNING);
1239  }
1240  $this->failed = array();
1241  // Validate
1242 
1243  $_POST['item'] = is_array($_POST['item']) ? $_POST['item'] : array();
1244  $all_items = array();
1245 
1246  foreach ($_POST['item'] as $ref_id => $data) {
1247  $item_obj = new ilObjectActivation();
1248  $old_data = ilObjectActivation::getItem($ref_id);
1249 
1250  $item_obj->setTimingType($_POST['item_active'][$ref_id]['active'] ?
1253  $item_obj->setTimingStart($old_data['timing_start']);
1254  $item_obj->setTimingEnd($old_data['timing_end']);
1255  $item_obj->setSuggestionStart($this->__toUnix($data["sug_start"]));
1256 
1257  // add duration
1258  $data['sug_start']['d'] += abs($data['duration_a']);
1259  $item_obj->setSuggestionEnd($this->__toUnix($data['sug_start'], array('h' => 23,'m' => 55)));
1260  $item_obj->toggleVisible($old_data['visible']);
1261  $item_obj->toggleChangeable($_POST['item_change'][$ref_id]['change']);
1262 
1263  if (!$item_obj->validateActivation()) {
1264  $this->failed[$ref_id] = $old_data['title'];
1265  }
1266  $all_items[$ref_id] = &$item_obj;
1267  unset($item_obj);
1268  }
1269 
1270  if (count($this->failed)) {
1271  $message = $this->lng->txt('crs_timings_update_error');
1272  $message .= ("<br />" . $this->lng->txt('crs_materials') . ': ');
1273  $message .= (implode(',', $this->failed));
1275  $this->editTimings();
1276  return false;
1277  }
1278 
1279  // No do update
1280  foreach ($all_items as $ref_id => $item_obj_new) {
1281  $item_obj_new->update($ref_id);
1282  }
1283  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1284  $this->editTimings();
1285  return false;
1286  }
1287 
1288  public function __setSubTabs()
1289  {
1290  if ($this->container_obj->getType() == 'crs') {
1291  $this->container_gui->setContentSubTabs();
1292  }
1293  }
1294 
1295  public function __initCourseObject()
1296  {
1297  global $DIC;
1298 
1299  $tree = $DIC['tree'];
1300 
1301  if ($this->container_obj->getType() == 'crs') {
1302  // Container is course
1303  $this->course_obj = &$this->container_obj;
1304  } else {
1305  $course_ref_id = $tree->checkForParentType($this->container_obj->getRefId(), 'crs');
1306  $this->course_obj = &ilObjectFactory::getInstanceByRefId($course_ref_id);
1307  }
1308  return true;
1309  }
1310 
1311  public function __toUnix($date, $time = array())
1312  {
1313  return gmmktime($time['h'], $time['m'], 0, $date['m'], $date['d'], $date['y']);
1314  }
1315 
1316  public function __prepareDateSelect($a_unix_time)
1317  {
1318  return array('y' => date('Y', $a_unix_time),
1319  'm' => date('m', $a_unix_time),
1320  'd' => date('d', $a_unix_time));
1321  }
1322 
1323  public function __prepareTimeSelect($a_unix_time)
1324  {
1325  return array('h' => date('G', $a_unix_time),
1326  'm' => date('i', $a_unix_time),
1327  's' => date('s', $a_unix_time));
1328  }
1329 
1330 
1331  public function __buildPath($a_ref_id)
1332  {
1333  global $DIC;
1334 
1335  $tree = $DIC['tree'];
1336 
1337  $path_arr = $tree->getPathFull($a_ref_id, $this->course_obj->getRefId());
1338  $counter = 0;
1339  foreach ($path_arr as $data) {
1340  if ($counter++) {
1341  $path .= " -> ";
1342  }
1343  $path .= $data['title'];
1344  }
1345 
1346  return $path;
1347  }
1348 } // END class.ilCourseContentGUI
managePersonalTimings($failed=array())
Manage personal timings.
static _lookupName($a_user_id)
lookup user name
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.
__toUnix($date, $time=array())
$path
Definition: aliased.php:25
static getItems($a_parent_id, $a_with_list_data=true)
Get sub item data.
updatePersonalTimings()
Update personal timings type $ilAccess type $ilErr.
static getCmdSide()
Get Column Side of Current Command.
static _getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
$_SESSION["AccountId"]
$type
view()
Output course content.
getRightColumnHTML()
Display right column.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
class ilTimingPlaned
static getTimingsItems($a_container_ref_id)
Get (sub) item data for timings view (no session material, no side blocks)
TableGUI class for timings administration.
static getItem($a_ref_id)
Get item data.
const IL_COL_RIGHT
const IL_CAL_UNIX
const IL_CRS_VIEW_TIMING
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
Class ilObj<module_name>
global $ilCtrl
Definition: ilias.php:18
$start
Definition: bench.php:8
$time
Definition: cron.php:21
getCenterColumnHTML()
Get center column.
const IL_CAL_DAY
catch(Exception $e) $message
const IL_SCREEN_FULL
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
Class for single dates.
static getTimingsAdministrationItems($a_parent_id)
Get (sub) item data for timings administration view (active/inactive)
Column user interface class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static hasChangeableTimings($a_ref_id)
Check if there is any active changeable timing (in subtree)
static _lookupObjId($a_id)
static _appointmentToString($start, $end, $fulltime)
$ilUser
Definition: imgupload.php:18
static _checkAllConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type="", $a_usr_id=0)
checks wether all conditions of a target object are fulfilled
manageTimings($failed_items=array())
Manage timings type $ilAccess type $ilErr.
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
STATIC, do not use $this inside!
static makeDateSelect($prefix, $year="", $month="", $day="", $startyear="", $a_long_month=true, $a_further_options=array(), $emptyoption=false)
Creates a combination of HTML selects for date inputs.
$failed
Definition: Utf8Test.php:85
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
TableGUI class for timings administration.
const IL_CAL_DATE
static getScreenMode()
Get Screen Mode for current command.
static _getFrame($a_class, $a_type='')
Get content frame name.
__construct($container_gui_obj)
Constructor public.
setPlanedStartingTime($a_time)
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
Class ilCourseContentGUI.
static _lookupAppointment($a_obj_id)
lookup appointment
$i
Definition: disco.tpl.php:19
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
__forwardToColumnGUI()
Get columngui output.
if(empty($password)) $table
Definition: pwgen.php:24
TableGUI class for editing personal timings.
const IL_SCREEN_SIDE
Class ilObjectActivation.
class ilCourseLMHistory
$_POST["username"]
$html
Definition: example_001.php:87
static parseIncomingDate($a_value, $a_add_time=null)
Try to parse incoming value to date object.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
const IL_COL_LEFT