예제 #1
0
function EditGroup()
{
    $gid = $_GET["PrivilegesGroup"];
    $ldap = new clladp();
    $update_array = array();
    writelogs("Save privileges for {$gid}", __CLASS__, __FUNCTION__, __FILE__, __LINE__);
    $loadGPID = true;
    if ($gid == -1) {
        $loadGPID = false;
        $Hash = $ldap->OUDatas($_GET["ou"]);
        writelogs("Loading ou datas of \"{$_GET["ou"]}\" ArticaGroupPrivileges=" . strlen($Hash["ArticaGroupPrivileges"]) . " bytes", __FUNCTION__, __FILE__, __LINE__);
        $dn = $Hash["dn"];
    }
    if ($gid == -2) {
        $loadGPID = false;
        $user = new user($_GET["userid"]);
        $Hash["ArticaGroupPrivileges"] = $user->ArticaGroupPrivileges;
        writelogs("Loading datas of \"{$_GET["userid"]}\" ArticaGroupPrivileges={$user->ArticaGroupPrivileges} bytes", __FUNCTION__, __FILE__, __LINE__);
    }
    if ($gid > 0) {
        writelogs("Loading datas of ldap->GroupDatas(\"{$_GET["{$gid}"]}\") ", __FUNCTION__, __FILE__, __LINE__);
        $Hash = $ldap->GroupDatas($gid);
    }
    if (!is_array($Hash["ArticaGroupPrivileges"])) {
        writelogs("ldap->_ParsePrivieleges(...)", __FUNCTION__, __FILE__, __LINE__);
        $ArticaGroupPrivileges = $ldap->_ParsePrivieleges($Hash["ArticaGroupPrivileges"]);
    } else {
        $ArticaGroupPrivileges = $Hash["ArticaGroupPrivileges"];
    }
    if (!is_array($ArticaGroupPrivileges)) {
        writelogs("ArticaGroupPrivileges[] is not an array !", __FUNCTION__, __FILE__, __LINE__);
    }
    if (is_array($ArticaGroupPrivileges)) {
        while (list($num, $val) = each($ArticaGroupPrivileges)) {
            $GroupPrivilege[$num] = $val;
        }
    }
    while (list($num, $val) = each($_GET)) {
        writelogs("ADD GroupPrivilege[{$num}]={$val}", __FUNCTION__, __FILE__, __LINE__);
        $GroupPrivilege[$num] = $val;
    }
    while (list($num, $val) = each($GroupPrivilege)) {
        if ($val == "no") {
            writelogs("[{$num}]=SKIP", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        writelogs("[{$num}]=\"{$val}\"", __FUNCTION__, __FILE__, __LINE__);
        $GroupPrivilegeNew[] = "[{$num}]=\"{$val}\"";
    }
    $values = @implode($GroupPrivilegeNew, "\n");
    if ($gid == -2) {
        writelogs("ArticaGroupPrivileges -> {$gid} -> user->SavePrivileges() values={$values}", __FUNCTION__, __FILE__, __LINE__);
        $user->SavePrivileges($values);
        return;
    }
    if (strpos($gid, ",") > 0) {
        $gp = new external_ad_search();
        $gp->SaveGroupPrivileges($values, $gid);
        return;
    }
    $update_array["ArticaGroupPrivileges"][0] = $values;
    writelogs("ArticaGroupPrivileges ->  {$Hash["dn"]} -> group->SavePrivileges() values={$values}", __FUNCTION__, __FILE__, __LINE__);
    if (!$ldap->Ldap_modify($Hash["dn"], $update_array)) {
        echo basename(__FILE__) . "\nline: " . __LINE__ . "\n" . $ldap->ldap_last_error;
    }
}