ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilGroupParticipantsTableGUI.php
Go to the documentation of this file.
1<?php
2
19include_once './Services/Membership/classes/class.ilParticipantsTableGUI.php';
20include_once './Services/Tracking/classes/class.ilLPStatus.php';
21
30{
31 protected $show_learning_progress = false;
32
33 protected $current_filter = array();
34
35 protected $cached_user_names = [];
36
44 public function __construct(
45 $a_parent_obj,
48 ) {
49 global $DIC;
50
51 $lng = $DIC['lng'];
52 $ilCtrl = $DIC['ilCtrl'];
53
54 $this->show_learning_progress = $show_learning_progress;
55
56 $this->lng = $lng;
57 $this->lng->loadLanguageModule('grp');
58 $this->lng->loadLanguageModule('trac');
59 $this->lng->loadLanguageModule('rbac');
60 $this->lng->loadLanguageModule('mmbr');
61
62 $this->ctrl = $ilCtrl;
63
64 $this->rep_object = $rep_object;
65
66 include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
67 $this->privacy = ilPrivacySettings::_getInstance();
68
69 include_once './Services/Membership/classes/class.ilParticipants.php';
70 $this->participants = ilParticipants::getInstanceByObjId($this->getRepositoryObject()->getId());
71
72
73 $this->setPrefix('participants');
74
75 $this->setId('grp_' . $this->getRepositoryObject()->getId());
76 parent::__construct($a_parent_obj, 'participants');
77
78 $this->initSettings();
79
80 $this->setFormName('participants');
81
82 $this->addColumn('', 'f', "1", true);
83 $this->addColumn($this->lng->txt('name'), 'lastname', '20%');
84
85 $all_cols = $this->getSelectableColumns();
86 foreach ($this->getSelectedColumns() as $col) {
87 $this->addColumn($all_cols[$col]['txt'], $col);
88 }
89
90 if ($this->show_learning_progress) {
91 $this->addColumn($this->lng->txt('learning_progress'), 'progress');
92 }
93
94 if ($this->privacy->enabledGroupAccessTimes()) {
95 $this->addColumn($this->lng->txt('last_access'), 'access_time_unix');
96 }
97 $this->addColumn($this->lng->txt('grp_mem_contacts'), 'contact');
98 $this->addColumn($this->lng->txt('grp_notification'), 'notification');
99
100 $this->addColumn($this->lng->txt('actions'), 'optional', '', false, 'ilMembershipRowActionsHeader');
101 $this->setDefaultOrderField('roles');
102
103 $this->setRowTemplate("tpl.show_participants_row.html", "Modules/Group");
104
105 $this->setShowRowsSelector(true);
106
107 $this->enable('sort');
108 $this->enable('header');
109 $this->enable('numinfo');
110 $this->enable('select_all');
111
112 $this->initFilter();
113
114 $this->addMultiCommand('editParticipants', $this->lng->txt('edit'));
115 $this->addMultiCommand('confirmDeleteParticipants', $this->lng->txt('remove'));
116 $this->addMultiCommand('sendMailToSelectedUsers', $this->lng->txt('mmbr_btn_mail_selected_users'));
117 $this->lng->loadLanguageModule('user');
118 $this->addMultiCommand('addToClipboard', $this->lng->txt('clipboard_add_btn'));
119
120 $this->setSelectAllCheckbox('participants', true);
121 $this->addCommandButton('updateParticipantsStatus', $this->lng->txt('save'));
122 }
123
131 public function fillRow($a_set)
132 {
133 global $DIC;
134
135 $ilUser = $DIC['ilUser'];
136 $ilAccess = $DIC['ilAccess'];
137
138 $this->tpl->setVariable('VAL_ID', $a_set['usr_id']);
139 $this->tpl->setVariable('VAL_NAME', $a_set['lastname'] . ', ' . $a_set['firstname']);
140 if (!$ilAccess->checkAccessOfUser($a_set['usr_id'], 'read', '', $this->getRepositoryObject()->getRefId()) and
141 is_array($info = $ilAccess->getInfo())) {
142 $this->tpl->setCurrentBlock('access_warning');
143 $this->tpl->setVariable('PARENT_ACCESS', $info[0]['text']);
144 $this->tpl->parseCurrentBlock();
145 }
146
147 if (!$a_set['active']) {
148 $this->tpl->setCurrentBlock('access_warning');
149 $this->tpl->setVariable('PARENT_ACCESS', $this->lng->txt('usr_account_inactive'));
150 $this->tpl->parseCurrentBlock();
151 }
152
153
154 foreach ($this->getSelectedColumns() as $field) {
155 switch ($field) {
156 case 'gender':
157 $a_set['gender'] = $a_set['gender'] ? $this->lng->txt('gender_' . $a_set['gender']) : '';
158 $this->tpl->setCurrentBlock('custom_fields');
159 $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
160 $this->tpl->parseCurrentBlock();
161 break;
162
163 case 'birthday':
164 $a_set['birthday'] = $a_set['birthday'] ? ilDatePresentation::formatDate(new ilDate($a_set['birthday'], IL_CAL_DATE)) : $this->lng->txt('no_date');
165 $this->tpl->setCurrentBlock('custom_fields');
166 $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
167 $this->tpl->parseCurrentBlock();
168 break;
169
170 case 'consultation_hour':
171 $this->tpl->setCurrentBlock('custom_fields');
172 $dts = array();
173 foreach ((array) $a_set['consultation_hours'] as $ch) {
175 new ilDateTime($ch['dt'], IL_CAL_UNIX),
176 new ilDateTime($ch['dtend'], IL_CAL_UNIX)
177 );
178 if ($ch['explanation']) {
179 $tmp .= ' ' . $ch['explanation'];
180 }
181 $dts[] = $tmp;
182 }
183 $dt_string = implode('<br />', $dts);
184 $this->tpl->setVariable('VAL_CUST', $dt_string) ;
185 $this->tpl->parseCurrentBlock();
186 break;
187
188 case 'prtf':
189 $tmp = array();
190 if (is_array($a_set['prtf'])) {
191 foreach ($a_set['prtf'] as $prtf_url => $prtf_txt) {
192 $tmp[] = '<a href="' . $prtf_url . '">' . $prtf_txt . '</a>';
193 }
194 }
195 $this->tpl->setCurrentBlock('custom_fields');
196 $this->tpl->setVariable('VAL_CUST', (string) implode('<br />', $tmp)) ;
197 $this->tpl->parseCurrentBlock();
198 break;
199
200 case 'odf_last_update':
201 $this->tpl->setCurrentBlock('custom_fields');
202 $this->tpl->setVariable('VAL_CUST', (string) $a_set['odf_info_txt']);
203 $this->tpl->parseCurrentBlock();
204 break;
205
206 case 'roles':
207 $this->tpl->setCurrentBlock('custom_fields');
208 $this->tpl->setVariable('VAL_CUST', (string) $a_set['roles_label']);
209 $this->tpl->parseCurrentBlock();
210 break;
211
212 case 'org_units':
213 $this->tpl->setCurrentBlock('custom_fields');
214 include_once './Modules/OrgUnit/classes/PathStorage/class.ilOrgUnitPathStorage.php';
215 $this->tpl->setVariable('VAL_CUST', (string) ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($a_set['usr_id']));
216 $this->tpl->parseCurrentBlock();
217 break;
218
219 default:
220 $this->tpl->setCurrentBlock('custom_fields');
221 $this->tpl->setVariable('VAL_CUST', isset($a_set[$field]) ? (string) $a_set[$field] : '');
222 $this->tpl->parseCurrentBlock();
223 break;
224 }
225 }
226
227 if ($this->privacy->enabledGroupAccessTimes()) {
228 $this->tpl->setVariable('VAL_ACCESS', $a_set['access_time']);
229 }
230
231 if ($this->show_learning_progress) {
232 $this->tpl->setCurrentBlock('lp');
234 $icon_rendered = $icons->renderIconForStatus($icons->lookupNumStatus($a_set['progress']));
235
236 $this->tpl->setVariable('LP_STATUS_ALT', $this->lng->txt($a_set['progress']));
237 $this->tpl->setVariable('LP_STATUS_ICON', $icon_rendered);
238
239 $this->tpl->parseCurrentBlock();
240 }
241
242 $this->tpl->setVariable('VAL_POSTNAME', 'participants');
243
244 if ($this->getParticipants()->isAdmin($a_set['usr_id'])) {
245 $this->tpl->setVariable('VAL_CONTACT_ID', $a_set['usr_id']);
246 $this->tpl->setVariable(
247 'VAL_CONTACT_CHECKED',
248 $a_set['contact'] ? 'checked="checked"' : ''
249 );
250 }
251
252 if (
253 $this->getParticipants()->isAdmin($a_set['usr_id'])
254 ) {
255 $this->tpl->setVariable('VAL_NOTIFICATION_ID', $a_set['usr_id']);
256 $this->tpl->setVariable(
257 'VAL_NOTIFICATION_CHECKED',
258 $a_set['notification'] ? 'checked="checked"' : ''
259 );
260 }
261
262 $this->showActionLinks($a_set);
263
264
265 $this->tpl->setVariable('VAL_LOGIN', $a_set['login']);
266 }
267
273 public function parse()
274 {
275 $this->determineOffsetAndOrder(true);
276
277 $part = ilGroupParticipants::_getInstanceByObjId($this->getRepositoryObject()->getId())->getParticipants();
278
279 $part = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
280 'manage_members',
281 'manage_members',
282 $this->getRepositoryObject()->getRefId(),
283 $part
284 );
285
286 if (!$part) {
287 $this->setData(array());
288 return;
289 }
290
291
292 $group_user_data = (array) $this->getParentObject()->readMemberData(
293 $part,
294 $this->getSelectedColumns()
295 );
296
297 include_once './Services/User/classes/class.ilUserQuery.php';
298
299 $additional_fields = $this->getSelectedColumns();
300 unset($additional_fields["firstname"]);
301 unset($additional_fields["lastname"]);
302 unset($additional_fields["last_login"]);
303 unset($additional_fields["access_until"]);
304 unset($additional_fields['consultation_hour']);
305 unset($additional_fields['prtf']);
306 unset($additional_fields['roles']);
307 unset($additional_fields['org_units']);
308
309
310
311 $udf_ids = $usr_data_fields = $odf_ids = array();
312 foreach ($additional_fields as $field) {
313 if (substr($field, 0, 3) == 'udf') {
314 $udf_ids[] = substr($field, 4);
315 continue;
316 }
317 if (substr($field, 0, 3) == 'odf') {
318 $odf_ids[] = substr($field, 4);
319 continue;
320 }
321
322 $usr_data_fields[] = $field;
323 }
324
326 '',
327 '',
328 0,
329 9999,
330 $this->current_filter['login'],
331 '',
332 null,
333 false,
334 false,
335 0,
336 0,
337 null,
338 $usr_data_fields,
339 $part
340 );
341
342 $a_user_data = array();
343 $filtered_user_ids = array();
344 $local_roles = $this->getParentObject()->getLocalRoles();
345 foreach ((array) $usr_data['set'] as $ud) {
346 $user_id = $ud['usr_id'];
347 if ($this->current_filter['roles']) {
348 if (!$GLOBALS['DIC']['rbacreview']->isAssigned($user_id, $this->current_filter['roles'])) {
349 continue;
350 }
351 }
352 if ($this->current_filter['org_units']) {
353 $org_unit = $this->current_filter['org_units'];
354 include_once './Modules/OrgUnit/classes/class.ilObjOrgUnitTree.php';
355 $assigned = ilObjOrgUnitTree::_getInstance()->getOrgUnitOfUser($user_id);
356 if (!in_array($org_unit, $assigned)) {
357 continue;
358 }
359 }
360
361 $filtered_user_ids[] = $user_id;
362 $a_user_data[$user_id] = array_merge($ud, (array) $group_user_data[$user_id]);
363
364 $roles = array();
365 foreach ($local_roles as $role_id => $role_name) {
366 // @todo fix performance
367 if ($GLOBALS['DIC']['rbacreview']->isAssigned($user_id, $role_id)) {
368 $roles[] = $role_name;
369 }
370 }
371 $a_user_data[$user_id]['name'] = $a_user_data[$user_id]['lastname'] . ', ' . $a_user_data[$user_id]['firstname'];
372 $a_user_data[$user_id]['roles_label'] = implode('<br />', $roles);
373 $a_user_data[$user_id]['roles'] = $this->participants->setRoleOrderPosition($user_id);
374 }
375
376 // Custom user data fields
377 if ($udf_ids) {
378 include_once './Services/User/classes/class.ilUserDefinedData.php';
379 $data = ilUserDefinedData::lookupData($filtered_user_ids, $udf_ids);
380 foreach ($data as $usr_id => $fields) {
381 if (!$this->checkAcceptance($usr_id)) {
382 continue;
383 }
384
385 foreach ($fields as $field_id => $value) {
386 $a_user_data[$usr_id]['udf_' . $field_id] = $value;
387 }
388 }
389 }
390 // Object specific user data fields
391 if ($odf_ids) {
392 include_once './Modules/Course/classes/Export/class.ilCourseUserData.php';
394 foreach ($data as $usr_id => $fields) {
395 if (!$this->checkAcceptance($usr_id)) {
396 continue;
397 }
398
399 foreach ($fields as $field_id => $value) {
400 if ($a_user_data[$usr_id]) {
401 $a_user_data[$usr_id]['odf_' . $field_id] = $value;
402 }
403 }
404 }
405 // add last edit date
406 include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
407 foreach (ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getRepositoryObject()->getId()) as $usr_id => $edit_info) {
408 if (!isset($a_user_data[$usr_id])) {
409 continue;
410 }
411
412 include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
413 if ($usr_id == $edit_info['update_user']) {
414 $a_user_data[$usr_id]['odf_last_update'] = '';
415 $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['DIC']['lng']->txt('cdf_edited_by_self');
416 if (ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getRepositoryObject()->getType())) {
417 $a_user_data[$usr_id]['odf_last_update'] .= ('_' . $edit_info['editing_time']->get(IL_CAL_UNIX));
418 $a_user_data[$usr_id]['odf_info_txt'] .= (', ' . ilDatePresentation::formatDate($edit_info['editing_time']));
419 }
420 } else {
421 $a_user_data[$usr_id]['odf_last_update'] = $edit_info['edit_user'];
422 $a_user_data[$usr_id]['odf_last_update'] .= ('_' . $edit_info['editing_time']->get(IL_CAL_UNIX));
423
424 $name = $this->lookupUserName((int) $edit_info['update_user']);
425 $a_user_data[$usr_id]['odf_info_txt'] = ($name['firstname'] . ' ' . $name['lastname'] . ', ' . ilDatePresentation::formatDate($edit_info['editing_time']));
426 }
427 }
428 }
429
430 // consultation hours
431 if ($this->isColumnSelected('consultation_hour')) {
432 include_once './Services/Booking/classes/class.ilBookingEntry.php';
433 foreach (ilBookingEntry::lookupManagedBookingsForObject($this->getRepositoryObject()->getId(), $GLOBALS['DIC']['ilUser']->getId()) as $buser => $booking) {
434 if (isset($a_user_data[$buser])) {
435 $a_user_data[$buser]['consultation_hour'] = $booking[0]['dt'];
436 $a_user_data[$buser]['consultation_hour_end'] = $booking[0]['dtend'];
437 $a_user_data[$buser]['consultation_hours'] = $booking;
438 }
439 }
440 }
441
442 // always sort by name first
443 $a_user_data = ilUtil::sortArray(
444 $a_user_data,
445 'name',
446 $this->getOrderDirection()
447 );
448
449 return $this->setData($a_user_data);
450 }
451
455 protected function lookupUserName(int $user_id) : array
456 {
457 if (isset($this->cached_user_names[$user_id])) {
458 return $this->cached_user_names[$user_id];
459 }
460 return $this->cached_user_names[$user_id] = ilObjUser::_lookupName($user_id);
461 }
462}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const IL_CAL_UNIX
static lookupManagedBookingsForObject($a_obj_id, $a_usr_id)
Lookup bookings for own and managed consultation hours of an object.
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
@classDescription Date and time handling
Class for single dates.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct( $a_parent_obj, ilObject $rep_object, $show_learning_progress=false)
Constructor.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
static _lookupName($a_user_id)
lookup user name
static lookupEntriesByObjectId($a_obj_id)
Get entries by obj_id @global type $ilDB.
Class ilObject Basic functions for all objects.
getSelectableColumns()
Get selectable columns.
showActionLinks($a_set)
show edit links
checkAcceptance($a_usr_id)
Check acceptance.
static getInstanceByObjId($a_obj_id)
Get instance by obj type.
static _getInstance()
Get instance of ilPrivacySettings.
getSelectedColumns()
Get selected columns.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
getParentObject()
Get parent object.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
getId()
Get element id.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
isColumnSelected($a_col)
Is given column selected?
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
getOrderDirection()
Get order direction.
enable($a_module_name)
enables particular modules of table
static lookupData($a_user_ids, $a_field_ids)
Lookup data.
static getUserListData( $a_order_field, $a_order_dir, $a_offset, $a_limit, $a_string_filter="", $a_activation_filter="", $a_last_login_filter=null, $a_limited_access_filter=false, $a_no_courses_filter=false, $a_course_group_filter=0, $a_role_filter=0, $a_user_folder_filter=null, $a_additional_fields='', $a_user_filter=null, $a_first_letter="", $a_authentication_filter=null)
Get data for user administration list.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
if($format !==null) $name
Definition: metadata.php:230
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc