echo Display::url(Display::return_icon('view_more_stats.gif', get_lang('AddUserToURL'), ''), api_get_path(WEB_CODE_PATH) . 'admin/access_url_add_users_to_url.php');
echo '</div>';
api_display_tool_title($tool_name);
if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
    Display::display_normal_message(Security::remove_XSS(stripslashes($_GET['message'])));
}
$nosessionUsersList = $sessionUsersList = array();
$ajax_search = $add_type == 'unique' ? true : false;
if ($ajax_search) {
    $Users = UrlManager::get_url_rel_user_data($access_url_id);
    foreach ($Users as $user) {
        $sessionUsersList[$user['user_id']] = $user;
    }
} else {
    $order_clause = api_sort_by_first_name() ? ' ORDER BY username, firstname, lastname' : ' ORDER BY username, lastname, firstname';
    $Users = UrlManager::get_url_rel_user_data(null, $order_clause);
    foreach ($Users as $user) {
        if ($user['access_url_id'] == $access_url_id) {
            $sessionUsersList[$user['user_id']] = $user;
        }
    }
    $sql = "SELECT u.user_id, lastname, firstname, username\n\t  \t  \tFROM {$tbl_user} u WHERE status <> " . ANONYMOUS . " " . $order_clause;
    $result = Database::query($sql);
    $Users = Database::store_result($result);
    $user_list_leys = array_keys($sessionUsersList);
    foreach ($Users as $user) {
        if (!in_array($user['user_id'], $user_list_leys)) {
            $nosessionUsersList[$user['user_id']] = $user;
        }
    }
}
echo '<div class="actions">';
echo Display::url(Display::return_icon('view_more_stats.gif', get_lang('AddUserToURL'), ''), api_get_path(WEB_CODE_PATH) . 'admin/access_url_add_users_to_url.php');
echo '</div>';
api_display_tool_title($tool_name);
if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
    Display::display_normal_message(Security::remove_XSS(stripslashes($_GET['message'])));
}
$nosessionUsersList = $sessionUsersList = array();
$ajax_search = $add_type == 'unique' ? true : false;
if ($ajax_search) {
    $Users = UrlManager::get_url_rel_user_data($access_url_id);
    foreach ($Users as $user) {
        $sessionUsersList[$user['user_id']] = $user;
    }
} else {
    $Users = UrlManager::get_url_rel_user_data();
    foreach ($Users as $user) {
        if ($user['access_url_id'] == $access_url_id) {
            $sessionUsersList[$user['user_id']] = $user;
        }
    }
    $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
    $sql = "SELECT u.user_id, lastname, firstname, username " . " FROM {$tbl_user} u WHERE status <> " . ANONYMOUS . " " . $order_clause;
    $result = Database::query($sql);
    $Users = Database::store_result($result);
    $user_list_leys = array_keys($sessionUsersList);
    foreach ($Users as $user) {
        if (!in_array($user['user_id'], $user_list_leys)) {
            $nosessionUsersList[$user['user_id']] = $user;
        }
    }