ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTrObjectUsersPropsTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
36{
37 protected array $user_fields;
38 protected int $in_course = 0;
39 protected int $in_group = 0;
40 protected int $in_course_ref_id = 0;
41 protected int $in_group_ref_id = 0;
42 protected bool $has_edit = false;
43 protected bool $has_collection = false;
44 protected bool $has_multi = false;
45
46 protected int $obj_id;
47 protected int $ref_id;
48 protected string $type;
49
50 protected ilTree $tree;
54
58 public function __construct(
59 ?object $a_parent_obj,
60 string $a_parent_cmd,
61 int $a_obj_id,
62 int $a_ref_id,
63 bool $a_print_view = false
64 ) {
65 global $DIC;
66
67 $this->tree = $DIC->repositoryTree();
68 $this->rbacsystem = $DIC->rbac()->system();
69 $this->ilObjDataCache = $DIC['ilObjDataCache'];
70 $this->objDefinition = $DIC['objDefinition'];
71
72 $this->setId("troup");
73 $this->obj_id = $a_obj_id;
74 $this->ref_id = $a_ref_id;
75 $this->type = ilObject::_lookupType($a_obj_id);
76
77 $this->in_group_ref_id = $this->tree->checkForParentType($this->ref_id, "grp");
78 if ($this->in_group_ref_id) {
79 $this->in_group = ilObject::_lookupObjId($this->in_group_ref_id);
80 } else {
81 $this->in_course_ref_id = $this->tree->checkForParentType(
82 $this->ref_id,
83 "crs"
84 );
85 if ($this->in_course_ref_id) {
86 $this->in_course = ilObject::_lookupObjId($this->in_course_ref_id);
87 }
88 }
89 parent::__construct($a_parent_obj, $a_parent_cmd);
90 $this->parseTitle($a_obj_id, "trac_participants");
91
92 if ($a_print_view) {
93 $this->setPrintMode(true);
94 }
95
96 if (!$this->getPrintMode()) {
97 // see ilObjCourseGUI::addMailToMemberButton()
98 $mail = new ilMail($DIC->user()->getId());
99 if ($this->rbacsystem->checkAccess(
100 "internal_mail",
101 $mail->getMailObjectReferenceId()
102 )) {
103 $this->addMultiCommand(
104 "mailselectedusers",
105 $this->lng->txt("send_mail")
106 );
107 }
108 $this->lng->loadLanguageModule('user');
109 $this->addMultiCommand(
110 'addToClipboard',
111 $this->lng->txt('clipboard_add_btn')
112 );
113 $this->addColumn("", "", 1);
114 $this->has_multi = true;
115 }
116
117 $labels = $this->getSelectableColumns();
118 $first = false;
119 foreach ($this->getSelectedColumns() as $c) {
120 $first = $c;
121
122 // list cannot be sorted by udf fields (separate query)
123 // because of pagination only core fields can be sorted
124 $sort_id = (substr($c, 0, 4) == "udf_") ? "" : $c;
125
126 $this->addColumn($labels[$c]["txt"], $sort_id);
127 }
128
129 if (!$this->getPrintMode()) {
130 $this->addColumn($this->lng->txt("actions"), "");
131 }
132 $this->setSelectAllCheckbox('uid');
133 $this->setExternalSorting(true);
134 $this->setExternalSegmentation(true);
135 $this->setEnableHeader(true);
136 $this->setFormAction(
137 $this->ctrl->getFormActionByClass(get_class($this))
138 );
139 $this->setRowTemplate(
140 "tpl.object_users_props_row.html",
141 "components/ILIAS/Tracking"
142 );
143 $this->setEnableTitle(true);
144 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
145
146 if ($first) {
147 $this->setDefaultOrderField($first);
148 $this->setDefaultOrderDirection("asc");
149 }
150
151 $this->initFilter();
152
153 $this->getItems();
154
155 // #13807
157 'edit_learning_progress',
158 $this->ref_id
159 );
160 }
161
162 public function getSelectableColumns(): array
163 {
164 if ($this->selectable_columns) {
166 }
167
168 $cols = $this->getSelectableUserColumns(
169 $this->in_course_ref_id,
170 $this->in_group_ref_id
171 );
172 $this->user_fields = $cols[1];
173 $this->selectable_columns = $cols[0];
174
176 }
177
181 public function getItems(): void
182 {
184 $additional_fields = $this->getSelectedColumns();
185
186 // only if object is [part of] course/group
187 $check_agreement = null;
188 if ($this->in_course) {
189 // privacy (if course agreement is activated)
191 if ($privacy->courseConfirmationRequired()) {
192 $check_agreement = $this->in_course;
193 }
194 } elseif ($this->in_group) {
195 // privacy (if group agreement is activated)
197 if ($privacy->groupConfirmationRequired()) {
198 $check_agreement = $this->in_group;
199 }
200 }
202 $this->ref_id,
207 $this->getCurrentFilter(),
208 $additional_fields,
209 $check_agreement,
210 $this->user_fields
211 );
212 if (count($tr_data["set"]) == 0 && $this->getOffset() > 0) {
213 $this->resetOffset();
215 $this->ref_id,
220 $this->getCurrentFilter(),
221 $additional_fields,
222 $check_agreement,
223 $this->user_fields
224 );
225 }
226
227 /*
228 * ilTrQuery does not read out any information about org units
229 * (nor should it), so it needs to be added here.
230 */
231 if (in_array('org_units', $additional_fields)) {
232 foreach (($tr_data['set'] ?? []) as $key => $data) {
233 if (!isset($data['usr_id'])) {
234 continue;
235 }
236 $usr_id = (int) $data['usr_id'];
237 $org_units = ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($usr_id);
238 $tr_data["set"][$key]['org_units'] = $org_units;
239 }
240 }
241
242 $this->setMaxCount($tr_data["cnt"]);
243 $this->setData($tr_data["set"]);
244 }
245
246 public function initFilter(): void
247 {
248 foreach ($this->getSelectableColumns() as $column => $meta) {
249 // no udf!
250 switch ($column) {
251 case "firstname":
252 case "lastname":
253 case "mark":
254 case "u_comment":
255 case "institution":
256 case "department":
257 case "title":
258 case "street":
259 case "zipcode":
260 case "city":
261 case "country":
262 case "email":
263 case "matriculation":
264 case "login":
265 if ($column != "mark" ||
266 ilObjectLP::supportsMark($this->type)) {
267 $item = $this->addFilterItemByMetaType(
268 $column,
270 true,
271 $meta["txt"]
272 );
273 $this->filter[$column] = $item->getValue();
274 }
275 break;
276
277 case "first_access":
278 case "last_access":
279 case "create_date":
280 case 'status_changed':
281 $item = $this->addFilterItemByMetaType(
282 $column,
284 true,
285 $meta["txt"]
286 );
287 $this->filter[$column] = $item->getDate();
288 break;
289
290 case "birthday":
291 $item = $this->addFilterItemByMetaType(
292 $column,
294 true,
295 $meta["txt"]
296 );
297 $this->filter[$column] = $item->getDate();
298 break;
299
300 case "read_count":
301 case "percentage":
302 $item = $this->addFilterItemByMetaType(
303 $column,
305 true,
306 $meta["txt"]
307 );
308 $this->filter[$column] = $item->getValue();
309 break;
310
311 case "gender":
312 $item = $this->addFilterItemByMetaType(
313 "gender",
315 true,
316 $meta["txt"]
317 );
318 $item->setOptions(
319 array(
320 "" => $this->lng->txt("trac_all"),
321 "n" => $this->lng->txt("gender_n"),
322 "m" => $this->lng->txt("gender_m"),
323 "f" => $this->lng->txt("gender_f"),
324 )
325 );
326 $this->filter["gender"] = $item->getValue();
327 break;
328
329 case "sel_country":
330 $item = $this->addFilterItemByMetaType(
331 "sel_country",
333 true,
334 $meta["txt"]
335 );
336
337 $options = array();
338 foreach (ilCountry::getCountryCodes() as $c) {
339 $options[$c] = $this->lng->txt("meta_c_" . $c);
340 }
341 asort($options);
342 $item->setOptions(
343 array("" => $this->lng->txt("trac_all")) + $options
344 );
345
346 $this->filter["sel_country"] = $item->getValue();
347 break;
348
349 case "status":
350 $item = $this->addFilterItemByMetaType(
351 "status",
353 true,
354 $meta["txt"]
355 );
356 $item->setOptions(
357 array("" => $this->lng->txt("trac_all"),
358 ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM + 1 => $this->lng->txt(
360 ),
361 ilLPStatus::LP_STATUS_IN_PROGRESS_NUM + 1 => $this->lng->txt(
363 ),
364 ilLPStatus::LP_STATUS_COMPLETED_NUM + 1 => $this->lng->txt(
366 ),
367 ilLPStatus::LP_STATUS_FAILED_NUM + 1 => $this->lng->txt(
369 )
370 )
371 );
372 $this->filter["status"] = $item->getValue();
373 if (is_numeric($this->filter["status"])) {
374 $this->filter["status"]--;
375 }
376 break;
377
378 case "language":
379 $item = $this->addFilterItemByMetaType(
380 "language",
382 true
383 );
384 $this->filter["language"] = $item->getValue();
385 break;
386
387 case "spent_seconds":
388 if (ilObjectLP::supportsSpentSeconds($this->type)) {
389 $item = $this->addFilterItemByMetaType(
390 "spent_seconds",
392 true,
393 $meta["txt"]
394 );
395 $this->filter["spent_seconds"]["from"] = $item->getCombinationItem(
396 "from"
397 )->getValueInSeconds();
398 $this->filter["spent_seconds"]["to"] = $item->getCombinationItem(
399 "to"
400 )->getValueInSeconds();
401 }
402 break;
403 }
404 }
405 }
406
407 protected function fillRow(array $a_set): void
408 {
409 if ($this->has_multi) {
410 $this->tpl->setVariable("USER_ID", $a_set["usr_id"]);
411 }
412
413 foreach ($this->getSelectedColumns() as $c) {
414 if (!(bool) ($a_set["privacy_conflict"] ?? null)) {
415 if ($c == 'status' && $a_set[$c] != ilLPStatus::LP_STATUS_COMPLETED_NUM) {
416 $timing = $this->showTimingsWarning(
417 $this->ref_id,
418 $a_set["usr_id"]
419 );
420 if ($timing) {
421 if ($timing !== true) {
422 $timing = ": " . ilDatePresentation::formatDate(
423 new ilDate($timing, IL_CAL_UNIX)
424 );
425 } else {
426 $timing = "";
427 }
428 $this->tpl->setCurrentBlock('warning_img');
429 $this->tpl->setVariable(
430 'WARNING_IMG',
432 'media/time_warn.svg'
433 )
434 );
435 $this->tpl->setVariable(
436 'WARNING_ALT',
437 $this->lng->txt(
438 'trac_time_passed'
439 ) . $timing
440 );
441 $this->tpl->parseCurrentBlock();
442 }
443 }
444
445 // #7694
446 if ($c == 'login' && !$a_set["active"]) {
447 $this->tpl->setCurrentBlock('inactive_bl');
448 $this->tpl->setVariable(
449 'TXT_INACTIVE',
450 $this->lng->txt("inactive")
451 );
452 $this->tpl->parseCurrentBlock();
453 }
454
455 $val = $this->parseValue($c, $a_set[$c] ?? '', $this->type);
456 } else {
457 if ($c == 'login') {
458 $this->tpl->setCurrentBlock('inactive_bl');
459 $this->tpl->setVariable(
460 'TXT_INACTIVE',
461 $this->lng->txt(
462 "status_no_permission"
463 )
464 );
465 $this->tpl->parseCurrentBlock();
466 }
467
468 $val = "&nbsp;";
469 }
470
471 $this->tpl->setCurrentBlock("user_field");
472 $this->tpl->setVariable("VAL_UF", $val);
473 $this->tpl->parseCurrentBlock();
474 }
475
476 $this->ctrl->setParameterByClass(
477 "illplistofobjectsgui",
478 "user_id",
479 $a_set["usr_id"]
480 );
481
482 if (!$this->getPrintMode() && !(bool) ($a_set["privacy_conflict"] ?? null)) {
483 // details for containers and collections
484 if ($this->has_collection ||
485 $this->objDefinition->isContainer($this->type)) {
486 $this->tpl->setCurrentBlock("item_command");
487 $this->tpl->setVariable(
488 "HREF_COMMAND",
489 $this->ctrl->getLinkTargetByClass(
490 "illplistofobjectsgui",
491 "userdetails"
492 )
493 );
494 $this->tpl->setVariable(
495 "TXT_COMMAND",
496 $this->lng->txt('details')
497 );
498 $this->tpl->parseCurrentBlock();
499 }
500
501 if ($this->has_edit) {
502 $this->tpl->setCurrentBlock("item_command");
503 $this->tpl->setVariable(
504 "HREF_COMMAND",
505 $this->ctrl->getLinkTargetByClass(
506 "illplistofobjectsgui",
507 "edituser"
508 )
509 );
510 $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('edit'));
511 $this->tpl->parseCurrentBlock();
512 }
513 }
514
515 $this->ctrl->setParameterByClass("illplistofobjectsgui", 'user_id', '');
516 }
517
518 protected function fillHeaderExcel(ilExcel $a_excel, int &$a_row): void
519 {
520 $labels = $this->getSelectableColumns();
521 $cnt = 0;
522 foreach ($this->getSelectedColumns() as $c) {
523 $a_excel->setCell($a_row, $cnt++, $labels[$c]["txt"]);
524 }
525
526 $a_excel->setBold(
527 "A" . $a_row . ":" . $a_excel->getColumnCoord($cnt - 1) . $a_row
528 );
529 }
530
531 protected function fillRowExcel(
532 ilExcel $a_excel,
533 int &$a_row,
534 array $a_set
535 ): void {
536 $cnt = 0;
537 foreach ($this->getSelectedColumns() as $c) {
538 if ($c !== 'status') {
539 $val = $this->parseValue($c, $a_set[$c] ?? null, $this->type);
540 } else {
542 (int) $a_set[$c]
543 );
544 }
545 $a_excel->setCell($a_row, $cnt++, $val);
546 }
547 }
548
549 protected function fillHeaderCSV(ilCSVWriter $a_csv): void
550 {
551 $labels = $this->getSelectableColumns();
552 foreach ($this->getSelectedColumns() as $c) {
553 $a_csv->addColumn($labels[$c]["txt"]);
554 }
555
556 $a_csv->addRow();
557 }
558
559 protected function fillRowCSV(ilCSVWriter $a_csv, array $a_set): void
560 {
561 foreach ($this->getSelectedColumns() as $c) {
562 if ($c !== 'status') {
563 $val = $this->parseValue($c, $a_set[$c] ?? null, $this->type);
564 } else {
566 (int) $a_set[$c]
567 );
568 }
569 $a_csv->addColumn($val);
570 }
571
572 $a_csv->addRow();
573 }
574}
const IL_CAL_UNIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addColumn(string $a_col)
static getCountryCodes()
Get country codes (DIN EN 3166-1)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Class for single dates.
setBold(string $a_coords)
Set cell(s) to bold.
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
getColumnCoord(int $a_col)
Get column "name" from number.
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_COMPLETED
const LP_STATUS_FAILED
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
TableGUI class for learning progress.
showTimingsWarning(int $a_ref_id, int $a_user_id)
getCurrentFilter(bool $as_query=false)
parseValue(string $id, ?string $value, string $type)
parseTitle(int $a_obj_id, string $action, int $a_user_id=0)
getSelectableUserColumns(int $a_in_course=0, int $a_in_group=0)
static checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
static _getStatusText(int $a_status, ?ilLanguage $a_lng=null)
Get status alt text.
class ilObjectDataCache
parses the objects.xml it handles the xml-description of all ilias objects
static supportsSpentSeconds(string $obj_type)
static supportsMark(string $obj_type)
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
determineOffsetAndOrder(bool $a_omit_offset=false)
setExportFormats(array $formats)
Set available export formats.
setExternalSegmentation(bool $a_val)
setEnableTitle(bool $a_enabletitle)
addMultiCommand(string $a_cmd, string $a_text)
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setFormAction(string $a_form_action, bool $a_multipart=false)
resetOffset(bool $a_in_determination=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)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setPrintMode(bool $a_value=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setExternalSorting(bool $a_val)
array $selectable_columns
const FILTER_DURATION_RANGE
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.
const FILTER_NUMBER_RANGE
const FILTER_DATETIME_RANGE
setMaxCount(int $a_max_count)
set max.
Learning progress table: One object, rows: users, columns: properties Example: A course,...
fillRow(array $a_set)
Standard Version of Fill Row.
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
CSV Version of Fill Row.
fillHeaderExcel(ilExcel $a_excel, int &$a_row)
Excel Version of Fill Header.
__construct(?object $a_parent_obj, string $a_parent_cmd, int $a_obj_id, int $a_ref_id, bool $a_print_view=false)
Constructor.
fillHeaderCSV(ilCSVWriter $a_csv)
CSV Version of Fill Header.
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
Excel Version of Fill Row.
static getUserDataForObject(int $a_ref_id, string $a_order_field="", string $a_order_dir="", int $a_offset=0, int $a_limit=9999, ?array $a_filters=null, ?array $a_additional_fields=null, ?int $check_agreement=null, ?array $privacy_fields=null)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
$c
Definition: deliver.php:25
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $DIC
Definition: shib_login.php:26