ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSessionClassificationPathGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected ilAccess $access;
29
30 public function __construct()
31 {
32 global $DIC;
34 $this->access = $DIC->access();
35 }
36
37 protected function buildTitle(int $a_obj_id): string
38 {
39 if (ilObject::_lookupType($a_obj_id) !== 'sess') {
40 return ilObject::_lookupTitle($a_obj_id);
41 }
42 $sess = new \ilObjSession($a_obj_id, false);
43 return $sess->getPresentationTitleAppointmentPeriod();
44 }
45
49 protected function getPathIds(): array
50 {
51 $this->enableHideLeaf(false);
52 $path = parent::getPathIds();
53 $this->enableHideLeaf(true);
54
55 $new_path = [];
56 foreach ($path as $path_item_ref_id) {
57 $session_container = $this->findSessionContainerForItem($path_item_ref_id);
58 if ($session_container) {
59 $new_path[] = $session_container;
60 }
61 $new_path[] = $path_item_ref_id;
62 }
63
64 // hide leaf
65 if (is_array($new_path) && count($new_path) > 0) {
66 unset($new_path[count($new_path) - 1]);
67 }
68 return $new_path;
69 }
70
71 protected function findSessionContainerForItem(int $item_ref_id): int
72 {
74
75 $accessible = [];
76 foreach (ilEventItems::getEventsForItemOrderedByStartingTime($item_ref_id) as $event_obj_id => $unix_time) {
77 foreach (ilObject::_getAllReferences($event_obj_id) as $something => $session_ref_id) {
78 if ($access->checkAccess('read', '', $session_ref_id)) {
79 $accessible[$session_ref_id] = $unix_time;
80 break;
81 }
82 }
83 }
84
85
86 // find closest in the future
87 $now = new ilDate(time(), IL_CAL_UNIX);
88 $now->increment(IL_CAL_DAY, -1);
89 $last = 0;
90 foreach ($accessible as $session_ref_id => $unix_time) {
91 $session_date = new ilDate($unix_time, IL_CAL_UNIX);
92 $last = $session_ref_id;
93
94 if (
95 ilDate::_equals($now, $session_date, IL_CAL_DAY) ||
96 ilDate::_after($session_date, $now, IL_CAL_DAY)
97 ) {
98 return (int) $session_ref_id;
99 }
100 }
101 return 0;
102 }
103}
const IL_CAL_UNIX
const IL_CAL_DAY
Class ilAccessHandler Checks access for ILIAS objects.
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)
enableHideLeaf(bool $a_status)
Hide leaf node in path.
PathGUI which handles materials assigned to sessions.
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26