18 declare(strict_types=1);
49 if (empty($users_per_position)) {
69 $options = array_merge($_options, $options);
71 $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 ( 74 LEFT JOIN ut_lp_marks AS lp on lp.obj_id = reg.obj_id AND lp.usr_id = reg.usr_id 75 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) 78 WHERE ' . $this->dic->database()->in(
'waiting.usr_id', $arr_usr_ids,
false,
'integer') .
' 81 WHERE ' . $this->dic->database()->in(
'requested.usr_id', $arr_usr_ids,
false,
'integer') .
' 84 INNER JOIN object_data AS crs on crs.obj_id = memb.obj_id AND crs.type = ' . $this->dic->database()
89 INNER JOIN object_reference AS crs_ref on crs_ref.obj_id = crs.obj_id AND crs_ref.deleted IS NULL 90 INNER JOIN usr_data on usr_data.usr_id = memb.usr_id';
93 foreach ($users_per_position as $position_id => $users) {
95 $this->dic->user()->getId(),
98 $arr_query[] = $query .
" AND " . $this->dic->database()->in(
103 ) .
" AND " . $this->dic->database()->in(
'usr_data.usr_id', $users,
false,
'integer');
106 $union_query =
"SELECT * FROM ((" . implode(
') UNION (', $arr_query) .
")) as a_table";
108 $union_query .= static::createWhereStatement($options[
'filters']);
110 $result = $this->dic->database()->query($union_query);
111 $numRows = $this->dic->database()->numRows($result);
113 if ($options[
'sort']) {
114 $union_query .=
" ORDER BY " . $options[
'sort'][
'field'] .
" " . $options[
'sort'][
'direction'];
117 if (isset($options[
'limit'][
'start']) && isset($options[
'limit'][
'end'])) {
118 $union_query .=
" LIMIT " . $options[
'limit'][
'start'] .
"," . $options[
'limit'][
'end'];
120 $result = $this->dic->database()->query($union_query);
123 while ($crs = $this->dic->database()->fetchAssoc($result)) {
125 $list_course->setCrsRefId(intval($crs[
'crs_ref_id']));
126 $list_course->setCrsTitle($crs[
'crs_title'] ??
"");
127 $list_course->setUsrRegStatus(intval($crs[
'reg_status']));
128 $list_course->setUsrLpStatus(intval($crs[
'lp_status']));
129 $list_course->setUsrLogin($crs[
'usr_login']);
130 $list_course->setUsrLastname($crs[
'usr_lastname']);
131 $list_course->setUsrFirstname($crs[
'usr_firstname']);
132 $list_course->setUsrEmail($crs[
'usr_email'] ??
"");
133 $list_course->setUsrId(intval($crs[
'usr_id']));
135 $crs_data[] = $list_course;
148 if (!empty($arr_filter[
'crs_title'])) {
149 $where[] =
'(crs_title LIKE ' . $this->dic->database()->quote(
150 '%' . $arr_filter[
'crs_title'] .
'%',
155 if ($arr_filter[
'course'] > 0) {
156 $where[] =
'(crs_ref_id = ' . $this->dic->database()->quote($arr_filter[
'course'],
'integer') .
')';
160 if (isset($arr_filter[
'lp_status']) && $arr_filter[
'lp_status'] >= 0) {
161 switch ($arr_filter[
'lp_status']) {
164 $where[] =
'(lp_status = ' . $this->dic->database()->quote(
165 $arr_filter[
'lp_status'],
167 ) .
' OR lp_status is NULL)';
170 $where[] =
'(lp_status = ' . $this->dic->database()->quote(
171 $arr_filter[
'lp_status'],
178 if (!empty($arr_filter[
'memb_status'])) {
179 $where[] =
'(reg_status = ' . $this->dic->database()->quote($arr_filter[
'memb_status'],
'integer') .
')';
182 if (!empty($arr_filter[
'user'])) {
183 $where[] =
"(" . $this->dic->database()->like(
186 "%" . $arr_filter[
'user'] .
"%" 187 ) .
" " .
"OR " . $this->dic->database()
191 "%" . $arr_filter[
'user'] .
"%" 192 ) .
" " .
"OR " . $this->dic->database()
196 "%" . $arr_filter[
'user'] .
"%" 197 ) .
" " .
"OR " . $this->dic->database()
201 "%" . $arr_filter[
'user'] .
"%" 205 if (!empty($arr_filter[
'org_unit'])) {
206 $where[] =
'usr_id IN (SELECT user_id FROM il_orgu_ua WHERE orgu_id = ' . $this->dic->database()
208 $arr_filter[
'org_unit'],
213 if (isset($arr_filter[
'usr_id']) && is_numeric($arr_filter[
'usr_id'])) {
217 if (!empty($where)) {
218 return ' WHERE ' . implode(
' AND ', $where) .
' ';
__construct(Container $dic)
ilMStListCourses constructor.
const int MEMBERSHIP_STATUS_WAITINGLIST
const int MEMBERSHIP_STATUS_REGISTERED
Customizing of pimple-DIC for ILIAS.
const string COURSE_CONTEXT
getData(array $arr_usr_ids=array(), array $options=array())
const string ACCESS_ENROLMENTS_ORG_UNIT_OPERATION
const LP_STATUS_NOT_ATTEMPTED_NUM
const int MEMBERSHIP_STATUS_REQUESTED
createWhereStatement(array $arr_filter)
Returns the WHERE Part for the Queries using parameter $user_ids AND local variable $filters...