$sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
}
if (isset ($keyword)) {
$keyword = Database::escape_string($keyword);
//OR u.official_code LIKE '%".$keyword."%'
$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' )";
}
$keyword_active = true;
//only active users
if ($keyword_active) {
$sql .= " AND u.active='1'";
}
// adding the filter to see the user's only of the current access_url
if (api_get_multiple_access_url()) {
$sql.= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
}
if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC';
}
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$res = Database::query($sql);
$users = array ();
$t = time();
while ($user = Database::fetch_row($res)) {
if ($user[7] == 1 && $user[9] != '0000-00-00 00:00:00') {
// check expiration date
$expiration_time = convert_sql_date($user[9]);
// if expiration date is passed, store a special value for active field