17 public static function getUserListData($a_order_field, $a_order_dir, $a_offset, $a_limit,
18 $a_string_filter =
"", $a_activation_filter =
"", $a_last_login_filter = null,
19 $a_limited_access_filter =
false, $a_no_courses_filter =
false,
20 $a_course_group_filter = 0, $a_role_filter = 0, $a_user_folder_filter = null,
21 $a_additional_fields =
'', $a_user_filter = null, $a_first_letter =
"")
23 global
$ilDB, $rbacreview;
25 $fields = array(
"usr_id",
"login",
"firstname",
"lastname",
"email",
26 "time_limit_until",
"time_limit_unlimited",
"time_limit_owner",
"last_login",
"active");
28 if (is_array($a_additional_fields))
30 foreach ($a_additional_fields as
$f)
32 if (!in_array($f, $fields))
40 $count_query =
"SELECT count(usr_id) cnt".
44 $query =
"SELECT ".implode($fields,
",").
48 $query.=
" WHERE usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
51 if($a_user_filter and is_array(($a_user_filter)))
53 $query .=
' AND '.$ilDB->in(
'usr_id',$a_user_filter,
false,
'integer');
56 $count_query.=
" WHERE usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
59 if ($a_first_letter !=
"")
61 $add = $where.
" (".$ilDB->upper($ilDB->substr(
"usr_data.lastname", 1, 1)).
" = ".$ilDB->upper($ilDB->quote($a_first_letter,
"text")).
") ";
67 if ($a_string_filter !=
"")
69 $add = $where.
" (".$ilDB->like(
"usr_data.login",
"text",
"%".$a_string_filter.
"%").
" ".
70 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$a_string_filter.
"%").
" ".
71 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$a_string_filter.
"%").
" ".
72 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$a_string_filter.
"%").
") ";
77 if ($a_activation_filter !=
"")
79 if ($a_activation_filter ==
"inactive")
81 $add = $where.
" usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
85 $add = $where.
" usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
92 if (is_object($a_last_login_filter))
94 if ($a_last_login_filter->get(
IL_CAL_UNIX) < time())
96 $add = $where.
" last_login < ".
103 if ($a_limited_access_filter)
105 $add = $where.
" time_limit_unlimited= ".$ilDB->quote(0,
"integer");
110 if ($a_no_courses_filter)
112 $add = $where.
" usr_id NOT IN (".
113 "SELECT DISTINCT ud.usr_id ".
114 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
115 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
116 "WHERE od.title LIKE 'il_crs_%')";
121 if ($a_course_group_filter > 0)
124 $add = $where.
" usr_id IN (".
125 "SELECT DISTINCT ud.usr_id ".
126 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
127 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
128 "WHERE od.title = ".$ilDB->quote(
"il_".$cgtype.
"_member_".$a_course_group_filter,
"text").
")";
133 if ($a_role_filter > 0)
135 $add = $where.
" usr_id IN (".
136 "SELECT DISTINCT ud.usr_id ".
137 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
138 "WHERE rbac_ua.rol_id = ".$ilDB->quote($a_role_filter,
"integer").
")";
144 if(!is_null($a_user_folder_filter))
146 $add = $where.
" ".$ilDB->in(
'time_limit_owner',$a_user_folder_filter,
false,
'integer');
153 if ($a_order_field !=
"access_until")
155 if (!in_array($a_order_field, $fields))
157 $a_order_field =
"login";
159 if ($a_order_dir !=
"asc" && $a_order_dir !=
"desc")
161 $a_order_dir =
"asc";
163 $query.=
" ORDER BY ".$a_order_field.
" ".strtoupper($a_order_dir);
167 if ($a_order_dir ==
"desc")
169 $query.=
" ORDER BY active DESC, time_limit_unlimited DESC, time_limit_until DESC";
173 $query.=
" ORDER BY active ASC, time_limit_unlimited ASC, time_limit_until ASC";
178 $set = $ilDB->query($count_query);
180 if ($rec = $ilDB->fetchAssoc($set))
185 $offset = (int) $a_offset;
186 $limit = (int) $a_limit;
187 $ilDB->setLimit($limit, $offset);
190 $set = $ilDB->query(
$query);
192 while($rec = $ilDB->fetchAssoc($set))
196 return array(
"cnt" => $cnt,
"set" => $result);