Query usr_data.
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"]]);
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
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.