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