ILIAS  release_8 Revision v8.24
class.ilSessionClassificationPathGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
29{
30 protected ilAccess $access;
31
32 public function __construct()
33 {
34 global $DIC;
36 $this->access = $DIC->access();
37 }
38
39 protected function buildTitle(int $a_obj_id): string
40 {
41 if (ilObject::_lookupType($a_obj_id) !== 'sess') {
42 return ilObject::_lookupTitle($a_obj_id);
43 }
44 $sess = new \ilObjSession($a_obj_id, false);
45 return $sess->getPresentationTitleAppointmentPeriod();
46 }
47
51 protected function getPathIds(): array
52 {
53 $this->enableHideLeaf(false);
54 $path = parent::getPathIds();
55 $this->enableHideLeaf(true);
56
57 $new_path = [];
58 foreach ($path as $path_item_ref_id) {
59 $session_container = $this->findSessionContainerForItem($path_item_ref_id);
60 if ($session_container) {
61 $new_path[] = $session_container;
62 }
63 $new_path[] = $path_item_ref_id;
64 }
65
66 // hide leaf
67 if (is_array($new_path) && count($new_path) > 0) {
68 unset($new_path[count($new_path) - 1]);
69 }
70 return $new_path;
71 }
72
73 protected function findSessionContainerForItem(int $item_ref_id): int
74 {
76
77 $accessible = [];
78 foreach (ilEventItems::getEventsForItemOrderedByStartingTime($item_ref_id) as $event_obj_id => $unix_time) {
79 foreach (ilObject::_getAllReferences($event_obj_id) as $something => $session_ref_id) {
80 if ($access->checkAccess('read', '', $session_ref_id)) {
81 $accessible[$session_ref_id] = $unix_time;
82 break;
83 }
84 }
85 }
86
87
88 // find closest in the future
89 $now = new ilDate(time(), IL_CAL_UNIX);
90 $now->increment(IL_CAL_DAY, -1);
91 $last = 0;
92 foreach ($accessible as $session_ref_id => $unix_time) {
93 $session_date = new ilDate($unix_time, IL_CAL_UNIX);
94 $last = $session_ref_id;
95
96 if (
97 ilDate::_equals($now, $session_date, IL_CAL_DAY) ||
98 ilDate::_after($session_date, $now, IL_CAL_DAY)
99 ) {
100 return (int) $session_ref_id;
101 }
102 }
103 return 0;
104 }
105}
const IL_CAL_UNIX
const IL_CAL_DAY
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static _equals(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check if two date are equal.
Class for single dates.
static getEventsForItemOrderedByStartingTime(int $item_ref_id)
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
Creates a path for a start and endnode.
enableHideLeaf(bool $a_status)
Hide leaf node in path.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$path
Definition: ltiservices.php:32
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc