function LIST_GROUPS_FROM_OU_search_ActiveDirectory() { if ($_POST["query"] != null) { $search = $_POST["query"]; } $GLOBALS["NOUSERSCOUNT"] = false; $ou = base64_decode($_GET["ou"]); $sock = new sockets(); $page = CurrentPageName(); $tpl = new templates(); if ($_POST["qtype"] == "group") { $_POST["qtype"] = "groupname"; } if ($_POST["sortname"] == "group") { $_POST["sortname"] = "groupname"; } $error = "No dn"; if (strlen($_GET["dn"]) > 0) { $table = "activedirectory_groupsNames"; $database = "artica_backup"; $_GET["dn"] = urldecode($_GET["dn"]); $FORCE_FILTER = "AND oudn='{$_GET["dn"]}'"; $error = null; } $q = new mysql(); if ($q->COUNT_ROWS($table, $database) == 0) { json_error_show("{$table}: No item {$error}", 1); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $searchstring = string_to_flexquery(); if ($search != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { json_error_show("{$q->mysql_error}<br>\n{$sql}", 1); } if (mysql_num_rows($results) == 0) { json_error_show("No item: {$sql}", 1); } $data = array(); $data['page'] = 1; $data['total'] = $total; $data['rows'] = array(); $ldapad = new external_ad_search(); while ($ligne = mysql_fetch_assoc($results)) { $color = "black"; if (preg_match("#^CN=Users#i", $ligne["dn"])) { $ligne["dn"] = $ldapad->GetGroupDN($ligne["groupname"]); } $dn = urlencode($ligne["dn"]); $lineEnc = urlencode($ligne["groupname"]); $js = "javascript:Loadjs('domains.edit.group.tabs.php?gid={$lineEnc}&name={$lineEnc}&ou={$_GET["ou"]}&encoded=yes&dn={$dn}')"; $text = $tpl->_ENGINE_parse_body("{manage_this_group}"); $members = $ligne["UsersCount"]; if ($ligne["description"] != null) { $text = $tpl->_ENGINE_parse_body($ligne["description"]); } $data['rows'][] = array('id' => md5($ligne["dn"]), 'cell' => array("<span style='font-size:14px;color:{$color};'><img src='img/group-24.png'></span>", "<a href=\"javascript:blur();\" OnClick=\"{$js}\" style='font-size:14px;color:{$color};text-decoration:underline'>{$ligne["groupname"]}</span>", "<span style='font-size:14px;color:{$color};'>{$members}</span>", "<span style='font-size:14px;color:{$color};'>{$text}</span><div><i style='font-size:11px'>{$ligne["dn"]}</i></div>")); } echo json_encode($data); }