53 "time_limit_unlimited",
66 $this->logger = $DIC->logger()->usr();
76 $this->udf_filter = $a_val;
96 $this->order_field = $a_order;
107 $this->order_dir = $a_dir;
116 $this->offset = $a_offset;
126 $this->limit = $a_limit;
135 $this->text_filter = $a_filter;
145 $this->activation = $a_activation;
154 $this->last_login = $dt;
163 $this->limited_access = $a_status;
172 $this->no_courses = $a_no_course;
181 $this->no_groups = $a_no_group;
191 $this->crs_grp = $a_cg_id;
201 $this->role = $a_role_id;
211 $this->user_folder = $a_fold_id;
220 $this->additional_fields = (
array) $a_add;
229 $this->users = $a_filter;
238 $this->first_letter = $a_fll;
248 $this->has_access = (bool) $a_access;
258 $this->authentication_method = $a_authentication;
270 $udf_fields =
array();
274 if (is_array($this->additional_fields)) {
275 foreach ($this->additional_fields as $f) {
276 if (!in_array($f, $this->default_fields)) {
277 if ($f ==
"online_time") {
278 $this->default_fields[] =
"ut_online.online_time";
279 $join =
" LEFT JOIN ut_online ON (usr_data.usr_id = ut_online.usr_id) ";
280 } elseif (substr($f, 0, 4) ==
"udf_") {
281 $udf_fields[] = (int) substr($f, 4);
283 $this->default_fields[] = $f;
291 if (count($udf_fields) > 0) {
292 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
297 foreach ($udf_fields as
$id) {
301 $join.=
" LEFT JOIN " . $udf_table .
" ud_" . $id .
" ON (ud_" . $id .
".field_id=" . $ilDB->quote($id) .
" AND ud_" . $id .
".usr_id = usr_data.usr_id) ";
305 $count_query =
"SELECT count(usr_data.usr_id) cnt" .
308 $all_multi_fields =
array(
"interests_general",
"interests_help_offered",
"interests_help_looking");
309 $multi_fields =
array();
311 $sql_fields =
array();
312 foreach ($this->default_fields as $idx => $field) {
317 if (in_array($field, $all_multi_fields)) {
318 $multi_fields[] = $field;
319 } elseif (!stristr($field,
".")) {
320 $sql_fields[] =
"usr_data." . $field;
322 $sql_fields[] = $field;
327 foreach ($udf_fields as $id) {
328 $sql_fields[] =
"ud_" . $id .
".value udf_" .
$id;
332 $query =
"SELECT " . implode($sql_fields,
",") .
336 $count_query = $count_query .
" " .
340 $query.=
" WHERE usr_data.usr_id <> " . $ilDB->quote(ANONYMOUS_USER_ID,
"integer");
343 $count_query.=
" WHERE 1 = 1 ";
344 $count_user_filter =
"usr_data.usr_id != " . $ilDB->quote(ANONYMOUS_USER_ID,
"integer");
345 if ($this->users and is_array(($this->users))) {
346 $query .=
' AND ' . $ilDB->in(
'usr_data.usr_id', $this->users,
false,
'integer');
347 $count_user_filter = $ilDB->in(
'usr_data.usr_id', $this->users,
false,
'integer');
350 $count_query.=
" AND " . $count_user_filter .
" ";
353 if ($this->first_letter !=
"") {
354 $add = $where .
" (" . $ilDB->upper($ilDB->substr(
"usr_data.lastname", 1, 1)) .
" = " . $ilDB->upper($ilDB->quote($this->first_letter,
"text")) .
") ";
360 if ($this->text_filter !=
"") {
361 $add = $where .
" (" . $ilDB->like(
"usr_data.login",
"text",
"%" . $this->text_filter .
"%") .
" " .
362 "OR " . $ilDB->like(
"usr_data.firstname",
"text",
"%" . $this->text_filter .
"%") .
" " .
363 "OR " . $ilDB->like(
"usr_data.lastname",
"text",
"%" . $this->text_filter .
"%") .
" " .
364 "OR " . $ilDB->like(
"usr_data.second_email",
"text",
"%" . $this->text_filter .
"%") .
" " .
365 "OR " . $ilDB->like(
"usr_data.email",
"text",
"%" . $this->text_filter .
"%") .
") ";
371 if ($this->activation !=
"") {
372 if ($this->activation ==
"inactive") {
373 $add = $where .
" usr_data.active = " . $ilDB->quote(0,
"integer") .
" ";
375 $add = $where .
" usr_data.active = " . $ilDB->quote(1,
"integer") .
" ";
382 if ($this->last_login instanceof
ilDateTime) {
384 $add = $where .
" usr_data.last_login < " .
391 if ($this->limited_access) {
392 $add = $where .
" usr_data.time_limit_unlimited= " . $ilDB->quote(0,
"integer");
401 $udf_id = explode(
"_", $k)[1];
403 $add = $where .
" " . $ilDB->like(
"ud_" . $udf_id .
".value",
"text",
"%" . $f .
"%");
405 $add = $where .
" ud_" . $udf_id .
".value = " . $ilDB->quote($f,
"text");
413 if ($this->has_access) {
414 $unlimited =
"time_limit_unlimited = " . $ilDB->quote(1,
'integer');
415 $from =
"time_limit_from < " . $ilDB->quote(
time(),
'integer');
416 $until =
"time_limit_until > " . $ilDB->quote(
time(),
'integer');
418 $add = $where .
' (' . $unlimited .
' OR (' .
$from .
' AND ' . $until .
'))';
423 if ($this->no_courses) {
424 $add = $where .
" usr_data.usr_id NOT IN (" .
425 "SELECT DISTINCT ud.usr_id " .
426 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
427 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
428 "WHERE od.title LIKE 'il_crs_%')";
433 if ($this->no_groups) {
434 $add = $where .
" usr_data.usr_id NOT IN (" .
435 "SELECT DISTINCT ud.usr_id " .
436 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
437 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
438 "WHERE od.title LIKE 'il_grp_%')";
443 if ($this->crs_grp > 0) {
445 $add = $where .
" usr_data.usr_id IN (" .
446 "SELECT DISTINCT ud.usr_id " .
447 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
448 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
449 "WHERE od.title = " . $ilDB->quote(
"il_" . $cgtype .
"_member_" . $this->crs_grp,
"text") .
")";
454 if ($this->role > 0) {
455 $add = $where .
" usr_data.usr_id IN (" .
456 "SELECT DISTINCT ud.usr_id " .
457 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
458 "WHERE rbac_ua.rol_id = " . $ilDB->quote($this->role,
"integer") .
")";
464 if ($this->user_folder) {
465 $add = $where .
" " . $ilDB->in(
'usr_data.time_limit_owner', $this->user_folder,
false,
'integer');
471 if ($this->authentication_method !=
"") {
472 $add = $where .
" usr_data.auth_mode = " . $ilDB->quote($this->authentication_method,
"text") .
" ";
479 switch ($this->order_field) {
481 if ($this->order_dir ==
"desc") {
482 $query.=
" ORDER BY usr_data.active DESC, usr_data.time_limit_unlimited DESC, usr_data.time_limit_until DESC";
484 $query.=
" ORDER BY usr_data.active ASC, usr_data.time_limit_unlimited ASC, usr_data.time_limit_until ASC";
489 if ($this->order_dir ==
"desc") {
490 $query.=
" ORDER BY ut_online.online_time DESC";
492 $query.=
" ORDER BY ut_online.online_time ASC";
497 if ($this->order_dir !=
"asc" && $this->order_dir !=
"desc") {
498 $this->order_dir =
"asc";
500 if (substr($this->order_field, 0, 4) ==
"udf_") {
503 $query .=
" ORDER BY ud_" . ((int) substr($this->order_field, 4)) .
".value " . strtoupper($this->order_dir);
505 $query .=
' ORDER BY ' . self::DEFAULT_ORDER_FIELD .
' ' . strtoupper($this->order_dir);
508 if (!in_array($this->order_field, $this->default_fields)) {
509 $this->order_field =
"login";
511 $query .=
" ORDER BY usr_data." . $this->order_field .
" " . strtoupper($this->order_dir);
517 $set = $ilDB->query($count_query);
519 if ($rec = $ilDB->fetchAssoc($set)) {
524 $limit = (int) $this->limit;
533 if (
sizeof($multi_fields)) {
538 $set = $ilDB->query(
$query);
540 while ($rec = $ilDB->fetchAssoc($set)) {
543 if (
sizeof($multi_fields)) {
544 $usr_ids[] = $rec[
"usr_id"];
549 if (
sizeof($multi_fields) &&
sizeof($usr_ids)) {
550 $usr_multi =
array();
551 $set = $ilDB->query(
"SELECT * FROM usr_data_multi" .
552 " WHERE " . $ilDB->in(
"usr_id", $usr_ids,
"",
"integer"));
553 while (
$row = $ilDB->fetchAssoc($set)) {
554 $usr_multi[
$row[
"usr_id"]][
$row[
"field_id"]][] = $row[
"value"];
556 foreach (
$result as $idx => $item) {
557 if (isset($usr_multi[$item[
"usr_id"]])) {
558 $result[$idx] = array_merge($item, $usr_multi[$item[
"usr_id"]]);
576 $a_string_filter =
"",
577 $a_activation_filter =
"",
578 $a_last_login_filter = null,
579 $a_limited_access_filter =
false,
580 $a_no_courses_filter =
false,
581 $a_course_group_filter = 0,
583 $a_user_folder_filter = null,
584 $a_additional_fields =
'',
585 $a_user_filter = null,
586 $a_first_letter =
"",
587 $a_authentication_filter = null
590 $query->setOrderField($a_order_field);
591 $query->setOrderDirection($a_order_dir);
592 $query->setOffset($a_offset);
593 $query->setLimit($a_limit);
594 $query->setTextFilter($a_string_filter);
595 $query->setActionFilter($a_activation_filter);
596 $query->setLastLogin($a_last_login_filter);
597 $query->setLimitedAccessFilter($a_limited_access_filter);
598 $query->setNoCourseFilter($a_no_courses_filter);
599 $query->setCourseGroupFilter($a_course_group_filter);
600 $query->setRoleFilter($a_role_filter);
601 $query->setUserFolder($a_user_folder_filter);
602 $query->setAdditionalFields($a_additional_fields);
603 $query->setUserFilter($a_user_filter);
604 $query->setFirstLetterLastname($a_first_letter);
605 $query->setAuthenticationFilter($a_authentication_filter);
getUdfFilter()
Get udf filter.
static _getInstance()
Get instance.
setFirstLetterLastname($a_fll)
set first letter lastname filter
setUdfFilter($a_val)
Set udf filter.
setOffset($a_offset)
Set offset.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
setCourseGroupFilter($a_cg_id)
Set course / group filter object_id of course or group.
setRoleFilter($a_role_id)
Set role filter obj_id of role.
setNoCourseFilter($a_no_course)
Enable no course filter.
if(!array_key_exists('StateId', $_REQUEST)) $id
setUserFilter($a_filter)
Array with user ids to query against.
__construct()
Constructor.
setActionFilter($a_activation)
Set activation filter 'active' or 'inactive' or empty.
const DEFAULT_ORDER_FIELD
setAccessFilter($a_access)
set filter for user that are limited but has access
setOrderField($a_order)
Set order field (column in usr_data) Default order is 'login'.
setAuthenticationFilter($a_authentication)
Set authentication filter 'default', 'local' or 'lti'.
setLimitedAccessFilter($a_status)
Enable limited access filter.
setNoGroupFilter($a_no_group)
Enable no group filter.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
setOrderDirection($a_dir)
Set order direction 'asc' or 'desc' Default is 'asc'.
setLimit($a_limit)
Set result limit Default is 50.
setTextFilter($a_filter)
Text (like) filter in login, firstname, lastname or email.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
setUserFolder($a_fold_id)
Set user folder filter reference id of user folder or category (local user administration) ...
setLastLogin(ilDateTime $dt=null)
Set last login filter.
setAdditionalFields($a_add)
Set additional fields (columns in usr_data or 'online_time')
static getUserListData( $a_order_field, $a_order_dir, $a_offset, $a_limit, $a_string_filter="", $a_activation_filter="", $a_last_login_filter=null, $a_limited_access_filter=false, $a_no_courses_filter=false, $a_course_group_filter=0, $a_role_filter=0, $a_user_folder_filter=null, $a_additional_fields='', $a_user_filter=null, $a_first_letter="", $a_authentication_filter=null)
Get data for user administration list.