ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjSessionListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29{
31 protected ilLanguage $lng;
32 protected array $app_info = [];
33 protected bool $subitems_enabled = false;
34 protected string $title = "";
35
36 public function __construct()
37 {
38 global $DIC;
39
40 $this->lng = $DIC->language();
41 $this->ctrl = $DIC->ctrl();
42
43 $this->lng->loadLanguageModule('crs');
44 $this->lng->loadLanguageModule('sess');
45
47 }
48
49 public function init(): void
50 {
51 $this->delete_enabled = true;
52 $this->cut_enabled = true;
53 $this->copy_enabled = true;
54 $this->subscribe_enabled = true;
55 $this->link_enabled = true;
56 $this->info_screen_enabled = true;
57 $this->subitems_enabled = true;
58 $this->type = "sess";
59 $this->gui_class_name = "ilobjsessiongui";
60
61 $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
62 $this->enableSubstitutions($this->substitutions->isActive());
63
64 // general commands array
65 $this->commands = ilObjSessionAccess::_getCommands();
66 }
67
73 public function getTitle(): string
74 {
76 $title = strlen($this->title) ? (': ' . $this->title) : '';
78 $app_info['start'] ?? 0,
79 $app_info['end'] ?? 0,
80 (bool) ($app_info['fullday'] ?? false)
81 ) . $title;
82 }
83
84 public function getCommandLink($a_cmd): string
85 {
86 $ilCtrl = $this->ctrl;
87
88 // separate method for this line
89 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
90 $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $a_cmd);
91 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->requested_ref_id);
92 return $cmd_link;
93 }
94
98 public function checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id = null): bool
99 {
100 if ($a_cmd != 'register' && $a_cmd != 'unregister') {
101 $a_cmd = '';
102 }
103 return parent::checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id);
104 }
105
106 public function getProperties(): array
107 {
108 $app_info = $this->getAppointmentInfo();
109
110 $props = [];
111 $session_data = new ilObjSession($this->obj_id, false);
112 $part = ilSessionParticipants::getInstance($this->ref_id);
113
114 if ($session_data->isRegistrationUserLimitEnabled()) {
115 if ($part->getCountMembers() <= $session_data->getRegistrationMaxUsers()) {
116 $props[] = array(
117 'alert' => false,
118 'property' => $this->lng->txt('sess_list_reg_limit_places'),
119 'value' => max(
120 0,
121 $session_data->getRegistrationMaxUsers() - $part->getCountMembers()
122 )
123 );
124 }
125 }
126
128 if ($items = self::lookupAssignedMaterials($this->obj_id)) {
129 $props[] = array(
130 'alert' => false,
131 'property' => $this->lng->txt('event_ass_materials_prop'),
132 'value' => count($items)
133 );
134 }
135 }
137 $session_data = ilObjSession::lookupSession($this->obj_id);
138
139 if (strlen($session_data['location'])) {
140 $props[] = array(
141 'alert' => false,
142 'property' => $this->lng->txt('event_location'),
143 'value' => $session_data['location']
144 );
145 }
146 if (strlen($session_data['details'])) {
147 $props[] = array(
148 'alert' => false,
149 'property' => $this->lng->txt('event_details_workflow'),
150 'value' => nl2br($session_data['details']),
151 'newline' => true
152 );
153 }
154 $has_new_line = false;
155 if (strlen($session_data['name'])) {
156 $props[] = array(
157 'alert' => false,
158 'property' => $this->lng->txt('event_lecturer'),
159 'value' => $session_data['name'],
160 'newline' => true
161 );
162 $has_new_line = true;
163 }
164 if (strlen($session_data['email'])) {
165 $props[] = array(
166 'alert' => false,
167 'property' => $this->lng->txt('tutor_email'),
168 'value' => $session_data['email'],
169 'newline' => $has_new_line ? false : true
170 );
171 $has_new_line = true;
172 }
173 if (strlen($session_data['phone'])) {
174 $props[] = array(
175 'alert' => false,
176 'property' => $this->lng->txt('tutor_phone'),
177 'value' => $session_data['phone'],
178 'newline' => $has_new_line ? false : true
179 );
180 $has_new_line = true;
181 }
182 }
183
184 // booking information
186 if ($repo instanceof \ILIAS\BookingManager\Reservations\ReservationDBRepository) {
187 $book_info = new ilBookingInfoListItemPropertiesAdapter($repo);
188 $props = $book_info->appendProperties($this->obj_id, $props);
189 }
190 return $props;
191 }
192
193 protected function getAppointmentInfo(): array
194 {
195 if (isset($this->app_info[$this->obj_id])) {
196 return $this->app_info[$this->obj_id];
197 }
198 return $this->app_info[$this->obj_id] = ilSessionAppointment::_lookupAppointment($this->obj_id);
199 }
200
201 protected static function lookupAssignedMaterials(int $a_sess_id): array
202 {
203 global $DIC;
204
205 $ilDB = $DIC->database();
206
207 $query = 'SELECT * FROM event_items ei ' .
208 'JOIN tree ON item_id = child ' .
209 'WHERE event_id = ' . $ilDB->quote($a_sess_id, 'integer') . ' ' .
210 'AND tree > 0';
211 $res = $ilDB->query($query);
212 $items = [];
213 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
214 $items[] = $row->item_id;
215 }
216 return $items;
217 }
218}
static _getInstanceByObjectType(string $a_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
static _getCommands()
get commands
getProperties()
Get item properties.
getTitle()
get title Overwritten since sessions prepend the date of the session to the title
static lookupAssignedMaterials(int $a_sess_id)
checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id=null)
Only check cmd access for cmd 'register' and 'unregister'.
static lookupSession(int $a_obj_id)
enableSubstitutions(bool $status)
static _lookupAppointment(int $a_obj_id)
static _appointmentToString(int $start, int $end, bool $fulltime)
static getInstance(int $a_ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParameterByClass(string $a_class, string $a_parameter, $a_value)
Sets a parameter for the given GUI class and appends the given value as well.
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26