19declare(strict_types=1);
50 if (empty($users_per_position)) {
72 $query =
'SELECT crs_ref.ref_id AS crs_ref_id, crs.title AS crs_title, reg_status, lp_status, usr_data.usr_id AS usr_id, usr_data.login AS usr_login, usr_data.lastname AS usr_lastname, usr_data.firstname AS usr_firstname, usr_data.email AS usr_email FROM (
75 LEFT JOIN ut_lp_marks AS lp on lp.obj_id = reg.obj_id AND lp.usr_id = reg.usr_id
76 WHERE ' . $this->dic->database()->in(
'reg.usr_id', $arr_usr_ids,
false,
'integer') .
' AND (reg.admin > 0 OR reg.tutor > 0 OR reg.member > 0)
79 WHERE ' . $this->dic->database()->in(
'waiting.usr_id', $arr_usr_ids,
false,
'integer') .
'
82 WHERE ' . $this->dic->database()->in(
'requested.usr_id', $arr_usr_ids,
false,
'integer') .
'
85 INNER JOIN object_data AS crs on crs.obj_id = memb.obj_id AND crs.type = ' . $this->dic->database()
90 INNER JOIN object_reference AS crs_ref on crs_ref.obj_id = crs.obj_id AND crs_ref.deleted IS NULL
91 LEFT JOIN orgu_obj_pos_settings AS oupos_set on oupos_set.obj_id = crs.obj_id
92 INNER JOIN orgu_obj_type_settings AS outype_set ON outype_set.obj_type = "crs"
93 INNER JOIN usr_data on usr_data.usr_id = memb.usr_id';
98 $query .=
" AND (oupos_set.active = 1 OR outype_set.activation_default = 1 OR outype_set.changeable = 0)";
100 foreach ($users_per_position as $position_id => $users) {
102 $this->dic->user()->getId(),
105 $arr_query[] = $query .
" AND " . $this->dic->database()->in(
110 ) .
" AND " . $this->dic->database()->in(
'usr_data.usr_id', $users,
false,
'integer');
113 $union_query =
"SELECT * FROM ((" . implode(
') UNION (', $arr_query) .
")) as a_table";
115 $union_query .= static::createWhereStatement(
$options[
'filters']);
117 $result = $this->dic->database()->query($union_query);
118 $numRows = $this->dic->database()->numRows($result);
121 $union_query .=
" ORDER BY " .
$options[
'sort'][
'field'] .
" " .
$options[
'sort'][
'direction'];
125 $union_query .=
" LIMIT " .
$options[
'limit'][
'start'] .
"," .
$options[
'limit'][
'end'];
127 $result = $this->dic->database()->query($union_query);
130 while ($crs = $this->dic->database()->fetchAssoc($result)) {
132 $list_course->setCrsRefId(intval($crs[
'crs_ref_id']));
133 $list_course->setCrsTitle($crs[
'crs_title'] ??
"");
134 $list_course->setUsrRegStatus(intval($crs[
'reg_status']));
135 $list_course->setUsrLpStatus(intval($crs[
'lp_status']));
136 $list_course->setUsrLogin($crs[
'usr_login']);
137 $list_course->setUsrLastname($crs[
'usr_lastname']);
138 $list_course->setUsrFirstname($crs[
'usr_firstname']);
139 $list_course->setUsrEmail($crs[
'usr_email'] ??
"");
140 $list_course->setUsrId(intval($crs[
'usr_id']));
142 $crs_data[] = $list_course;
155 if (!empty($arr_filter[
'crs_title'])) {
156 $where[] =
'(crs_title LIKE ' . $this->dic->database()->quote(
157 '%' . $arr_filter[
'crs_title'] .
'%',
162 if ($arr_filter[
'course'] > 0) {
163 $where[] =
'(crs_ref_id = ' . $this->dic->database()->quote($arr_filter[
'course'],
'integer') .
')';
167 if (isset($arr_filter[
'lp_status']) && $arr_filter[
'lp_status'] >= 0) {
168 switch ($arr_filter[
'lp_status']) {
171 $where[] =
'(lp_status = ' . $this->dic->database()->quote(
172 $arr_filter[
'lp_status'],
174 ) .
' OR lp_status is NULL)';
177 $where[] =
'(lp_status = ' . $this->dic->database()->quote(
178 $arr_filter[
'lp_status'],
185 if (!empty($arr_filter[
'memb_status'])) {
186 $where[] =
'(reg_status = ' . $this->dic->database()->quote($arr_filter[
'memb_status'],
'integer') .
')';
189 if (!empty($arr_filter[
'user'])) {
190 $where[] =
"(" . $this->dic->database()->like(
193 "%" . $arr_filter[
'user'] .
"%"
194 ) .
" " .
"OR " . $this->dic->database()
198 "%" . $arr_filter[
'user'] .
"%"
199 ) .
" " .
"OR " . $this->dic->database()
203 "%" . $arr_filter[
'user'] .
"%"
204 ) .
" " .
"OR " . $this->dic->database()
208 "%" . $arr_filter[
'user'] .
"%"
212 if (!empty($arr_filter[
'org_unit'])) {
213 $where[] =
'usr_id IN (SELECT user_id FROM il_orgu_ua WHERE orgu_id = ' . $this->dic->database()
215 $arr_filter[
'org_unit'],
220 if (isset($arr_filter[
'usr_id']) && is_numeric($arr_filter[
'usr_id'])) {
224 if (!empty($where)) {
225 return ' WHERE ' . implode(
' AND ', $where) .
' ';
Customizing of pimple-DIC for ILIAS.
const int MEMBERSHIP_STATUS_REGISTERED
const int MEMBERSHIP_STATUS_WAITINGLIST
const int MEMBERSHIP_STATUS_REQUESTED
getData(array $arr_usr_ids=array(), array $options=array())
createWhereStatement(array $arr_filter)
Returns the WHERE Part for the Queries using parameter $user_ids AND local variable $filters.
__construct(Container $dic)
ilMStListCourses constructor.
const string ACCESS_ENROLMENTS_ORG_UNIT_OPERATION
const string COURSE_CONTEXT
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_NOT_ATTEMPTED_NUM
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...