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 $sql_fields = array();
236 foreach($this->default_fields as $idx => $field)
243 if(!stristr($field,
"."))
245 $sql_fields[] =
"usr_data.".$field;
249 $sql_fields[] = $field;
254 $query =
"SELECT ".implode($sql_fields,
",").
259 $query.=
" WHERE usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
262 if($this->users and is_array(($this->users)))
264 $query .=
' AND '.$ilDB->in(
'usr_data.usr_id',$this->users,
false,
'integer');
267 $count_query.=
" WHERE usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
270 if ($this->first_letter !=
"")
272 $add = $where.
" (".$ilDB->upper($ilDB->substr(
"usr_data.lastname", 1, 1)).
" = ".$ilDB->upper($ilDB->quote($this->first_letter,
"text")).
") ";
278 if ($this->text_filter !=
"")
280 $add = $where.
" (".$ilDB->like(
"usr_data.login",
"text",
"%".$this->text_filter.
"%").
" ".
281 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$this->text_filter.
"%").
" ".
282 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$this->text_filter.
"%").
" ".
283 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$this->text_filter.
"%").
") ";
289 if ($this->activation !=
"")
291 if ($this->activation ==
"inactive")
293 $add = $where.
" usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
297 $add = $where.
" usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
308 $add = $where.
" usr_data.last_login < ".
315 if ($this->limited_access)
317 $add = $where.
" usr_data.time_limit_unlimited= ".$ilDB->quote(0,
"integer");
322 if ($this->no_courses)
324 $add = $where.
" usr_data.usr_id NOT IN (".
325 "SELECT DISTINCT ud.usr_id ".
326 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
327 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
328 "WHERE od.title LIKE 'il_crs_%')";
333 if ($this->no_groups)
335 $add = $where.
" usr_data.usr_id NOT IN (".
336 "SELECT DISTINCT ud.usr_id ".
337 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
338 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
339 "WHERE od.title LIKE 'il_grp_%')";
344 if ($this->crs_grp > 0)
347 $add = $where.
" usr_data.usr_id IN (".
348 "SELECT DISTINCT ud.usr_id ".
349 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
350 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
351 "WHERE od.title = ".$ilDB->quote(
"il_".$cgtype.
"_member_".$this->crs_grp,
"text").
")";
358 $add = $where.
" usr_data.usr_id IN (".
359 "SELECT DISTINCT ud.usr_id ".
360 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
361 "WHERE rbac_ua.rol_id = ".$ilDB->quote($this->role,
"integer").
")";
367 if($this->user_folder)
369 $add = $where.
" ".$ilDB->in(
'usr_data.time_limit_owner',$this->user_folder,
false,
'integer');
376 switch($this->order_field)
379 if ($this->order_dir ==
"desc")
381 $query.=
" ORDER BY usr_data.active DESC, usr_data.time_limit_unlimited DESC, usr_data.time_limit_until DESC";
385 $query.=
" ORDER BY usr_data.active ASC, usr_data.time_limit_unlimited ASC, usr_data.time_limit_until ASC";
390 if ($this->order_dir ==
"desc")
392 $query.=
" ORDER BY ut_online.online_time DESC";
396 $query.=
" ORDER BY ut_online.online_time ASC";
401 if (!in_array($this->order_field, $this->default_fields))
403 $this->order_field =
"login";
405 if ($this->order_dir !=
"asc" && $this->order_dir !=
"desc")
407 $this->order_dir =
"asc";
409 $query .=
" ORDER BY usr_data.".$this->order_field.
" ".strtoupper($this->order_dir);
414 $set = $ilDB->query($count_query);
416 if ($rec = $ilDB->fetchAssoc($set))
422 $limit = (int) $this->limit;
433 $set = $ilDB->query(
$query);
435 while($rec = $ilDB->fetchAssoc($set))
439 return array(
"cnt" => $cnt,
"set" =>
$result);
448 public static function getUserListData($a_order_field, $a_order_dir, $a_offset, $a_limit,
449 $a_string_filter =
"", $a_activation_filter =
"", $a_last_login_filter = null,
450 $a_limited_access_filter =
false, $a_no_courses_filter =
false,
451 $a_course_group_filter = 0, $a_role_filter = 0, $a_user_folder_filter = null,
452 $a_additional_fields =
'', $a_user_filter = null, $a_first_letter =
"")
456 $query->setOrderField($a_order_field);
457 $query->setOrderDirection($a_order_dir);
458 $query->setOffset($a_offset);
459 $query->setLimit($a_limit);
460 $query->setTextFilter($a_string_filter);
461 $query->setActionFilter($a_activation_filter);
462 $query->setLastLogin($a_last_login_filter);
463 $query->setLimitedAccessFilter($a_limited_access_filter);
464 $query->setNoCourseFilter($a_no_courses_filter);
465 $query->setCourseGroupFilter($a_course_group_filter);
466 $query->setRoleFilter($a_role_filter);
467 $query->setUserFolder($a_user_folder_filter);
468 $query->setAdditionalFields($a_additional_fields);
469 $query->setUserFilter($a_user_filter);
470 $query->setFirstLetterLastname($a_first_letter);