ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\MyStaff\ListCourses\ilMStListCourses Class Reference

Class ilMStListCourses. More...

+ Inheritance diagram for ILIAS\MyStaff\ListCourses\ilMStListCourses:
+ Collaboration diagram for ILIAS\MyStaff\ListCourses\ilMStListCourses:

Public Member Functions

 __construct (Container $dic)
 ilMStListCourses constructor. More...
 
 getData (array $arr_usr_ids=array(), array $options=array())
 

Protected Member Functions

 createWhereStatement (array $arr_filter)
 Returns the WHERE Part for the Queries using parameter $user_ids AND local variable $filters. More...
 

Protected Attributes

Container $dic
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MyStaff\ListCourses\ilMStListCourses::__construct ( Container  $dic)

ilMStListCourses constructor.

Parameters
Container$dic

Definition at line 41 of file class.ilMStListCourses.php.

42 {
43 $this->dic = $dic;
44 }

References ILIAS\MyStaff\ListCourses\ilMStListCourses\$dic.

Member Function Documentation

◆ createWhereStatement()

ILIAS\MyStaff\ListCourses\ilMStListCourses::createWhereStatement ( array  $arr_filter)
protected

Returns the WHERE Part for the Queries using parameter $user_ids AND local variable $filters.

Reimplemented in ILIAS\MyStaff\Courses\ShowUser\ilMStShowUserCourses.

Definition at line 151 of file class.ilMStListCourses.php.

151 : string
152 {
153 $where = array();
154
155 if (!empty($arr_filter['crs_title'])) {
156 $where[] = '(crs_title LIKE ' . $this->dic->database()->quote(
157 '%' . $arr_filter['crs_title'] . '%',
158 'text'
159 ) . ')';
160 }
161
162 if ($arr_filter['course'] > 0) {
163 $where[] = '(crs_ref_id = ' . $this->dic->database()->quote($arr_filter['course'], 'integer') . ')';
164 }
165
166
167 if (isset($arr_filter['lp_status']) && $arr_filter['lp_status'] >= 0) {
168 switch ($arr_filter['lp_status']) {
170 //if a user has the lp status not attempted it could be, that the user hase no records in table ut_lp_marks
171 $where[] = '(lp_status = ' . $this->dic->database()->quote(
172 $arr_filter['lp_status'],
173 'integer'
174 ) . ' OR lp_status is NULL)';
175 break;
176 default:
177 $where[] = '(lp_status = ' . $this->dic->database()->quote(
178 $arr_filter['lp_status'],
179 'integer'
180 ) . ')';
181 break;
182 }
183 }
184
185 if (!empty($arr_filter['memb_status'])) {
186 $where[] = '(reg_status = ' . $this->dic->database()->quote($arr_filter['memb_status'], 'integer') . ')';
187 }
188
189 if (!empty($arr_filter['user'])) {
190 $where[] = "(" . $this->dic->database()->like(
191 "usr_login",
192 "text",
193 "%" . $arr_filter['user'] . "%"
194 ) . " " . "OR " . $this->dic->database()
195 ->like(
196 "usr_firstname",
197 "text",
198 "%" . $arr_filter['user'] . "%"
199 ) . " " . "OR " . $this->dic->database()
200 ->like(
201 "usr_lastname",
202 "text",
203 "%" . $arr_filter['user'] . "%"
204 ) . " " . "OR " . $this->dic->database()
205 ->like(
206 "usr_email",
207 "text",
208 "%" . $arr_filter['user'] . "%"
209 ) . ") ";
210 }
211
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()
214 ->quote(
215 $arr_filter['org_unit'],
216 'integer'
217 ) . ')';
218 }
219
220 if (isset($arr_filter['usr_id']) && is_numeric($arr_filter['usr_id'])) {
221 $where[] = 'usr_id = ' . $this->dic->database()->quote($arr_filter['usr_id'], \ilDBConstants::T_INTEGER);
222 }
223
224 if (!empty($where)) {
225 return ' WHERE ' . implode(' AND ', $where) . ' ';
226 } else {
227 return '';
228 }
229 }
const LP_STATUS_NOT_ATTEMPTED_NUM

References ilLPStatus\LP_STATUS_NOT_ATTEMPTED_NUM, and ilDBConstants\T_INTEGER.

◆ getData()

ILIAS\MyStaff\ListCourses\ilMStListCourses::getData ( array  $arr_usr_ids = array(),
array  $options = array() 
)
final

Definition at line 46 of file class.ilMStListCourses.php.

