39 "time_limit_unlimited",
60 $this->order_field = $a_order;
71 $this->order_dir = $a_dir;
80 $this->offset = $a_offset;
90 $this->limit = $a_limit;
99 $this->text_filter = $a_filter;
109 $this->activation = $a_activation;
118 $this->last_login = $dt;
127 $this->limited_access = $a_status;
136 $this->no_courses = $a_no_course;
145 $this->no_groups = $a_no_group;
155 $this->crs_grp = $a_cg_id;
165 $this->role = $a_role_id;
175 $this->user_folder = $a_fold_id;
184 $this->additional_fields = (
array) $a_add;
193 $this->users = $a_filter;
202 $this->first_letter = $a_fll;
212 $this->has_access = (bool) $a_access;
224 if (is_array($this->additional_fields))
226 foreach ($this->additional_fields as $f)
228 if (!in_array($f, $this->default_fields))
230 if($f ==
"online_time")
232 $this->default_fields[] =
"ut_online.online_time";
233 $ut_join =
" LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id";
237 $this->default_fields[] = $f;
243 $count_query =
"SELECT count(usr_id) cnt".
246 $all_multi_fields =
array(
"interests_general",
"interests_help_offered",
"interests_help_looking");
247 $multi_fields =
array();
249 $sql_fields =
array();
250 foreach($this->default_fields as $idx => $field)
257 if(in_array($field, $all_multi_fields))
259 $multi_fields[] = $field;
261 else if(!stristr($field,
"."))
263 $sql_fields[] =
"usr_data.".$field;
267 $sql_fields[] = $field;
272 $query =
"SELECT ".implode($sql_fields,
",").
277 $query.=
" WHERE usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
280 if($this->users
and is_array(($this->users)))
282 $query .=
' AND '.$ilDB->in(
'usr_data.usr_id',$this->users,
false,
'integer');
285 $count_query.=
" WHERE usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
288 if ($this->first_letter !=
"")
290 $add = $where.
" (".$ilDB->upper($ilDB->substr(
"usr_data.lastname", 1, 1)).
" = ".$ilDB->upper($ilDB->quote($this->first_letter,
"text")).
") ";
296 if ($this->text_filter !=
"")
298 $add = $where.
" (".$ilDB->like(
"usr_data.login",
"text",
"%".$this->text_filter.
"%").
" ".
299 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$this->text_filter.
"%").
" ".
300 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$this->text_filter.
"%").
" ".
301 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$this->text_filter.
"%").
") ";
307 if ($this->activation !=
"")
309 if ($this->activation ==
"inactive")
311 $add = $where.
" usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
315 $add = $where.
" usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
326 $add = $where.
" usr_data.last_login < ".
333 if ($this->limited_access)
335 $add = $where.
" usr_data.time_limit_unlimited= ".$ilDB->quote(0,
"integer");
341 if($this->has_access)
343 $unlimited =
"time_limit_unlimited = ". $ilDB->quote(1,
'integer');
344 $from =
"time_limit_from < ". $ilDB->quote(
time(),
'integer');
345 $until =
"time_limit_until > ". $ilDB->quote(
time(),
'integer');
347 $add = $where.
' (' .$unlimited.
' OR ('.$from.
' AND ' .$until.
'))';
352 if ($this->no_courses)
354 $add = $where.
" usr_data.usr_id NOT IN (".
355 "SELECT DISTINCT ud.usr_id ".
356 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
357 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
358 "WHERE od.title LIKE 'il_crs_%')";
363 if ($this->no_groups)
365 $add = $where.
" usr_data.usr_id NOT IN (".
366 "SELECT DISTINCT ud.usr_id ".
367 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
368 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
369 "WHERE od.title LIKE 'il_grp_%')";
374 if ($this->crs_grp > 0)
377 $add = $where.
" usr_data.usr_id IN (".
378 "SELECT DISTINCT ud.usr_id ".
379 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
380 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
381 "WHERE od.title = ".$ilDB->quote(
"il_".$cgtype.
"_member_".$this->crs_grp,
"text").
")";
388 $add = $where.
" usr_data.usr_id IN (".
389 "SELECT DISTINCT ud.usr_id ".
390 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
391 "WHERE rbac_ua.rol_id = ".$ilDB->quote($this->role,
"integer").
")";
397 if($this->user_folder)
399 $add = $where.
" ".$ilDB->in(
'usr_data.time_limit_owner',$this->user_folder,
false,
'integer');
406 switch($this->order_field)
409 if ($this->order_dir ==
"desc")
411 $query.=
" ORDER BY usr_data.active DESC, usr_data.time_limit_unlimited DESC, usr_data.time_limit_until DESC";
415 $query.=
" ORDER BY usr_data.active ASC, usr_data.time_limit_unlimited ASC, usr_data.time_limit_until ASC";
420 if ($this->order_dir ==
"desc")
422 $query.=
" ORDER BY ut_online.online_time DESC";
426 $query.=
" ORDER BY ut_online.online_time ASC";
431 if (!in_array($this->order_field, $this->default_fields))
433 $this->order_field =
"login";
435 if ($this->order_dir !=
"asc" && $this->order_dir !=
"desc")
437 $this->order_dir =
"asc";
439 $query .=
" ORDER BY usr_data.".$this->order_field.
" ".strtoupper($this->order_dir);
444 $set = $ilDB->query($count_query);
446 if ($rec = $ilDB->fetchAssoc($set))
452 $limit = (int) $this->limit;
462 if(
sizeof($multi_fields))
468 $set = $ilDB->query(
$query);
470 while($rec = $ilDB->fetchAssoc($set))
474 if(
sizeof($multi_fields))
476 $usr_ids[] = $rec[
"usr_id"];
481 if(
sizeof($multi_fields) &&
sizeof($usr_ids))
483 $usr_multi =
array();
484 $set = $ilDB->query(
"SELECT * FROM usr_data_multi".
485 " WHERE ".$ilDB->in(
"usr_id", $usr_ids,
"",
"integer"));
486 while(
$row = $ilDB->fetchAssoc($set))
488 $usr_multi[
$row[
"usr_id"]][
$row[
"field_id"]][] = $row[
"value"];
490 foreach(
$result as $idx => $item)
492 if(isset($usr_multi[$item[
"usr_id"]]))
494 $result[$idx] = array_merge($item, $usr_multi[$item[
"usr_id"]]);
507 public static function getUserListData($a_order_field, $a_order_dir, $a_offset, $a_limit,
508 $a_string_filter =
"", $a_activation_filter =
"", $a_last_login_filter = null,
509 $a_limited_access_filter =
false, $a_no_courses_filter =
false,
510 $a_course_group_filter = 0, $a_role_filter = 0, $a_user_folder_filter = null,
511 $a_additional_fields =
'', $a_user_filter = null, $a_first_letter =
"")
515 $query->setOrderField($a_order_field);
516 $query->setOrderDirection($a_order_dir);
517 $query->setOffset($a_offset);
518 $query->setLimit($a_limit);
519 $query->setTextFilter($a_string_filter);
520 $query->setActionFilter($a_activation_filter);
521 $query->setLastLogin($a_last_login_filter);
522 $query->setLimitedAccessFilter($a_limited_access_filter);
523 $query->setNoCourseFilter($a_no_courses_filter);
524 $query->setCourseGroupFilter($a_course_group_filter);
525 $query->setRoleFilter($a_role_filter);
526 $query->setUserFolder($a_user_folder_filter);
527 $query->setAdditionalFields($a_additional_fields);
528 $query->setUserFilter($a_user_filter);
529 $query->setFirstLetterLastname($a_first_letter);
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="")
Get data for user administration list.
setFirstLetterLastname($a_fll)
set first letter lastname 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.
setUserFilter($a_filter)
Array with user ids to query against.
__construct()
Constructor.
setActionFilter($a_activation)
Set activation filter 'active' or 'inactive' or empty.
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'.
setLimitedAccessFilter($a_status)
Enable limited access filter.
setLastLogin(ilDateTime $dt=NULL)
Set last login 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) ...
setAdditionalFields($a_add)
Set additional fields (columns in usr_data or 'online_time')