17 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)
22 global
$ilDB, $rbacreview;
24 $fields = array(
"usr_id",
"login",
"firstname",
"lastname",
"email",
25 "time_limit_until",
"time_limit_unlimited",
"last_login",
"active");
28 $count_query =
"SELECT count(usr_id) cnt".
32 $query =
"SELECT ".implode($fields,
",").
36 $query.=
" WHERE usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
37 $count_query.=
" WHERE usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
40 if ($a_string_filter !=
"")
42 $add = $where.
" (".$ilDB->like(
"usr_data.login",
"text",
"%".$a_string_filter.
"%").
" ".
43 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$a_string_filter.
"%").
" ".
44 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$a_string_filter.
"%").
" ".
45 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$a_string_filter.
"%").
") ";
50 if ($a_activation_filter !=
"")
52 if ($a_activation_filter ==
"inactive")
54 $add = $where.
" usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
58 $add = $where.
" usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
65 if (is_object($a_last_login_filter))
67 if ($a_last_login_filter->get(
IL_CAL_UNIX) < time())
69 $add = $where.
" last_login < ".
76 if ($a_limited_access_filter)
78 $add = $where.
" time_limit_unlimited= ".$ilDB->quote(0,
"integer");
83 if ($a_no_courses_filter)
85 $add = $where.
" usr_id NOT IN (".
86 "SELECT DISTINCT ud.usr_id ".
87 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
88 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
89 "WHERE od.title LIKE 'il_crs_%')";
94 if ($a_course_group_filter > 0)
97 $add = $where.
" usr_id IN (".
98 "SELECT DISTINCT ud.usr_id ".
99 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
100 "JOIN object_data od ON (rbac_ua.rol_id = od.obj_id) ".
101 "WHERE od.title = ".$ilDB->quote(
"il_".$cgtype.
"_member_".$a_course_group_filter,
"text").
")";
106 if ($a_role_filter > 0)
108 $add = $where.
" usr_id IN (".
109 "SELECT DISTINCT ud.usr_id ".
110 "FROM usr_data ud join rbac_ua ON (ud.usr_id = rbac_ua.usr_id) ".
111 "WHERE rbac_ua.rol_id = ".$ilDB->quote($a_role_filter,
"integer").
")";
118 if ($a_order_field !=
"access_until")
120 if (!in_array($a_order_field, $fields))
122 $a_order_field =
"login";
124 if ($a_order_dir !=
"asc" && $a_order_dir !=
"desc")
126 $a_order_dir =
"asc";
128 $query.=
" ORDER BY ".$a_order_field.
" ".strtoupper($a_order_dir);
132 if ($a_order_dir ==
"desc")
134 $query.=
" ORDER BY active DESC, time_limit_unlimited DESC, time_limit_until DESC";
138 $query.=
" ORDER BY active ASC, time_limit_unlimited ASC, time_limit_until ASC";
143 $set = $ilDB->query($count_query);
145 if ($rec = $ilDB->fetchAssoc($set))
150 $offset = (int) $a_offset;
151 $limit = (int) $a_limit;
152 $ilDB->setLimit($limit, $offset);
155 $set = $ilDB->query(
$query);
157 while($rec = $ilDB->fetchAssoc($set))
161 return array(
"cnt" => $cnt,
"set" =>
$result);
166 $result_arr = array();
170 if ($a_fields !== NULL and is_array($a_fields))
172 if (count($a_fields) == 0)
178 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
179 unset($a_fields[$usr_id_field]);
181 $select = implode(
",",$a_fields).
",usr_data.usr_id";
183 if(in_array(
'online_time',$a_fields))
185 $select .=
",ut_online.online_time ";
189 $q =
"SELECT ".$select.
" FROM usr_data ";
193 if(in_array(
'online_time',$a_fields))
195 $q .=
"LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
202 $q .=
"WHERE active = ".$ilDB->quote($active,
"integer");
205 $q .=
"WHERE time_limit_unlimited= ".$ilDB->quote(0,
"integer");;
208 $qtemp =
$q .
", rbac_ua, object_data WHERE rbac_ua.rol_id = object_data.obj_id AND ".
209 $ilDB->like(
"object_data.title",
"text",
"%crs%").
" AND usr_data.usr_id = rbac_ua.usr_id";
210 $r =
$ilDB->query($qtemp);
211 $course_users = array();
214 array_push($course_users,
$row[
"usr_id"]);
216 if (count($course_users))
218 $q .=
" WHERE ".$ilDB->in(
"usr_data.usr_id", $course_users,
true,
"integer").
" ";
226 $date = strftime(
"%Y-%m-%d %H:%I:%S", mktime(0, 0, 0,
$_SESSION[
"user_filter_data"][
"m"],
$_SESSION[
"user_filter_data"][
"d"],
$_SESSION[
"user_filter_data"][
"y"]));
227 $q.=
" AND last_login < ".$ilDB->quote($date,
"timestamp");
233 $q .=
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id ".
234 "WHERE crs_members.obj_id = (SELECT obj_id FROM object_reference ".
235 "WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") ";
243 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
244 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
245 if (is_array($local_roles) && count($local_roles))
247 $q.=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
248 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false,
"integer").
" ";
256 $q .=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
257 $ilDB->quote($rol_id,
"integer");
266 $result_arr[] =
$row;