46 : ListFetcherResult
47 {
48 $users_per_position = ilMyStaffAccess::getInstance()->getUsersForUserPerPosition($this->dic->user()->getId());
49
50 if (empty($users_per_position)) {
51 return new ListFetcherResult([], 0);
52 }
53
54 //Permission Filter
56
57 // permission should not be changed here because learning progress only works in combination with course memberships
58 /*if (isset($options['filters']['lp_status']) && $options['filters']['lp_status'] >= 0) {
59 $operation_access = ilOrgUnitOperation::OP_READ_LEARNING_PROGRESS;
60 }*/
61 /*$tmp_table_user_matrix = ilMyStaffAccess::getInstance()->buildTempTableIlobjectsUserMatrixForUserOperationAndContext($this->dic->user()
62 ->getId(), $operation_access, ilMyStaffAccess::DEFAULT_CONTEXT, ilMyStaffAccess::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX);*/
63
64 $_options = array(
65 'filters' => array(),
66 'sort' => array(),
67 'limit' => array(),
68 'count' => false,
69 );
70 $options = array_merge($_options, $options);
71
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 (
73 SELECT reg.obj_id, reg.usr_id, ' . ilMStListCourse::MEMBERSHIP_STATUS_REGISTERED . ' AS reg_status, lp.status AS lp_status FROM obj_members
74 AS reg
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)
77 UNION
78 SELECT obj_id, usr_id, ' . ilMStListCourse::MEMBERSHIP_STATUS_WAITINGLIST . ' AS reg_status, 0 AS lp_status FROM crs_waiting_list AS waiting
79 WHERE ' . $this->dic->database()->in('waiting.usr_id', $arr_usr_ids, false, 'integer') . '
80 UNION
81 SELECT obj_id, usr_id, ' . ilMStListCourse::MEMBERSHIP_STATUS_REQUESTED . ' AS reg_status, 0 AS lp_status FROM il_subscribers AS requested
82 WHERE ' . $this->dic->database()->in('requested.usr_id', $arr_usr_ids, false, 'integer') . '
83 ) AS memb
84
85 INNER JOIN object_data AS crs on crs.obj_id = memb.obj_id AND crs.type = ' . $this->dic->database()
86 ->quote(
88 'text'
89 ) . '
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';
94
95 $arr_query = [];
96
97 // reflect course settings or org unit settings
98 $query .= " AND (oupos_set.active = 1 OR outype_set.activation_default = 1 OR outype_set.changeable = 0)";
99
100 foreach ($users_per_position as $position_id => $users) {
101 $obj_ids = ilMyStaffAccess::getInstance()->getIdsForUserAndOperation(
102 $this->dic->user()->getId(),
103 $operation_access
104 );
105 $arr_query[] = $query . " AND " . $this->dic->database()->in(
106 'crs.obj_id',
107 $obj_ids,
108 false,
109 'integer'
110 ) . " AND " . $this->dic->database()->in('usr_data.usr_id', $users, false, 'integer');
111 }
112
113 $union_query = "SELECT * FROM ((" . implode(') UNION (', $arr_query) . ")) as a_table";
114
115 $union_query .= static::createWhereStatement($options['filters']);
116
117 $result = $this->dic->database()->query($union_query);
118 $numRows = $this->dic->database()->numRows($result);
119
120 if ($options['sort']) {
121 $union_query .= " ORDER BY " . $options['sort']['field'] . " " . $options['sort']['direction'];
122 }
123
124 if (isset($options['limit']['start']) && isset($options['limit']['end'])) {
125 $union_query .= " LIMIT " . $options['limit']['start'] . "," . $options['limit']['end'];
126 }
127 $result = $this->dic->database()->query($union_query);
128 $crs_data = array();
129
130 while ($crs = $this->dic->database()->fetchAssoc($result)) {
131 $list_course = new ilMStListCourse();
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']));
141
142 $crs_data[] = $list_course;
143 }
144
145 return new ListFetcherResult($crs_data, $numRows);
146 }

References ILIAS\UI\Implementation\Component\Input\Field\$options, ILIAS\MyStaff\ilMyStaffAccess\ACCESS_ENROLMENTS_ORG_UNIT_OPERATION, ILIAS\MyStaff\ilMyStaffAccess\COURSE_CONTEXT, ILIAS\MyStaff\ilMyStaffAccess\getInstance(), ILIAS\MyStaff\ListCourses\ilMStListCourse\MEMBERSHIP_STATUS_REGISTERED, ILIAS\MyStaff\ListCourses\ilMStListCourse\MEMBERSHIP_STATUS_REQUESTED, and ILIAS\MyStaff\ListCourses\ilMStListCourse\MEMBERSHIP_STATUS_WAITINGLIST.

+ Here is the call graph for this function:

Field Documentation

◆ $dic

Container ILIAS\MyStaff\ListCourses\ilMStListCourses::$dic
protected

The documentation for this class was generated from the following file: