Query usr_data.
278 $ilDB = $DIC[
'ilDB'];
281 $udf_fields = array();
285 if (is_array($this->additional_fields)) {
286 foreach ($this->additional_fields as
$f) {
287 if (!in_array($f, $this->default_fields)) {
288 if ($f ==
"online_time") {
289 $this->default_fields[] =
"ut_online.online_time";
290 $join =
" LEFT JOIN ut_online ON (usr_data.usr_id = ut_online.usr_id) ";
291 } elseif (substr($f, 0, 4) ==
"udf_") {
292 $udf_fields[] = (int) substr($f, 4);
294 $this->default_fields[] =
$f;
302 if (count($udf_fields) > 0) {
303 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
308 foreach ($udf_fields as
$id) {
312 $join .=
" LEFT JOIN " . $udf_table .
" ud_" . $id .
" ON (ud_" . $id .
".field_id=" .
$ilDB->quote($id) .
" AND ud_" . $id .
".usr_id = usr_data.usr_id) ";
316 $count_query =
"SELECT count(usr_data.usr_id) cnt" .
319 $all_multi_fields = array(
"interests_general",
"interests_help_offered",
"interests_help_looking");
320 $multi_fields = array();
322 $sql_fields = array();
323 foreach ($this->default_fields as $idx => $field) {
328 if (in_array($field, $all_multi_fields)) {
329 $multi_fields[] = $field;
330 } elseif (!stristr($field,
".")) {
331 $sql_fields[] =
"usr_data." . $field;
333 $sql_fields[] = $field;
338 foreach ($udf_fields as $id) {
339 $sql_fields[] =
"ud_" . $id .
".value udf_" .
$id;
343 $query =
"SELECT " . implode($sql_fields,
",") .
347 $count_query = $count_query .
" " .
351 $query .=
" WHERE usr_data.usr_id <> " .
$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
354 $count_query .=
" WHERE 1 = 1 ";
355 $count_user_filter =
"usr_data.usr_id != " .
$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
356 if ($this->users
and is_array(($this->users))) {
357 $query .=
' AND ' .
$ilDB->in(
'usr_data.usr_id', $this->users,
false,
'integer');
358 $count_user_filter =
$ilDB->in(
'usr_data.usr_id', $this->users,
false,
'integer');
361 $count_query .=
" AND " . $count_user_filter .
" ";
364 if ($this->first_letter !=
"") {
365 $add = $where .
" (" .
$ilDB->upper(
$ilDB->substr(
"usr_data.lastname", 1, 1)) .
" = " .
$ilDB->upper(
$ilDB->quote($this->first_letter,
"text")) .
") ";
367 $count_query .= $add;
371 if ($this->text_filter !=
"") {
372 $add = $where .
" (" .
$ilDB->like(
"usr_data.login",
"text",
"%" . $this->text_filter .
"%") .
" " .
373 "OR " .
$ilDB->like(
"usr_data.firstname",
"text",
"%" . $this->text_filter .
"%") .
" " .
374 "OR " .
$ilDB->like(
"usr_data.lastname",
"text",
"%" . $this->text_filter .
"%") .
" " .
375 "OR " .
$ilDB->like(
"usr_data.second_email",
"text",
"%" . $this->text_filter .
"%") .
" " .
376 "OR " .
$ilDB->like(
"usr_data.email",
"text",
"%" . $this->text_filter .
"%") .
") ";
378 $count_query .= $add;
382 if ($this->activation !=
"") {
383 if ($this->activation ==
"inactive") {
384 $add = $where .
" usr_data.active = " .
$ilDB->quote(0,
"integer") .
" ";
386 $add = $where .
" usr_data.active = " .
$ilDB->quote(1,
"integer") .
" ";
389 $count_query .= $add;
393 if ($this->last_login instanceof
ilDateTime) {
395 $add = $where .
" usr_data.last_login < " .
398 $count_query .= $add;
402 if ($this->limited_access) {
403 $add = $where .
" usr_data.time_limit_unlimited= " .
$ilDB->quote(0,
"integer");
405 $count_query .= $add;
412 $udf_id = explode(
"_", $k)[1];
414 $add = $where .
" " .
$ilDB->like(
"ud_" . $udf_id .
".value",
"text",
"%" . $f .
"%");
416 $add = $where .
" ud_" . $udf_id .
".value = " .
$ilDB->quote($f,
"text");
419 $count_query .= $add;
424 if ($this->has_access) {
425 $unlimited =
"time_limit_unlimited = " .
$ilDB->quote(1,
'integer');
426 $from =
"time_limit_from < " .
$ilDB->quote(time(),
'integer');
427 $until =
"time_limit_until > " .
$ilDB->quote(time(),
'integer');
429 $add = $where .
' (' . $unlimited .
' OR (' .
$from .
' AND ' . $until .
'))';
431 $count_query .= $add;
434 if ($this->no_courses) {
435 $add = $where .
" usr_data.usr_id NOT IN (" .
436 "SELECT DISTINCT ud.usr_id " .
437 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
438 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
439 "WHERE od.title LIKE 'il_crs_%')";
441 $count_query .= $add;
444 if ($this->no_groups) {
445 $add = $where .
" usr_data.usr_id NOT 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 LIKE 'il_grp_%')";
451 $count_query .= $add;
454 if ($this->crs_grp > 0) {
456 $add = $where .
" usr_data.usr_id IN (" .
457 "SELECT DISTINCT ud.usr_id " .
458 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
459 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) " .
460 "WHERE od.title = " .
$ilDB->quote(
"il_" . $cgtype .
"_member_" . $this->crs_grp,
"text") .
")";
462 $count_query .= $add;
465 if ($this->role > 0) {
466 $add = $where .
" usr_data.usr_id IN (" .
467 "SELECT DISTINCT ud.usr_id " .
468 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) " .
469 "WHERE rbac_ua.rol_id = " .
$ilDB->quote($this->role,
"integer") .
")";
471 $count_query .= $add;
475 if ($this->user_folder) {
476 $add = $where .
" " .
$ilDB->in(
'usr_data.time_limit_owner', $this->user_folder,
false,
'integer');
478 $count_query .= $add;
482 if ($this->authentication_method !=
"") {
483 $add = $where .
" usr_data.auth_mode = " .
$ilDB->quote($this->authentication_method,
"text") .
" ";
485 $count_query .= $add;
490 switch ($this->order_field) {
492 if ($this->order_dir ==
"desc") {
493 $query .=
" ORDER BY usr_data.active DESC, usr_data.time_limit_unlimited DESC, usr_data.time_limit_until DESC";
495 $query .=
" ORDER BY usr_data.active ASC, usr_data.time_limit_unlimited ASC, usr_data.time_limit_until ASC";
500 if ($this->order_dir ==
"desc") {
501 $query .=
" ORDER BY ut_online.online_time DESC";
503 $query .=
" ORDER BY ut_online.online_time ASC";
508 if ($this->order_dir !=
"asc" && $this->order_dir !=
"desc") {
509 $this->order_dir =
"asc";
511 if (substr($this->order_field, 0, 4) ==
"udf_") {
514 $query .=
" ORDER BY ud_" . ((int) substr($this->order_field, 4)) .
".value " . strtoupper($this->order_dir);
516 $query .=
' ORDER BY ' . self::DEFAULT_ORDER_FIELD .
' ' . strtoupper($this->order_dir);
519 if (!in_array($this->order_field, $this->default_fields)) {
520 $this->order_field =
"login";
522 $query .=
" ORDER BY usr_data." . $this->order_field .
" " . strtoupper($this->order_dir);
528 $set =
$ilDB->query($count_query);
530 if ($rec =
$ilDB->fetchAssoc($set)) {
535 $limit = (int) $this->limit;
544 if (
sizeof($multi_fields)) {
552 while ($rec =
$ilDB->fetchAssoc($set)) {
554 if (
sizeof($multi_fields)) {
555 $usr_ids[] = $rec[
"usr_id"];
560 if (
sizeof($multi_fields) &&
sizeof($usr_ids)) {
561 $usr_multi = array();
562 $set =
$ilDB->query(
"SELECT * FROM usr_data_multi" .
563 " WHERE " .
$ilDB->in(
"usr_id", $usr_ids,
"",
"integer"));
565 $usr_multi[
$row[
"usr_id"]][
$row[
"field_id"]][] = $row[
"value"];
567 foreach (
$result as $idx => $item) {
568 if (isset($usr_multi[$item[
"usr_id"]])) {
569 $result[$idx] = array_merge($item, $usr_multi[$item[
"usr_id"]]);
573 return array(
"cnt" => $cnt,
"set" =>
$result);
getUdfFilter()
Get udf filter.
static _getInstance()
Get instance.
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
static _lookupType($a_id, $a_reference=false)
lookup object type