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