Skip to content

Commit

Permalink
MyStaff: Pick fixes from release_6 (ILIAS-eLearning#4085)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
mjansenDatabay and mstuder authored Mar 10, 2022
1 parent 5e35d80 commit b6cd535
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final public function getData(array $arr_usr_ids = array(), array $options = arr
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 @@ -172,6 +172,10 @@ protected function createWhereStatement(array $arr_filter): string
'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 @@ -27,7 +27,12 @@ class ilMStShowUserCoursesTableGUI extends ilTable2GUI
protected int $usr_id;
protected array $filter = array();
protected ilMyStaffAccess $access;
protected ?array $columnDefinition = null;

/**
* @param ilMStShowUserCoursesGUI $parent_obj
* @param string $parent_cmd
*/
public function __construct(ilMStShowUserCoursesGUI $parent_obj, $parent_cmd = ilMStShowUserCoursesGUI::CMD_INDEX)
{
global $DIC;
Expand Down Expand Up @@ -154,6 +159,10 @@ final public function getSelectableColumns() : array
{
global $DIC;

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

$cols = array();

$cols['crs_title'] = array(
Expand All @@ -177,7 +186,9 @@ final public function getSelectableColumns() : array
);
}

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

return $this->columnDefinition;
}

private function addColumns() : void
Expand Down

0 comments on commit b6cd535

Please sign in to comment.