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'];
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 ($f ===
'dpro_agreed_on') {
256 $this->default_fields[] =
'dpro.dpro_agreed_on';
257 $join =
' LEFT JOIN (SELECT value AS dpro_agreed_on, usr_id FROM usr_pref WHERE keyword = "dpro_agree_date") AS dpro' .
258 ' ON (usr_data.usr_id = dpro.usr_id)';
259 } elseif (substr($f, 0, 4) ===
"udf_") {
260 $udf_fields[] = (
int) substr($f, 4);
262 $this->default_fields[] =
$f;
270 if (count($udf_fields) > 0) {
275 foreach ($udf_fields as
$id) {
279 $join .=
" LEFT JOIN " . $udf_table .
" ud_" . $id .
" ON (ud_" . $id .
".field_id=" .
$ilDB->quote($id) .
" AND ud_" . $id .
".usr_id = usr_data.usr_id) ";
283 $count_query =
"SELECT count(usr_data.usr_id) cnt" .
286 $all_multi_fields = [
"interests_general",
"interests_help_offered",
"interests_help_looking"];
290 foreach ($this->default_fields as $idx => $field) {
295 if (in_array($field, $all_multi_fields)) {
296 $multi_fields[] = $field;
297 } elseif (strpos($field,
".") ===
false) {
298 $sql_fields[] =
"usr_data." . $field;
300 $sql_fields[] = $field;
305 foreach ($udf_fields as $id) {
306 $sql_fields[] =
"ud_" . $id .
".value udf_" .
$id;
310 $query =
"SELECT " . implode(
",", $sql_fields) .
314 $count_query .=
" " . $join;
320 $count_query .=
" WHERE 1 = 1 ";
322 if ($this->users && is_array(($this->users))) {
323 $query .=
' AND ' .
$ilDB->in(
'usr_data.usr_id', $this->users,
false,
'integer');
324 $count_user_filter =
$ilDB->in(
'usr_data.usr_id', $this->users,
false,
'integer');
327 $count_query .=
" AND " . $count_user_filter .
" ";
330 if ($this->first_letter !=
"") {
331 $add = $where .
" (" .
$ilDB->upper(
$ilDB->substr(
"usr_data.lastname", 1, 1)) .
" = " .
$ilDB->upper(
$ilDB->quote($this->first_letter,
"text")) .
") ";
333 $count_query .= $add;
337 if ($this->text_filter !=
"") {
338 $add = $where .
" (" .
$ilDB->like(
"usr_data.login",
"text",
"%" . $this->text_filter .
"%") .
" " .
339 "OR " .
$ilDB->like(
"usr_data.firstname",
"text",
"%" . $this->text_filter .
"%") .
" " .
340 "OR " .
$ilDB->like(
"usr_data.lastname",
"text",
"%" . $this->text_filter .
"%") .
" " .
341 "OR " .
$ilDB->like(
"usr_data.second_email",
"text",
"%" . $this->text_filter .
"%") .
" " .
342 "OR " .
$ilDB->like(
"usr_data.email",
"text",
"%" . $this->text_filter .
"%") .
") ";
344 $count_query .= $add;
348 if ($this->activation !=
"") {
349 if ($this->activation ===
"inactive") {
350 $add = $where .
" usr_data.active = " .
$ilDB->quote(0,
"integer") .
" ";
352 $add = $where .
" usr_data.active = " .
$ilDB->quote(1,
"integer") .
" ";
355 $count_query .= $add;
359 if ($this->last_login instanceof
ilDateTime) {
361 $add = $where .
" usr_data.last_login < " .
364 $count_query .= $add;
368 if ($this->limited_access) {
369 $add = $where .
" usr_data.time_limit_unlimited= " .
$ilDB->quote(0,
"integer");
371 $count_query .= $add;
378 $udf_id = explode(
"_", $k)[1];
380 $add = $where .
" " .
$ilDB->like(
"ud_" . $udf_id .
".value",
"text",
"%" .
$f .
"%");
382 $add = $where .
" ud_" . $udf_id .
".value = " .
$ilDB->quote(
$f,
"text");
385 $count_query .= $add;
390 if ($this->has_access) {
391 $unlimited =
"time_limit_unlimited = " .
$ilDB->quote(1,
'integer');
392 $from =
"time_limit_from < " .
$ilDB->quote(time(),
'integer');
393 $until =
"time_limit_until > " .
$ilDB->quote(time(),
'integer');
395 $add = $where .
' (' . $unlimited .
' OR (' . $from .
' AND ' . $until .
'))';
397 $count_query .= $add;
400 if ($this->no_courses) {
401 $add = $where .
" usr_data.usr_id NOT IN (" .
402 "SELECT DISTINCT ud.usr_id " .
403 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
404 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
405 "JOIN rbac_fa ON (rbac_ua.rol_id = rbac_fa.rol_id) " .
406 "JOIN tree ON (rbac_fa.parent = tree.child) " .
407 "WHERE od.title LIKE 'il_crs_%' " .
408 "AND rbac_fa.assign = 'y' " .
409 "AND tree.tree > 0)";
411 $count_query .= $add;
414 if ($this->no_groups) {
415 $add = $where .
" usr_data.usr_id NOT IN (" .
416 "SELECT DISTINCT ud.usr_id " .
417 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
418 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
419 "JOIN rbac_fa ON (rbac_ua.rol_id = rbac_fa.rol_id) " .
420 "JOIN tree ON (rbac_fa.parent = tree.child) " .
421 "WHERE od.title LIKE 'il_grp_%' " .
422 "AND rbac_fa.assign = 'y' " .
423 "AND tree.tree > 0)";
425 $count_query .= $add;
428 if ($this->crs_grp > 0) {
430 $add = $where .
" usr_data.usr_id IN (" .
431 "SELECT DISTINCT ud.usr_id " .
432 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
433 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
434 "WHERE od.title = " .
$ilDB->quote(
"il_" . $cgtype .
"_member_" . $this->crs_grp,
"text") .
")";
436 $count_query .= $add;
439 if ($this->role > 0) {
440 $add = $where .
" usr_data.usr_id IN (" .
441 "SELECT DISTINCT ud.usr_id " .
442 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
443 "WHERE rbac_ua.rol_id = " .
$ilDB->quote($this->role,
"integer") .
")";
445 $count_query .= $add;
449 if ($this->user_folder) {
450 $add = $where .
" " .
$ilDB->in(
'usr_data.time_limit_owner', $this->user_folder,
false,
'integer');
452 $count_query .= $add;
456 if ($this->authentication_method !=
"") {
457 $add = $where .
" usr_data.auth_mode = " .
$ilDB->quote($this->authentication_method,
"text") .
" ";
459 $count_query .= $add;
464 switch ($this->order_field) {
466 if ($this->order_dir ===
"desc") {
467 $query .=
" ORDER BY usr_data.active DESC, usr_data.time_limit_unlimited DESC, usr_data.time_limit_until DESC";
469 $query .=
" ORDER BY usr_data.active ASC, usr_data.time_limit_unlimited ASC, usr_data.time_limit_until ASC";
474 if ($this->order_dir ===
"desc") {
475 $query .=
" ORDER BY ut_online.online_time DESC";
477 $query .=
" ORDER BY ut_online.online_time ASC";
482 if ($this->order_dir !==
"asc" && $this->order_dir !==
"desc") {
483 $this->order_dir =
"asc";
485 if (substr($this->order_field, 0, 4) ===
"udf_") {
488 $query .=
" ORDER BY ud_" . ((
int) substr($this->order_field, 4)) .
".value " . strtoupper($this->order_dir);
490 $query .=
' ORDER BY ' . self::DEFAULT_ORDER_FIELD .
' ' . strtoupper($this->order_dir);
493 if (!in_array($this->order_field, $this->default_fields)) {
494 $this->order_field =
"login";
496 $query .=
" ORDER BY usr_data." . $this->order_field .
" " . strtoupper($this->order_dir);
502 $set =
$ilDB->query($count_query);
504 if ($rec =
$ilDB->fetchAssoc($set)) {
512 if ($offset >= $cnt) {
516 $ilDB->setLimit($limit, $offset);
518 if (count($multi_fields)) {
523 $set =
$ilDB->query($query);
526 while ($rec =
$ilDB->fetchAssoc($set)) {
528 if (count($multi_fields)) {
529 $usr_ids[] = (
int) $rec[
"usr_id"];
534 if (count($multi_fields) && count($usr_ids)) {
536 $set =
$ilDB->query(
"SELECT * FROM usr_data_multi" .
537 " WHERE " .
$ilDB->in(
"usr_id", $usr_ids,
"",
"integer"));
538 while ($row =
$ilDB->fetchAssoc($set)) {
539 $usr_multi[(
int) $row[
"usr_id"]][$row[
"field_id"]][] = $row[
"value"];
541 foreach ($result as $idx => $item) {
542 if (isset($usr_multi[$item[
"usr_id"]])) {
543 $result[$idx] = array_merge($item, $usr_multi[(
int) $item[
"usr_id"]]);
547 return [
"cnt" => $cnt,
"set" => $result];
556 string $a_order_field,
560 string $a_string_filter =
"",
561 string $a_activation_filter =
"",
563 bool $a_limited_access_filter =
false,
564 bool $a_no_courses_filter =
false,
565 int $a_course_group_filter = 0,
566 int $a_role_filter = 0,
567 ?array $a_user_folder_filter =
null,
568 ?array $a_additional_fields =
null,
569 ?array $a_user_filter =
null,
570 string $a_first_letter =
"",
571 string $a_authentication_filter =
"" 574 $query->setOrderField($a_order_field);
575 $query->setOrderDirection($a_order_dir);
576 $query->setOffset($a_offset);
577 $query->setLimit($a_limit);
578 $query->setTextFilter($a_string_filter);
579 $query->setActionFilter($a_activation_filter);
580 $query->setLastLogin($a_last_login_filter);
581 $query->setLimitedAccessFilter($a_limited_access_filter);
582 $query->setNoCourseFilter($a_no_courses_filter);
583 $query->setCourseGroupFilter($a_course_group_filter);
584 $query->setRoleFilter($a_role_filter);
585 $query->setUserFolder($a_user_folder_filter);
586 $query->setAdditionalFields($a_additional_fields ?? []);
587 $query->setUserFilter($a_user_filter ?? []);
588 $query->setFirstLetterLastname($a_first_letter);
589 $query->setAuthenticationFilter($a_authentication_filter);
590 return $query->query();
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
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.
setLastLogin(?ilDateTime $dt=null)
Set last login filter.
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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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)
setAuthenticationFilter(string $a_authentication)
Set authentication filter.
setNoGroupFilter(bool $a_no_group)