Skip to content

Commit

Permalink
Tracking: streamline user fields handling in some tables (31900)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmitz-ilias committed Jun 24, 2024
1 parent 834a271 commit 27a55df
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 22 deletions.
8 changes: 5 additions & 3 deletions Services/Tracking/classes/class.ilLPTableBaseGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=0);

use ILIAS\Refinery\Factory as RefineryFactory;
use ILIAS\HTTP\Services as HttpService;

Expand Down Expand Up @@ -1132,19 +1134,19 @@ protected function getSelectableUserColumns(
($a_in_course || $a_in_group)) {
// only show if export permission is granted
if (ilPrivacySettings::getInstance()->checkExportAccess(
$this->ref_id
$a_in_group === 0 ? $a_in_course : $a_in_group
)) {
// other user profile fields
foreach ($ufs as $f => $fd) {
if (!isset($cols[$f]) && $f != "username" && !($fd["lists_hide"] ?? false)) {
if ($a_in_course &&
!(!($fd["course_export_fix_value"] ?? false) || $this->setting->get(
!(($fd["course_export_fix_value"] ?? false) || $this->setting->get(
"usr_settings_course_export_" . $f
))) {
continue;
}
if ($a_in_group &&
!(!($fd["group_export_fix_value"] ?? false) || $this->setting->get(
!(($fd["group_export_fix_value"] ?? false) || $this->setting->get(
"usr_settings_group_export_" . $f
))) {
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

declare(strict_types=0);
/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
Expand All @@ -17,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=0);

/**
* name table
* @author Jörg Lützenkirchen <[email protected]>
Expand All @@ -35,6 +36,8 @@ class ilTrMatrixTableGUI extends ilLPTableBaseGUI
protected array $subitem_ids = [];
protected int $in_course = 0;
protected int $in_group = 0;
protected int $in_course_ref_id = 0;
protected int $in_group_ref_id = 0;
protected array $privacy_fields = [];
protected array $privacy_cols = [];
protected array $perc_map = [];
Expand Down Expand Up @@ -63,16 +66,16 @@ public function __construct(
$this->obj_id = ilObject::_lookupObjId($ref_id);
$this->type = ilObject::_lookupType($this->obj_id); // #17188

$this->in_group = $this->tree->checkForParentType($this->ref_id, "grp");
if ($this->in_group) {
$this->in_group = ilObject::_lookupObjId($this->in_group);
$this->in_group_ref_id = $this->tree->checkForParentType($this->ref_id, "grp");
if ($this->in_group_ref_id) {
$this->in_group = ilObject::_lookupObjId($this->in_group_ref_id);
} else {
$this->in_course = $this->tree->checkForParentType(
$this->in_course_ref_id = $this->tree->checkForParentType(
$this->ref_id,
"crs"
);
if ($this->in_course) {
$this->in_course = ilObject::_lookupObjId($this->in_course);
if ($this->in_course_ref_id) {
$this->in_course = ilObject::_lookupObjId($this->in_course_ref_id);
}
}

Expand Down Expand Up @@ -188,8 +191,8 @@ public function numericOrdering($a_field): bool
public function getSelectableColumns(): array
{
$user_cols = $this->getSelectableUserColumns(
$this->in_course,
$this->in_group
$this->in_course_ref_id,
$this->in_group_ref_id
);
$columns = [];
if ($this->obj_ids === null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
<?php

/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=0);

/**
* Learning progress table: One object, rows: users, columns: properties
Expand All @@ -21,6 +37,8 @@ class ilTrObjectUsersPropsTableGUI extends ilLPTableBaseGUI
protected array $user_fields;
protected int $in_course = 0;
protected int $in_group = 0;
protected int $in_course_ref_id = 0;
protected int $in_group_ref_id = 0;
protected bool $has_edit = false;
protected bool $has_collection = false;
protected bool $has_multi = false;
Expand Down Expand Up @@ -56,16 +74,16 @@ public function __construct(
$this->ref_id = $a_ref_id;
$this->type = ilObject::_lookupType($a_obj_id);

$this->in_group = $this->tree->checkForParentType($this->ref_id, "grp");
if ($this->in_group) {
$this->in_group = ilObject::_lookupObjId($this->in_group);
$this->in_group_ref_id = $this->tree->checkForParentType($this->ref_id, "grp");
if ($this->in_group_ref_id) {
$this->in_group = ilObject::_lookupObjId($this->in_group_ref_id);
} else {
$this->in_course = $this->tree->checkForParentType(
$this->in_course_ref_id = $this->tree->checkForParentType(
$this->ref_id,
"crs"
);
if ($this->in_course) {
$this->in_course = ilObject::_lookupObjId($this->in_course);
if ($this->in_course_ref_id) {
$this->in_course = ilObject::_lookupObjId($this->in_course_ref_id);
}
}
parent::__construct($a_parent_obj, $a_parent_cmd);
Expand Down Expand Up @@ -149,8 +167,8 @@ public function getSelectableColumns(): array
}

$cols = $this->getSelectableUserColumns(
$this->in_course,
$this->in_group
$this->in_course_ref_id,
$this->in_group_ref_id
);
$this->user_fields = $cols[1];
$this->selectable_columns = $cols[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class ilTrSummaryTableGUI extends ilLPTableBaseGUI
{
protected ?ilObjectLP $olp = null;
protected bool $is_root;
protected bool $is_in_course = false;
protected bool $is_in_group = false;
protected int $ref_id;
protected ?string $type = null;
protected int $obj_id;
Expand Down Expand Up @@ -63,6 +65,18 @@ public function __construct(
}
}

if (
!$this->is_root &&
$DIC->repositoryTree()->checkForParentType($this->ref_id, 'grp')
) {
$this->is_in_group = true;
} elseif (
!$this->is_root &&
$DIC->repositoryTree()->checkForParentType($this->ref_id, 'crs')
) {
$this->is_in_course = true;
}

parent::__construct($a_parent_obj, $a_parent_cmd);

if ($a_print_mode) {
Expand Down Expand Up @@ -173,7 +187,10 @@ public function getSelectableColumns(): array

$privacy = array("gender", "city", "country", "sel_country");
foreach ($privacy as $field) {
if ($this->setting->get("usr_settings_course_export_" . $field)) {
if (
($this->is_in_course && $this->setting->get("usr_settings_course_export_" . $field)) ||
($this->is_in_group && $this->setting->get("usr_settings_group_export_" . $field))
) {
$all[] = $field;
}
}
Expand Down

0 comments on commit 27a55df

Please sign in to comment.