function MEMBERS_SEARCH_USERS()
{
    $gid = $_GET["FindInGroup"];
    $pattern = $_GET["pattern"];
    $pattern = str_replace('*', '', $pattern);
    $styleRoll = "\n\tstyle='border:1px solid white;width:190px;float:left;margin:1px'\n\tOnMouseOver=\"this.style.backgroundColor='#F3F3DF';this.style.cursor='pointer';this.style.border='1px solid #CCCCCC'\"\n\tOnMouseOut=\"this.style.backgroundColor='transparent';this.style.cursor='auto';this.style.border='1px solid white'\"\n\t";
    //first we search the users
    $ldap = new clladp();
    $hash = $ldap->UserSearch(null, $pattern);
    //second we load users uids of the group and build the hash
    $sr = @ldap_search($ldap->ldap_connection, $ldap->suffix, "(gidnumber={$gid})", array("memberUid"));
    if (!$sr) {
        writelogs("Search members for (gidnumber={$gid}) failed", __FUNCTION__, __FILE__);
        return null;
    }
    $entry_id = ldap_first_entry($ldap->ldap_connection, $sr);
    if (!$entry_id) {
        return null;
    }
    $attrs = ldap_get_attributes($ldap->ldap_connection, $entry_id);
    if (!is_array($attrs["memberUid"])) {
        writelogs("memberUid no attrs", __FUNCTION__, __FILE__);
        return null;
    }
    $count = $attrs["memberUid"]["count"];
    while (list($num, $ligne) = each($attrs["memberUid"])) {
        $hash_members[$ligne] = true;
    }
    //now we parse the search results
    $count = 0;
    for ($i = 0; $i < $hash["count"]; $i++) {
        if ($hash_members[$hash[$i]["uid"][0]]) {
            $uid = $hash[$i]["uid"][0];
            $count = $count + 1;
            $html = $html . "<div {$styleRoll} id='mainid_{$uid}'>" . MEMBERS_SELL($uid) . "</div>";
            if ($count > 41) {
                break;
            }
        }
    }
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
function MEMBERS_LIST_LIST($gid)
{
    if ($gid == "undefined") {
        $gid = 0;
    }
    $ldap = new clladp();
    $hashGroup = $ldap->GroupDatas($gid);
    $members = $hashGroup["ARRAY_MEMBERS"];
    $count = count($members);
    $number_of_users = $count;
    writelogs("found {$count} members for (gidnumber={$gid})", __FUNCTION__, __FILE__);
    if (!is_array($members)) {
        return null;
    }
    sort($members);
    if ($_GET["page"] == null) {
        $_GET["page"] = 0;
    }
    $priv = new usersMenus();
    $pagesNumber = round($count / 40, 1);
    //if(strpos($pagesNumber,'.')>0){$pagesNumber=$pagesNumber+1;}
    $pageaffich = round($pagesNumber);
    $pageaffich = $pageaffich + 1;
    if ($count > 40) {
        $start = $_GET["page"] * 40;
        $max = $start + 40;
        $curmx = $count - $start;
        $cols = round($curmx / 10);
    } else {
        $start = 0;
        $max = $count;
        $cols = round($max / 10);
    }
    if ($pagesNumber > 1) {
        $title_pages = "&nbsp;&laquo;&nbsp; {$_GET["page"]}/{$pageaffich} {pages} {members} {$start}/{$max} ({$number_of_users} {members})&nbsp;&raquo;&nbsp;";
        $tabs = MEMBERS_LIST_TABS($pagesNumber, $_GET["page"]);
    }
    $html = "\n\t{$tabs}\n\t<table style='width:100%;padding:1px;border:1px solid #CCCCCC'>\n\t</tr><td valign='top'><div id='listofMembersOfThisGroup'>";
    $styleRoll = "\n\tstyle='border:1px solid white;width:190px;float:left;margin:1px'\n\tOnMouseOver=\"this.style.backgroundColor='#F3F3DF';this.style.cursor='pointer';this.style.border='1px solid #CCCCCC'\"\n\tOnMouseOut=\"this.style.backgroundColor='transparent';this.style.cursor='auto';this.style.border='1px solid white'\"\n\t";
    for ($i = $start; $i <= $max; $i++) {
        $html = $html . "<div {$styleRoll} id='mainid_{$members[$i]}'>" . MEMBERS_SELL($members[$i], $i) . "</div>";
    }
    $html = $html . "</div></td></table><p>&nbsp;</p>";
    $tpl = new templates();
    $html = "\n\t<p class=caption>{$title_pages}</p>\n\t<div style='width:99.5%;height:300px;overflow:auto'>{$html}</div>";
    return $tpl->_ENGINE_parse_body($html);
}