40 public function getData(array $arr_usr_ids = array(), array $options = array())
45 if (!empty($options[
'filters'][
'lp_status']) || $options[
'filters'][
'lp_status'] === 0) {
57 $options = array_merge($_options, $options);
59 $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 ( 62 LEFT JOIN ut_lp_marks AS lp on lp.obj_id = reg.obj_id AND lp.usr_id = reg.usr_id 63 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) 66 WHERE ' . $this->dic->database()->in(
'waiting.usr_id', $arr_usr_ids,
false,
'integer') .
' 69 WHERE ' . $this->dic->database()->in(
'requested.usr_id', $arr_usr_ids,
false,
'integer') .
' 72 INNER JOIN object_data AS crs on crs.obj_id = memb.obj_id AND crs.type = ' . $this->dic->database()
74 INNER JOIN object_reference AS crs_ref on crs_ref.obj_id = crs.obj_id AND crs_ref.deleted IS NULL 75 INNER JOIN usr_data on usr_data.usr_id = memb.usr_id AND usr_data.active = 1';
81 if (empty($users_per_position)) {
82 if ($options[
"count"]) {
90 foreach ($users_per_position as $position_id => $users) {
92 $arr_query[] =
$query .
" AND " . $this->dic->database()->in(
'crs.obj_id', $obj_ids,
false,
'integer') .
" AND " . $this->dic->database()->in(
'usr_data.usr_id', $users,
false,
'integer');
95 $union_query =
"SELECT * FROM ((" . implode(
') UNION (', $arr_query) .
")) as a_table";
97 $union_query .= static::createWhereStatement($options[
'filters']);
99 if ($options[
'count']) {
100 $result = $this->dic->database()->query($union_query);
102 return $this->dic->database()->numRows(
$result);
105 if ($options[
'sort']) {
106 $union_query .=
" ORDER BY " . $options[
'sort'][
'field'] .
" " . $options[
'sort'][
'direction'];
109 if (isset($options[
'limit'][
'start']) && isset($options[
'limit'][
'end'])) {
110 $union_query .=
" LIMIT " . $options[
'limit'][
'start'] .
"," . $options[
'limit'][
'end'];
112 $result = $this->dic->database()->query($union_query);
115 while ($crs = $this->dic->database()->fetchAssoc(
$result)) {
117 $list_course->setCrsRefId($crs[
'crs_ref_id']);
118 $list_course->setCrsTitle($crs[
'crs_title']);
119 $list_course->setUsrRegStatus($crs[
'reg_status']);
120 $list_course->setUsrLpStatus($crs[
'lp_status']);
121 $list_course->setUsrLogin($crs[
'usr_login']);
122 $list_course->setUsrLastname($crs[
'usr_lastname']);
123 $list_course->setUsrFirstname($crs[
'usr_firstname']);
124 $list_course->setUsrEmail($crs[
'usr_email']);
125 $list_course->setUsrId($crs[
'usr_id']);
127 $crs_data[] = $list_course;
148 if (!empty($arr_filter[
'crs_title'])) {
149 $where[] =
'(crs_title LIKE ' . $this->dic->database()->quote(
'%' . $arr_filter[
'crs_title'] .
'%',
'text') .
')';
152 if ($arr_filter[
'course'] > 0) {
153 $where[] =
'(crs_ref_id = ' . $this->dic->database()->quote($arr_filter[
'course'],
'integer') .
')';
156 if (!empty($arr_filter[
'lp_status']) || $arr_filter[
'lp_status'] === 0) {
157 switch ($arr_filter[
'lp_status']) {
160 $where[] =
'(lp_status = ' . $this->dic->database()->quote($arr_filter[
'lp_status'],
'integer') .
' OR lp_status is NULL)';
163 $where[] =
'(lp_status = ' . $this->dic->database()->quote($arr_filter[
'lp_status'],
'integer') .
')';
168 if (!empty($arr_filter[
'memb_status'])) {
169 $where[] =
'(reg_status = ' . $this->dic->database()->quote($arr_filter[
'memb_status'],
'integer') .
')';
172 if (!empty($arr_filter[
'user'])) {
173 $where[] =
"(" . $this->dic->database()->like(
"usr_login",
"text",
"%" . $arr_filter[
'user'] .
"%") .
" " .
"OR " . $this->dic->database()
174 ->like(
"usr_firstname",
"text",
"%" . $arr_filter[
'user'] .
"%") .
" " .
"OR " . $this->dic->database()
175 ->like(
"usr_lastname",
"text",
"%" . $arr_filter[
'user'] .
"%") .
" " .
"OR " . $this->dic->database()
176 ->like(
"usr_email",
"text",
"%" . $arr_filter[
'user'] .
"%") .
") ";
179 if (!empty($arr_filter[
'org_unit'])) {
180 $where[] =
'usr_id IN (SELECT user_id FROM il_orgu_ua WHERE orgu_id = ' . $this->dic->database()
181 ->quote($arr_filter[
'org_unit'],
'integer') .
')';
184 if (isset($arr_filter[
'usr_id']) && is_numeric($arr_filter[
'usr_id'])) {
188 if (!empty($where)) {
189 return ' WHERE ' . implode(
' AND ', $where) .
' ';
const MEMBERSHIP_STATUS_REGISTERED
const MEMBERSHIP_STATUS_WAITINGLIST
__construct(Container $dic)
ilMStListCourses constructor.
Customizing of pimple-DIC for ILIAS.
getData(array $arr_usr_ids=array(), array $options=array())
const OP_READ_LEARNING_PROGRESS
const LP_STATUS_NOT_ATTEMPTED_NUM
const OP_ACCESS_ENROLMENTS
createWhereStatement(array $arr_filter)
Returns the WHERE Part for the Queries using parameter $user_ids AND local variable $filters...
const MEMBERSHIP_STATUS_REQUESTED