function COUNT_DE_USERS()
{
    $sock = new sockets();
    $ldap = new clladp();
    $_GET["dn"] = urldecode($_GET["dn"]);
    if ($ldap->IsKerbAuth()) {
        $ad = new external_ad_search();
        echo $ad->CountDeUSerOu($_GET["count-de-users"], $_GET["dn"]);
    }
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $ldap = new ldapAD();
        echo $ldap->CountDeUSerOu($_GET["count-de-users"], $_GET["dn"]);
        return;
    }
    $ldap = new clladp();
    echo $ldap->CountDeUSerOu($_GET["count-de-users"]);
}
Пример #2
0
function ORGANISATIONS_LIST()
{
    $tpl = new templates();
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        return ORGANISATIONS_LIST_ACTIVE_DIRECTORY();
    }
    include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
    $Mypage = CurrentPageName();
    $users = new usersMenus();
    $sock = new sockets();
    $ou_nozarafa_explain = $tpl->_ENGINE_parse_body("{ou_nozarafa_explain}");
    $t = $_GET["t"];
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    $AllowInternetUsersCreateOrg = $sock->GET_INFO("AllowInternetUsersCreateOrg");
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $ldap = new ldapAD();
        $hash = $ldap->hash_get_ou(true);
    } else {
        $ldap = new clladp();
        $hash = $ldap->hash_get_ou(true);
    }
    if (!is_array($hash)) {
        json_error_show("No data...");
    }
    ksort($hash);
    if ($EnableManageUsersTroughActiveDirectory == 0) {
        if (!$ldap->BuildOrganizationBranch()) {
            json_error_show("{GENERIC_LDAP_ERROR}<br>{$ldap->ldap_last_error}");
        }
    }
    if ($_POST["query"] != null) {
        $search = $_POST["query"];
        $search = str_replace(".", "\\.", $search);
        $search = str_replace("*", ".*?", $search);
    }
    if (isset($_GET["ajaxmenu"])) {
        $ajax = true;
    }
    $pic = "32-environement.png";
    $style = "style='font-size:16px;'";
    $c = 0;
    $ldap2 = new clladp();
    if (count($hash) == 0) {
        json_error_show("no data");
    }
    while (list($num, $ligne) = each($hash)) {
        $ou = $ligne;
        $ou_encoded = base64_encode($ou);
        if (!preg_match("#{$search}#i", $ligne)) {
            writelogs("'{$ligne}' NO MATCH {$search}", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        $md = md5(serialize($hash) . time());
        $md5S = $md;
        $uri = "javascript:Loadjs('domains.manage.org.index.php?js=yes&ou={$ligne}');";
        if ($ajax) {
            $uri = "javascript:Loadjs('{$Mypage}?LoadOrgPopup={$ligne}');";
        }
        $IsOUUnderActiveDirectory = $ldap2->IsOUUnderActiveDirectory($ou);
        $GroupsNB = 0;
        if ($EnableManageUsersTroughActiveDirectory == 0) {
            $img = $ldap->get_organization_picture($ligne, 32);
            writelogs("ldap->CountDeUSerOu({$ligne})", __FUNCTION__, __FILE__, __LINE__);
            $usersNB = $ldap->CountDeUSerOu($ligne);
            $usersNB = "{$usersNB}";
        } else {
            $img = $pic;
            if ($IsOUUnderActiveDirectory) {
                $ad = new external_ad_search();
                writelogs("ldap->CountDeUSerOu({$ligne})", __FUNCTION__, __FILE__, __LINE__);
                $usersNB = $ad->CountDeUSerOu($ligne);
            } else {
                writelogs("ldap->CountDeUSerOu({$ligne})", __FUNCTION__, __FILE__, __LINE__);
                $usersNB = $ldap->CountDeUSerOu($ligne);
                $usersNB = "{$usersNB}";
            }
        }
        $delete = imgtootltip("delete-32-grey.png", "<b>{delete_ou} {$ligne}</b><br><i>{delete_ou_text}</i>");
        if ($users->AsArticaAdministrator) {
            $delete = Paragraphe('64-cancel.png', "{delete_ou} {$ligne}", '{delete_ou_text}', "javascript:Loadjs('domains.delete.org.php?ou={$ligne}');", null, 210, 100, 0, true);
            $delete = imgsimple("delete-32.png", "<b>{delete_ou} {$ligne}</b><br><i>{delete_ou_text}</i>", "javascript:Loadjs('domains.delete.org.php?ou={$ligne}&t={$t}&id-table={$md5S}');");
        }
        $DomainsNB = $ldap->CountDeDomainsOU($ligne);
        if ($GroupsNB == 0) {
            if ($IsOUUnderActiveDirectory) {
                $ad = new external_ad_search();
                writelogs("->CountDeGroups({$ou})", __FUNCTION__, __FILE__, __LINE__);
                $GroupsNB = $ad->CountDeGroups($ou);
            } else {
                writelogs("->CountDeGroups({$ou})", __FUNCTION__, __FILE__, __LINE__);
                $GroupsNB = $ldap->CountDeGroups($ou);
            }
        }
        Paragraphe('folder-useradd-64.png', '{create_user}', '{create_user_text}', "javascript:Loadjs('domains.add.user.php?ou={$ou}')", null, 210, null, 0, true);
        Paragraphe('64-folder-group-add.png', '{create_user}', '{create_user_text}', "javascript:Loadjs('domains.add.user.php?ou={$ou}')", null, 210, null, 0, true);
        Paragraphe("64-folder-group-add.png", "{$ou}:{add_group}", "{add_a_new_group_in_this_org}:<b>{$ou}</b>", "javascript:Loadjs('domains.edit.group.php?popup-add-group=yes&ou={$ou}&t={$t}')");
        $select = imgsimple("domain-32.png", "{manage_organisations_text}", $uri);
        $adduser = imgsimple("folder-useradd-32.png", "{$ou}<hr><b>{create_user}</b><br><i>{create_user_text}</i>", "Loadjs('domains.add.user.php?ou={$ou_encoded}&encoded=yes');");
        $addgroup = imgsimple("32-folder-group-add.png", "{$ou}<hr><b>{add_group}</b><br><i>{add_a_new_group_in_this_org}</i>", "Loadjs('domains.edit.group.php?popup-add-group=yes&ou={$ou}&t={$t}');");
        $SearchUser = imgsimple("loupe-32.png", "{$ou}<hr><b>{search}</b>:<i>{members}</i>", "Loadjs('domains.find.user.php?ou={$ou_encoded}&encoded=yes');");
        $SearchGroup = imgsimple("loupe-32.png", "{$ou}<hr><b>{search}</b>:<i>{groups}</i>", "Loadjs('domains.find.groups.php?ou={$ou_encoded}&encoded=yes&t={$t}');");
        $searchDomain = imgsimple("loupe-32.png", "{$ou}<hr><b>{localdomains}</b>:<i>{localdomains_text}</i>", "Loadjs('domains.edit.domains.php?js=yes&ou={$ou}&master-t={$t}');");
        $NOZARAFA = 0;
        $OuZarafaText = null;
        if ($IsOUUnderActiveDirectory) {
            $delete = imgtootltip("delete-24-grey.png", "", "");
            $adduser = imgsimple("folder-useradd-32-grey.png");
            $addgroup = imgsimple("32-folder-group-add-grey.png");
        }
        if ($_GET["zarafaF"] == 1) {
            $info = $ldap->OUDatas($ou);
            if (!$info["objectClass"]["zarafa-company"]) {
                $NOZARAFA = 1;
                $OuZarafaText = "<br><a href=\"javascript:blur()\" style='color:#B20808;text-decoration:underline;font-style:italic' \n\t\t\t\tOnClick=\"javascript:Loadjs('domains.edit.zarafa.php?ou={$ou_encoded}&t={$t}')\">{$ou_nozarafa_explain}</a>";
            }
        }
        $array = array();
        $array[] = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"{$uri}\" style='font-size:26px;font-weight:bolder;text-transform:capitalize;\n\t\ttext-decoration:underline'>{$ligne}</strong></a>{$OuZarafaText}";
        if ($_GET["zarafaF"] == 1) {
            $zarafaEnabled = "zarafa-logo-32.png";
            if ($NOZARAFA == 1) {
                $zarafaEnabled = "zarafa-logo-32-grey.png";
            }
            $array[] = "<center>" . imgsimple($zarafaEnabled, "<strong style=font-size:26px>{$ou}:{APP_ZARAFA}</strong>\n\t\t\t\t\t<br>{ZARAFA_OU_ICON_TEXT}", "Loadjs('domains.edit.zarafa.php?ou={$ou_encoded}&t={$t}')") . "</center>";
        } else {
            $array[] = "&nbsp;";
        }
        $array[] = "<strong style='font-size:26px'>{$usersNB}</strong>";
        $array[] = "<center style='font-size:16px'>{$SearchUser}</center>";
        $array[] = "<strong style='font-size:26px'>{$GroupsNB}</strong>";
        $array[] = "<center style='font-size:16px'>{$SearchGroup}</center>";
        $array[] = "<strong style='font-size:26px'>{$DomainsNB}</strong>";
        $array[] = "<center style='font-size:16px'>{$searchDomain}</center>";
        $array[] = "<center style='font-size:16px'>{$adduser}</center>";
        $array[] = "<center style='font-size:16px'>{$addgroup}</center>";
        $array[] = "<center style='font-size:16px'>{$delete}</center>";
        $c++;
        $data['rows'][] = array('id' => $md5S, 'cell' => $array);
    }
    $total = $c;
    $data['page'] = 1;
    $data['total'] = $total;
    echo json_encode($data);
}