From 267720313007b16edae93cd423aa6fd905864c29 Mon Sep 17 00:00:00 2001 From: mjansen Date: Mon, 14 Feb 2022 17:30:32 +0100 Subject: [PATCH 1/3] MyStaff: Improve performance when listing courses of user --- .../Courses/class.ilMStShowUserCoursesTableGUI.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Services/MyStaff/classes/ShowUser/Courses/class.ilMStShowUserCoursesTableGUI.php b/Services/MyStaff/classes/ShowUser/Courses/class.ilMStShowUserCoursesTableGUI.php index e19a06113144..937555c1b96d 100644 --- a/Services/MyStaff/classes/ShowUser/Courses/class.ilMStShowUserCoursesTableGUI.php +++ b/Services/MyStaff/classes/ShowUser/Courses/class.ilMStShowUserCoursesTableGUI.php @@ -37,6 +37,9 @@ class ilMStShowUserCoursesTableGUI extends ilTable2GUI * @var ilMyStaffAccess */ protected $access; + + /** @var null|array */ + protected $columnDefinition = null; /** * @param ilMStShowUserCoursesGUI $parent_obj @@ -177,6 +180,10 @@ public function getSelectableColumns() : array { global $DIC; + if ($this->columnDefinition !== null) { + return $this->columnDefinition; + } + $cols = array(); $cols['crs_title'] = array( @@ -200,7 +207,9 @@ public function getSelectableColumns() : array ); } - return $cols; + $this->columnDefinition = $cols; + + return $this->columnDefinition; } /** From d3ba07a4c96acae5d9cda8f278ff4ea87540319f Mon Sep 17 00:00:00 2001 From: mjansen Date: Tue, 15 Feb 2022 18:30:07 +0100 Subject: [PATCH 2/3] MyStaff: Fix query when determining courses of user(s) --- Services/MyStaff/classes/ListCourses/class.ilMStListCourses.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Services/MyStaff/classes/ListCourses/class.ilMStListCourses.php b/Services/MyStaff/classes/ListCourses/class.ilMStListCourses.php index e6434c2fd5df..55a3b656cb66 100644 --- a/Services/MyStaff/classes/ListCourses/class.ilMStListCourses.php +++ b/Services/MyStaff/classes/ListCourses/class.ilMStListCourses.php @@ -56,7 +56,7 @@ public function getData(array $arr_usr_ids = array(), array $options = array()) SELECT reg.obj_id, reg.usr_id, ' . ilMStListCourse::MEMBERSHIP_STATUS_REGISTERED . ' AS reg_status, lp.status AS lp_status FROM obj_members AS reg LEFT JOIN ut_lp_marks AS lp on lp.obj_id = reg.obj_id AND lp.usr_id = reg.usr_id - WHERE ' . $this->dic->database()->in('reg.usr_id', $arr_usr_ids, false, 'integer') . ' + WHERE ' . $this->dic->database()->in('reg.usr_id', $arr_usr_ids, false, 'integer') . ' AND (reg.admin = 1 OR reg.tutor = 1 OR reg.member = 1) UNION SELECT obj_id, usr_id, ' . ilMStListCourse::MEMBERSHIP_STATUS_WAITINGLIST . ' AS reg_status, 0 AS lp_status FROM crs_waiting_list AS waiting WHERE ' . $this->dic->database()->in('waiting.usr_id', $arr_usr_ids, false, 'integer') . ' From 232f09da6443dcbb590a516bc17d28261f87f6dd Mon Sep 17 00:00:00 2001 From: mjansen Date: Mon, 14 Feb 2022 16:05:50 +0100 Subject: [PATCH 3/3] Org.Units: Fix filter when listing courses for user --- .../MyStaff/classes/ListCourses/class.ilMStListCourses.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Services/MyStaff/classes/ListCourses/class.ilMStListCourses.php b/Services/MyStaff/classes/ListCourses/class.ilMStListCourses.php index 55a3b656cb66..38ede5332710 100644 --- a/Services/MyStaff/classes/ListCourses/class.ilMStListCourses.php +++ b/Services/MyStaff/classes/ListCourses/class.ilMStListCourses.php @@ -185,6 +185,10 @@ protected function createWhereStatement(array $arr_filter) 'integer') . ')'; } + if (isset($arr_filter['usr_id']) && is_numeric($arr_filter['usr_id'])) { + $where[] = 'usr_id = ' . $this->dic->database()->quote($arr_filter['usr_id'], \ilDBConstants::T_INTEGER); + } + if (!empty($where)) { return ' WHERE ' . implode(' AND ', $where) . ' '; } else {