ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSessionOverviewTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 protected ilTree $tree;
31 protected array $events = [];
32
36 protected $renderer;
37
41 protected $ui_factory;
42
43 public function __construct(object $a_parent_obj, string $a_parent_cmd, int $a_crs_ref_id, array $a_members)
44 {
45 global $DIC;
46
47 $this->ui_factory = $DIC->ui()->factory();
48 $this->renderer = $DIC->ui()->renderer();
49
50 $this->tree = $DIC->repositoryTree();
51 $this->access = $DIC->access();
52
53 $this->setId('sessov');
54
55 parent::__construct($a_parent_obj, $a_parent_cmd);
56
57 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
58
59 $this->setTitle($this->lng->txt('event_overview'));
60
61 $this->addColumn($this->lng->txt('name'), 'name');
62 $this->addColumn($this->lng->txt('login'), 'login');
63
64 $this->events = $this->gatherEvents($a_crs_ref_id);
65 foreach ($this->events as $idx => $event_obj) {
66 // tooltip properties
67 $tt = [];
68 if (trim($event_obj->getTitle())) {
69 $tt[] = $event_obj->getTitle();
70 }
71 if (trim($event_obj->getDescription())) {
72 $tt[] = $event_obj->getDescription();
73 }
74 if (trim($event_obj->getLocation())) {
75 $tt[] = $this->lng->txt("event_location") . ': ' . $event_obj->getLocation();
76 }
77 $tt[] = $this->lng->txt("event_date_time") . ': ' . $event_obj->getFirstAppointment()->appointmentToString();
78
79 // use title/datetime
80 if (sizeof($this->events) <= 4) {
81 $caption = $event_obj->getFirstAppointment()->appointmentToString();
82 if (sizeof($tt) == 1) {
83 $tt = [];
84 }
85 }
86 // use sequence
87 else {
88 $caption = $idx + 1;
89 }
90 $tt = implode("<br />\n", $tt);
91
92 $this->addColumn((string) $caption, 'event_' . $event_obj->getId(), '', false, '', $tt, true);
93 }
94
95 $this->setDefaultOrderField('name');
96 $this->setDefaultOrderDirection('asc');
97
98 $this->setRowTemplate('tpl.sess_list_row.html', 'components/ILIAS/Session');
99
100 $this->getItems($this->events, $a_members);
101 }
102
103 protected function gatherEvents(int $a_crs_ref_id): array
104 {
106 $ilAccess = $this->access;
107
108 $events = [];
109 foreach ($tree->getSubtree($tree->getNodeData($a_crs_ref_id), false, ['sess']) as $event_id) {
110 $tmp_event = ilObjectFactory::getInstanceByRefId($event_id, false);
111 if (!is_object($tmp_event) ||
112 !$ilAccess->checkAccess('manage_members', '', $event_id)) {
113 continue;
114 }
115 // sort by date of 1st appointment
116 $events[$tmp_event->getFirstAppointment()->getStartingTime() . '_' . $tmp_event->getId()] = $tmp_event;
117 }
118
119 ksort($events);
120 return array_values($events);
121 }
122
123 protected function getItems(array $a_events, array $a_members): void
124 {
125 $data = [];
126 foreach ($a_members as $user_id) {
128 $data[$user_id] = array(
129 'name' => $name['lastname'] . ', ' . $name['firstname'],
130 'login' => $name['login']
131 );
132 }
133 foreach ($a_events as $event_obj) {
134 $users_of_event = ilEventParticipants::_getParticipated($event_obj->getID());
135 foreach ($a_members as $user_id) {
136 if (array_key_exists($user_id, $users_of_event)) {
137 $data[$user_id]['event_' . $event_obj->getId()] = true;
138 } else {
139 $data[$user_id]['event_' . $event_obj->getId()] = false;
140 }
141 }
142 }
143 $this->setData($data);
144 }
145
146 protected function fillRow(array $a_set): void
147 {
148 $this->tpl->setVariable('NAME', $a_set['name']);
149 $this->tpl->setVariable('LOGIN', $a_set['login']);
150
151 $this->tpl->setCurrentBlock('eventcols');
152 foreach ($this->events as $event_obj) {
153 if ($a_set['event_' . $event_obj->getId()]) {
154 $icon = $this->ui_factory->symbol()->icon()->custom(ilUtil::getImagePath('standard/icon_ok.svg'), $this->lng->txt('event_participated'));
155 } else {
156 $icon = $this->ui_factory->symbol()->icon()->custom(ilUtil::getImagePath('standard/icon_not_ok.svg'), $this->lng->txt('event_not_participated'));
157 }
158 $this->tpl->setVariable("IMAGE_PARTICIPATED", $this->renderer->render($icon));
159 $this->tpl->parseCurrentBlock();
160 }
161 }
162}
renderer()
static _getParticipated(int $a_event_id)
static _lookupName(int $a_user_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Table presentation for session overview.
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_crs_ref_id, array $a_members)
getItems(array $a_events, array $a_members)
fillRow(array $a_set)
Standard Version of Fill Row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26