Skip to content

Commit

Permalink
MyStaff: Pick fixes from release_6 (#4085) (#4127)
Browse files Browse the repository at this point in the history
thank you michael!

* MyStaff: Improve performance when listing courses of user

* MyStaff: Fix query when determining courses of user(s)

* Org.Units: Fix filter when listing courses for user

Co-authored-by: Martin Studer <[email protected]>

(cherry picked from commit b6cd535)
  • Loading branch information
mjansenDatabay authored Mar 14, 2022
1 parent 4c6ff1a commit 52848ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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') . '
Expand Down Expand Up @@ -181,6 +181,10 @@ protected function createWhereStatement(array $arr_filter)
->quote($arr_filter['org_unit'], '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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class ilMStShowUserCoursesTableGUI extends ilTable2GUI
* @var ilMyStaffAccess
*/
protected $access;

/** @var null|array */
protected $columnDefinition = null;

/**
* @param ilMStShowUserCoursesGUI $parent_obj
Expand Down Expand Up @@ -182,6 +183,10 @@ public function getSelectableColumns()
{
global $DIC;

if ($this->columnDefinition !== null) {
return $this->columnDefinition;
}

$cols = array();

$cols['crs_title'] = array(
Expand All @@ -205,7 +210,9 @@ public function getSelectableColumns()
);
}

return $cols;
$this->columnDefinition = $cols;

return $this->columnDefinition;
}


Expand Down

0 comments on commit 52848ec

Please sign in to comment.