56 "time_limit_unlimited",
75 foreach ($a_val as $udf_name => $udf_value) {
76 [$udf_string, $udf_id] = explode(
'_', $udf_name);
77 if (array_key_exists((
int) $udf_id, $definitions)) {
78 $valid_udfs[$udf_name] = $udf_value;
81 $this->udf_filter = $valid_udfs;
99 $this->order_field = $a_order;
109 $this->order_dir = $a_dir;
114 $this->offset = $a_offset;
119 $this->limit = $a_limit;
127 $this->text_filter = $a_filter;
136 $this->activation = $a_activation;
144 $this->last_login = $dt;
152 $this->limited_access = $a_status;
157 $this->no_courses = $a_no_course;
162 $this->no_groups = $a_no_group;
171 $this->crs_grp = $a_cg_id;
180 $this->role = $a_role_id;
189 $this->user_folder = $a_fold_id;
197 $this->additional_fields = $a_add;
205 $this->users = $a_filter;
213 $this->first_letter = $a_fll;
221 $this->has_access = $a_access;
230 $this->authentication_method = $a_authentication;
241 $ilDB = $DIC[
'ilDB'];
244 $udf_fields = array();
249 if (is_array($this->additional_fields)) {
250 foreach ($this->additional_fields as
$f) {
251 if (!in_array($f, $this->default_fields)) {
252 if ($f ===
"online_time") {
253 $this->default_fields[] =
"ut_online.online_time";
254 $join =
" LEFT JOIN ut_online ON (usr_data.usr_id = ut_online.usr_id) ";
255 } elseif (substr($f, 0, 4) ===
"udf_") {
256 $udf_fields[] = (
int) substr($f, 4);
258 $this->default_fields[] =
$f;
266 if (count($udf_fields) > 0) {
271 foreach ($udf_fields as
$id) {
275 $join .=
" LEFT JOIN " . $udf_table .
" ud_" . $id .
" ON (ud_" . $id .
".field_id=" .
$ilDB->quote($id) .
" AND ud_" . $id .
".usr_id = usr_data.usr_id) ";
279 $count_query =
"SELECT count(usr_data.usr_id) cnt" .
282 $all_multi_fields = array(
"interests_general",
"interests_help_offered",
"interests_help_looking");
283 $multi_fields = array();
285 $sql_fields = array();
286 foreach ($this->default_fields as $idx => $field) {
291 if (in_array($field, $all_multi_fields)) {
292 $multi_fields[] = $field;
293 } elseif (strpos($field,
".") ===
false) {
294 $sql_fields[] =
"usr_data." . $field;
296 $sql_fields[] = $field;
301 foreach ($udf_fields as $id) {
302 $sql_fields[] =
"ud_" . $id .
".value udf_" .
$id;
306 $query =
"SELECT " . implode(
",", $sql_fields) .
310 $count_query .=
" " . $join;
316 $count_query .=
" WHERE 1 = 1 ";
318 if ($this->users and is_array(($this->users))) {
319 $query .=
' AND ' .
$ilDB->in(
'usr_data.usr_id', $this->users,
false,
'integer');
320 $count_user_filter =
$ilDB->in(
'usr_data.usr_id', $this->users,
false,
'integer');
323 $count_query .=
" AND " . $count_user_filter .
" ";
326 if ($this->first_letter !=
"") {
327 $add = $where .
" (" .
$ilDB->upper(
$ilDB->substr(
"usr_data.lastname", 1, 1)) .
" = " .
$ilDB->upper(
$ilDB->quote($this->first_letter,
"text")) .
") ";
329 $count_query .= $add;
333 if ($this->text_filter !=
"") {
334 $add = $where .
" (" .
$ilDB->like(
"usr_data.login",
"text",
"%" . $this->text_filter .
"%") .
" " .
335 "OR " .
$ilDB->like(
"usr_data.firstname",
"text",
"%" . $this->text_filter .
"%") .
" " .
336 "OR " .
$ilDB->like(
"usr_data.lastname",
"text",
"%" . $this->text_filter .
"%") .
" " .
337 "OR " .
$ilDB->like(
"usr_data.second_email",
"text",
"%" . $this->text_filter .
"%") .
" " .
338 "OR " .
$ilDB->like(
"usr_data.email",
"text",
"%" . $this->text_filter .
"%") .
") ";
340 $count_query .= $add;
344 if ($this->activation !=
"") {
345 if ($this->activation ===
"inactive") {
346 $add = $where .
" usr_data.active = " .
$ilDB->quote(0,
"integer") .
" ";
348 $add = $where .
" usr_data.active = " .
$ilDB->quote(1,
"integer") .
" ";
351 $count_query .= $add;
355 if ($this->last_login instanceof
ilDateTime) {
357 $add = $where .
" usr_data.last_login < " .
360 $count_query .= $add;
364 if ($this->limited_access) {
365 $add = $where .
" usr_data.time_limit_unlimited= " .
$ilDB->quote(0,
"integer");
367 $count_query .= $add;
374 $udf_id = explode(
"_", $k)[1];
376 $add = $where .
" " .
$ilDB->like(
"ud_" . $udf_id .
".value",
"text",
"%" .
$f .
"%");
378 $add = $where .
" ud_" . $udf_id .
".value = " .
$ilDB->quote(
$f,
"text");
381 $count_query .= $add;
386 if ($this->has_access) {
387 $unlimited =
"time_limit_unlimited = " .
$ilDB->quote(1,
'integer');
388 $from =
"time_limit_from < " .
$ilDB->quote(time(),
'integer');
389 $until =
"time_limit_until > " .
$ilDB->quote(time(),
'integer');
391 $add = $where .
' (' . $unlimited .
' OR (' . $from .
' AND ' . $until .
'))';
393 $count_query .= $add;
396 if ($this->no_courses) {
397 $add = $where .
" usr_data.usr_id NOT IN (" .
398 "SELECT DISTINCT ud.usr_id " .
399 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
400 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
401 "JOIN rbac_fa ON (rbac_ua.rol_id = rbac_fa.rol_id) " .
402 "JOIN tree ON (rbac_fa.parent = tree.child) " .
403 "WHERE od.title LIKE 'il_crs_%' " .
404 "AND rbac_fa.assign = 'y' " .
405 "AND tree.tree > 0)";
407 $count_query .= $add;
410 if ($this->no_groups) {
411 $add = $where .
" usr_data.usr_id NOT IN (" .
412 "SELECT DISTINCT ud.usr_id " .
413 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
414 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
415 "JOIN rbac_fa ON (rbac_ua.rol_id = rbac_fa.rol_id) " .
416 "JOIN tree ON (rbac_fa.parent = tree.child) " .
417 "WHERE od.title LIKE 'il_grp_%' " .
418 "AND rbac_fa.assign = 'y' " .
419 "AND tree.tree > 0)";
421 $count_query .= $add;
424 if ($this->crs_grp > 0) {
426 $add = $where .
" usr_data.usr_id IN (" .
427 "SELECT DISTINCT ud.usr_id " .
428 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
429 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
430 "WHERE od.title = " .
$ilDB->quote(
"il_" . $cgtype .
"_member_" . $this->crs_grp,
"text") .
")";
432 $count_query .= $add;
435 if ($this->role > 0) {
436 $add = $where .
" usr_data.usr_id IN (" .
437 "SELECT DISTINCT ud.usr_id " .
438 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
439 "WHERE rbac_ua.rol_id = " .
$ilDB->quote($this->role,
"integer") .
")";
441 $count_query .= $add;
445 if ($this->user_folder) {
446 $add = $where .
" " .
$ilDB->in(
'usr_data.time_limit_owner', $this->user_folder,
false,
'integer');
448 $count_query .= $add;
452 if ($this->authentication_method !=
"") {
453 $add = $where .
" usr_data.auth_mode = " .
$ilDB->quote($this->authentication_method,
"text") .
" ";
455 $count_query .= $add;
460 switch ($this->order_field) {
462 if ($this->order_dir ===
"desc") {
463 $query .=
" ORDER BY usr_data.active DESC, usr_data.time_limit_unlimited DESC, usr_data.time_limit_until DESC";
465 $query .=
" ORDER BY usr_data.active ASC, usr_data.time_limit_unlimited ASC, usr_data.time_limit_until ASC";
470 if ($this->order_dir ===
"desc") {
471 $query .=
" ORDER BY ut_online.online_time DESC";
473 $query .=
" ORDER BY ut_online.online_time ASC";
478 if ($this->order_dir !==
"asc" && $this->order_dir !==
"desc") {
479 $this->order_dir =
"asc";
481 if (substr($this->order_field, 0, 4) ===
"udf_") {
484 $query .=
" ORDER BY ud_" . ((
int) substr($this->order_field, 4)) .
".value " . strtoupper($this->order_dir);
486 $query .=
' ORDER BY ' . self::DEFAULT_ORDER_FIELD .
' ' . strtoupper($this->order_dir);
489 if (!in_array($this->order_field, $this->default_fields)) {
490 $this->order_field =
"login";
492 $query .=
" ORDER BY usr_data." . $this->order_field .
" " . strtoupper($this->order_dir);
498 $set =
$ilDB->query($count_query);
500 if ($rec =
$ilDB->fetchAssoc($set)) {
508 if ($offset >= $cnt) {
512 $ilDB->setLimit($limit, $offset);
514 if (count($multi_fields)) {
522 while ($rec =
$ilDB->fetchAssoc($set)) {
524 if (count($multi_fields)) {
525 $usr_ids[] = (
int) $rec[
"usr_id"];
530 if (count($multi_fields) && count($usr_ids)) {
531 $usr_multi = array();
532 $set =
$ilDB->query(
"SELECT * FROM usr_data_multi" .
533 " WHERE " .
$ilDB->in(
"usr_id", $usr_ids,
"",
"integer"));
534 while ($row =
$ilDB->fetchAssoc($set)) {
535 $usr_multi[(
int) $row[
"usr_id"]][$row[
"field_id"]][] = $row[
"value"];
537 foreach ($result as $idx => $item) {
538 if (isset($usr_multi[$item[
"usr_id"]])) {
539 $result[$idx] = array_merge($item, $usr_multi[(
int) $item[
"usr_id"]]);
543 return array(
"cnt" => $cnt,
"set" => $result);
552 string $a_order_field,
556 string $a_string_filter =
"",
557 string $a_activation_filter =
"",
559 bool $a_limited_access_filter =
false,
560 bool $a_no_courses_filter =
false,
561 int $a_course_group_filter = 0,
562 int $a_role_filter = 0,
563 array $a_user_folder_filter = null,
564 array $a_additional_fields = null,
565 array $a_user_filter = null,
566 string $a_first_letter =
"",
567 string $a_authentication_filter =
"" 570 $query->setOrderField($a_order_field);
571 $query->setOrderDirection($a_order_dir);
572 $query->setOffset($a_offset);
573 $query->setLimit($a_limit);
574 $query->setTextFilter($a_string_filter);
575 $query->setActionFilter($a_activation_filter);
576 $query->setLastLogin($a_last_login_filter);
577 $query->setLimitedAccessFilter($a_limited_access_filter);
578 $query->setNoCourseFilter($a_no_courses_filter);
579 $query->setCourseGroupFilter($a_course_group_filter);
580 $query->setRoleFilter($a_role_filter);
581 $query->setUserFolder($a_user_folder_filter);
582 $query->setAdditionalFields($a_additional_fields ?? []);
583 $query->setUserFilter($a_user_filter ?? []);
584 $query->setFirstLetterLastname($a_first_letter);
585 $query->setAuthenticationFilter($a_authentication_filter);
setOrderField(string $a_order)
Set order field (column in usr_data) Default order is 'login'.
setNoCourseFilter(bool $a_no_course)
setRoleFilter(int $a_role_id)
Set role filter obj_id of role.
getUdfFilter()
Get udf filter.
setLimitedAccessFilter(bool $a_status)
Enable limited access filter.
string $authentication_method
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setAdditionalFields(array $a_add)
Set additional fields (columns in usr_data or 'online_time')
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
setFirstLetterLastname(string $a_fll)
set first letter lastname filter
setTextFilter(string $a_filter)
Text (like) filter in login, firstname, lastname or email.
setUserFolder(?array $a_fold_id)
Set user folder filter reference id of user folder or category (local user administration) ...
const DEFAULT_ORDER_FIELD
setUserFilter(array $a_filter)
Array with user ids to query against.
setOrderDirection(string $a_dir)
Set order direction 'asc' or 'desc' Default is 'asc'.
setCourseGroupFilter(int $a_cg_id)
Set course / group filter object_id of course or group.
const UDF_TYPE_TEXT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setActionFilter(string $a_activation)
Set activation filter 'active' or 'inactive' or empty.
setUdfFilter(array $a_val)
Set udf filter.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
setAccessFilter(bool $a_access)
set filter for user that are limited but has access
static _lookupType(int $id, bool $reference=false)
static getUserListData(string $a_order_field, string $a_order_dir, int $a_offset, int $a_limit, string $a_string_filter="", string $a_activation_filter="", ?ilDateTime $a_last_login_filter=null, bool $a_limited_access_filter=false, bool $a_no_courses_filter=false, int $a_course_group_filter=0, int $a_role_filter=0, array $a_user_folder_filter=null, array $a_additional_fields=null, array $a_user_filter=null, string $a_first_letter="", string $a_authentication_filter="")
Get data for user administration list.
setLastLogin(ilDateTime $dt=null)
Set last login filter.
setAuthenticationFilter(string $a_authentication)
Set authentication filter.
setNoGroupFilter(bool $a_no_group)