From 27a55df5aabfad54c15affe855231e0f98bdac15 Mon Sep 17 00:00:00 2001 From: Tim Schmitz Date: Mon, 24 Jun 2024 15:00:42 +0200 Subject: [PATCH] Tracking: streamline user fields handling in some tables (31900) --- .../classes/class.ilLPTableBaseGUI.php | 8 +++-- .../class.ilTrMatrixTableGUI.php | 21 ++++++----- .../class.ilTrObjectUsersPropsTableGUI.php | 36 ++++++++++++++----- .../class.ilTrSummaryTableGUI.php | 19 +++++++++- 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/Services/Tracking/classes/class.ilLPTableBaseGUI.php b/Services/Tracking/classes/class.ilLPTableBaseGUI.php index 32c9720b3867..9b512555277f 100644 --- a/Services/Tracking/classes/class.ilLPTableBaseGUI.php +++ b/Services/Tracking/classes/class.ilLPTableBaseGUI.php @@ -16,6 +16,8 @@ * *********************************************************************/ +declare(strict_types=0); + use ILIAS\Refinery\Factory as RefineryFactory; use ILIAS\HTTP\Services as HttpService; @@ -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; diff --git a/Services/Tracking/classes/repository_statistics/class.ilTrMatrixTableGUI.php b/Services/Tracking/classes/repository_statistics/class.ilTrMatrixTableGUI.php index ab0880e509cf..5cbf2b716c92 100644 --- a/Services/Tracking/classes/repository_statistics/class.ilTrMatrixTableGUI.php +++ b/Services/Tracking/classes/repository_statistics/class.ilTrMatrixTableGUI.php @@ -1,6 +1,5 @@ @@ -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 = []; @@ -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); } } @@ -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) { diff --git a/Services/Tracking/classes/repository_statistics/class.ilTrObjectUsersPropsTableGUI.php b/Services/Tracking/classes/repository_statistics/class.ilTrObjectUsersPropsTableGUI.php index 2ea5a4f6bc73..6bfa4360a975 100644 --- a/Services/Tracking/classes/repository_statistics/class.ilTrObjectUsersPropsTableGUI.php +++ b/Services/Tracking/classes/repository_statistics/class.ilTrObjectUsersPropsTableGUI.php @@ -1,6 +1,22 @@ 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); @@ -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]; diff --git a/Services/Tracking/classes/repository_statistics/class.ilTrSummaryTableGUI.php b/Services/Tracking/classes/repository_statistics/class.ilTrSummaryTableGUI.php index 9acb51af255f..1893634f082e 100644 --- a/Services/Tracking/classes/repository_statistics/class.ilTrSummaryTableGUI.php +++ b/Services/Tracking/classes/repository_statistics/class.ilTrSummaryTableGUI.php @@ -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; @@ -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) { @@ -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; } }