ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSessionClassificationPathGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
12 
17  protected function buildTitle($a_obj_id)
18  {
19  if (ilObject::_lookupType($a_obj_id) !== 'sess') {
20  return ilObject::_lookupTitle($a_obj_id);
21  }
22  $sess = new \ilObjSession($a_obj_id, false);
23  return $sess->getPresentationTitleAppointmentPeriod();
24  }
25 
29  protected function getPathIds()
30  {
31  global $DIC;
32 
33  $access = $DIC->access();
34 
35  $this->enableHideLeaf(false);
36  $path = parent::getPathIds();
37  $this->enableHideLeaf(true);
38 
39  $new_path = [];
40  foreach ($path as $path_item_ref_id) {
41  $session_container = $this->findSessionContainerForItem($path_item_ref_id);
42  if ($session_container) {
43  $new_path[] = $session_container;
44  }
45  $new_path[] = $path_item_ref_id;
46  }
47 
48  // hide leaf
49  if (is_array($new_path) && count($new_path) > 0) {
50  unset($new_path[count($new_path) - 1]);
51  }
52  return $new_path;
53  }
54 
58  protected function findSessionContainerForItem($item_ref_id)
59  {
60  global $DIC;
61 
62  $access = $DIC->access();
63 
64  $accessible = [];
65  foreach (ilEventItems::getEventsForItemOrderedByStartingTime($item_ref_id) as $event_obj_id => $unix_time) {
66  foreach (ilObject::_getAllReferences($event_obj_id) as $something => $session_ref_id) {
67  if ($access->checkAccess('read', '', $session_ref_id)) {
68  $accessible[$session_ref_id] = $unix_time;
69  break;
70  }
71  }
72  }
73 
74 
75  // find closest in the future
76  $now = new ilDate(time(), IL_CAL_UNIX);
77  $now->increment(IL_CAL_DAY, -1);
78  $last = 0;
79  foreach ($accessible as $session_ref_id => $unix_time) {
80  $session_date = new ilDate($unix_time, IL_CAL_UNIX);
81  $last = $session_ref_id;
82 
83  if (
84  ilDate::_equals($now, $session_date, IL_CAL_DAY) ||
85  ilDate::_after($session_date, $now, IL_CAL_DAY)
86  ) {
87  return $session_ref_id;
88  }
89  }
90  return 0;
91  }
92 }
Creates a path for a start and endnode.
$path
Definition: aliased.php:25
global $DIC
Definition: saml.php:7
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.
static getEventsForItemOrderedByStartingTime($item_ref_id)
static _lookupTitle($a_id)
lookup object title
const IL_CAL_UNIX
static _getAllReferences($a_id)
get all reference ids of object
const IL_CAL_DAY
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
Class for single dates.
enableHideLeaf($a_status)
Hide leaf node in path.
PathGUI which handles materials assigned to sessions.
static _lookupType($a_id, $a_reference=false)
lookup object type