38 "time_limit_unlimited",
59 $this->order_field = $a_order;
70 $this->order_dir = $a_dir;
79 $this->offset = $a_offset;
89 $this->limit = $a_limit;
98 $this->text_filter = $a_filter;
108 $this->activation = $a_activation;
117 $this->last_login = $dt;
126 $this->limited_access = $a_status;
135 $this->no_courses = $a_no_course;
144 $this->no_groups = $a_no_group;
154 $this->crs_grp = $a_cg_id;
164 $this->role = $a_role_id;
174 $this->user_folder = $a_fold_id;
183 $this->additional_fields = (array) $a_add;
192 $this->users = $a_filter;
201 $this->first_letter = $a_fll;
213 if (is_array($this->additional_fields))
215 foreach ($this->additional_fields as $f)
217 if (!in_array($f, $this->default_fields))
219 if($f ==
"online_time")
221 $this->default_fields[] =
"ut_online.online_time";
222 $ut_join =
" LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id";
226 $this->default_fields[] = $f;
232 $count_query =
"SELECT count(usr_id) cnt".
235 $all_multi_fields = array(
"interests_general",
"interests_help_offered",
"interests_help_looking");
236 $multi_fields = array();
238 $sql_fields = array();
239 foreach($this->default_fields as $idx => $field)
246 if(in_array($field, $all_multi_fields))
248 $multi_fields[] = $field;
250 else if(!stristr($field,
"."))
252 $sql_fields[] =
"usr_data.".$field;
256 $sql_fields[] = $field;
261 $query =
"SELECT ".implode($sql_fields,
",").
266 $query.=
" WHERE usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
269 if($this->users and is_array(($this->users)))
271 $query .=
' AND '.$ilDB->in(
'usr_data.usr_id',$this->users,
false,
'integer');
274 $count_query.=
" WHERE usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
277 if ($this->first_letter !=
"")
279 $add = $where.
" (".$ilDB->upper($ilDB->substr(
"usr_data.lastname", 1, 1)).
" = ".$ilDB->upper($ilDB->quote($this->first_letter,
"text")).
") ";
285 if ($this->text_filter !=
"")
287 $add = $where.
" (".$ilDB->like(
"usr_data.login",
"text",
"%".$this->text_filter.
"%").
" ".
288 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$this->text_filter.
"%").
" ".
289 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$this->text_filter.
"%").
" ".
290 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$this->text_filter.
"%").
") ";
296 if ($this->activation !=
"")
298 if ($this->activation ==
"inactive")
300 $add = $where.
" usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
304 $add = $where.
" usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
315 $add = $where.
" usr_data.last_login < ".
322 if ($this->limited_access)
324 $add = $where.
" usr_data.time_limit_unlimited= ".$ilDB->quote(0,
"integer");
329 if ($this->no_courses)
331 $add = $where.
" usr_data.usr_id NOT IN (".
332 "SELECT DISTINCT ud.usr_id ".
333 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
334 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
335 "WHERE od.title LIKE 'il_crs_%')";
340 if ($this->no_groups)
342 $add = $where.
" usr_data.usr_id NOT IN (".
343 "SELECT DISTINCT ud.usr_id ".
344 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
345 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
346 "WHERE od.title LIKE 'il_grp_%')";
351 if ($this->crs_grp > 0)
354 $add = $where.
" usr_data.usr_id 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 = ".$ilDB->quote(
"il_".$cgtype.
"_member_".$this->crs_grp,
"text").
")";
365 $add = $where.
" usr_data.usr_id IN (".
366 "SELECT DISTINCT ud.usr_id ".
367 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
368 "WHERE rbac_ua.rol_id = ".$ilDB->quote($this->role,
"integer").
")";
374 if($this->user_folder)
376 $add = $where.
" ".$ilDB->in(
'usr_data.time_limit_owner',$this->user_folder,
false,
'integer');
383 switch($this->order_field)
386 if ($this->order_dir ==
"desc")
388 $query.=
" ORDER BY usr_data.active DESC, usr_data.time_limit_unlimited DESC, usr_data.time_limit_until DESC";
392 $query.=
" ORDER BY usr_data.active ASC, usr_data.time_limit_unlimited ASC, usr_data.time_limit_until ASC";
397 if ($this->order_dir ==
"desc")
399 $query.=
" ORDER BY ut_online.online_time DESC";
403 $query.=
" ORDER BY ut_online.online_time ASC";
408 if (!in_array($this->order_field, $this->default_fields))
410 $this->order_field =
"login";
412 if ($this->order_dir !=
"asc" && $this->order_dir !=
"desc")
414 $this->order_dir =
"asc";
416 $query .=
" ORDER BY usr_data.".$this->order_field.
" ".strtoupper($this->order_dir);
421 $set = $ilDB->query($count_query);
423 if ($rec = $ilDB->fetchAssoc($set))
429 $limit = (int) $this->limit;
439 if(
sizeof($multi_fields))
445 $set = $ilDB->query(
$query);
447 while($rec = $ilDB->fetchAssoc($set))
451 if(
sizeof($multi_fields))
453 $usr_ids[] = $rec[
"usr_id"];
458 if(
sizeof($multi_fields) &&
sizeof($usr_ids))
460 $usr_multi = array();
461 $set = $ilDB->query(
"SELECT * FROM usr_data_multi".
462 " WHERE ".$ilDB->in(
"usr_id", $usr_ids,
"",
"integer"));
463 while(
$row = $ilDB->fetchAssoc($set))
465 $usr_multi[
$row[
"usr_id"]][
$row[
"field_id"]][] = $row[
"value"];
467 foreach(
$result as $idx => $item)
469 if(isset($usr_multi[$item[
"usr_id"]]))
471 $result[$idx] = array_merge($item, $usr_multi[$item[
"usr_id"]]);
476 return array(
"cnt" => $cnt,
"set" =>
$result);
484 public static function getUserListData($a_order_field, $a_order_dir, $a_offset, $a_limit,
485 $a_string_filter =
"", $a_activation_filter =
"", $a_last_login_filter = null,
486 $a_limited_access_filter =
false, $a_no_courses_filter =
false,
487 $a_course_group_filter = 0, $a_role_filter = 0, $a_user_folder_filter = null,
488 $a_additional_fields =
'', $a_user_filter = null, $a_first_letter =
"")
492 $query->setOrderField($a_order_field);
493 $query->setOrderDirection($a_order_dir);
494 $query->setOffset($a_offset);
495 $query->setLimit($a_limit);
496 $query->setTextFilter($a_string_filter);
497 $query->setActionFilter($a_activation_filter);
498 $query->setLastLogin($a_last_login_filter);
499 $query->setLimitedAccessFilter($a_limited_access_filter);
500 $query->setNoCourseFilter($a_no_courses_filter);
501 $query->setCourseGroupFilter($a_course_group_filter);
502 $query->setRoleFilter($a_role_filter);
503 $query->setUserFolder($a_user_folder_filter);
504 $query->setAdditionalFields($a_additional_fields);
505 $query->setUserFilter($a_user_filter);
506 $query->setFirstLetterLastname($a_first_letter);