예제 #1
0
function r_copy_dn($serverSRC, $serverDST, $snapshottree, $dnSRC, $dnDST, $remove)
{
    if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
        debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs);
    }
    $copy_message = array();
    $children = isset($snapshottree[$dnSRC]) ? $snapshottree[$dnSRC] : null;
    # If we have children, then we need to copy, then delete for a move
    if (is_array($children) && count($children)) {
        $copy_result = copy_dn($serverSRC, $serverDST, $dnSRC, $dnDST, false);
        if (!$copy_result) {
            return false;
        }
        array_push($copy_message, sprintf('%s %s: <b>%s</b> %s', _('Copy successful'), _('DN'), $dnDST, _('has been created.')));
        $hadError = false;
        foreach ($children as $child_dn) {
            $dnDST_new = sprintf('%s,%s', get_rdn($child_dn), $dnDST);
            $copy_result = r_copy_dn($serverSRC, $serverDST, $snapshottree, $child_dn, $dnDST_new, $remove);
            $copy_message = array_merge($copy_message, array_values($copy_result));
            if (!$copy_result) {
                $hadError = true;
            }
        }
        if (!$hadError && $remove) {
            $delete_result = $serverSRC->delete($dnSRC);
            if ($delete_result) {
                array_push($copy_message, sprintf('%s %s: <b>%s</b> %s', _('Delete successful'), _('DN'), $dnDST, _('has been deleted.')));
            }
        }
    } else {
        $copy_result = copy_dn($serverSRC, $serverDST, $dnSRC, $dnDST, $remove);
        if ($copy_result) {
            array_push($copy_message, sprintf('%s %s: <b>%s</b> %s', $remove ? _('Move successful') : _('Copy successful'), _('DN'), $dnDST, _('has been created.')));
        } else {
            array_push($copy_message, sprintf('%s %s: <b>%s</b> %s', $remove ? _('Move NOT successful') : _('Copy NOT successful'), _('DN'), $dnDST, _('has NOT been created.')));
        }
    }
    return $copy_message;
}
예제 #2
0
function r_copy_dn($ldapserver_src, $ldapserver_dst, $snapshottree, $root_dn, $dn_dst)
{
    if (DEBUG_ENABLED) {
        debug_log('r_copy_dn: Entered with (%s,%s,%s,%s,%s)', 1, $ldapserver_src->server_id, $ldapserver_dst->server_id, $snapshottree, $root_dn, $dn_dst);
    }
    printf('<nobr>%s %s...', _('Copying '), htmlspecialchars($root_dn));
    flush();
    $copy_result = copy_dn($ldapserver_src, $ldapserver_dst, $root_dn, $dn_dst);
    if (!$copy_result) {
        return false;
    }
    printf('<span style="color:green">%s</span></nobr><br />', _('Success'));
    flush();
    $children = isset($snapshottree[$root_dn]) ? $snapshottree[$root_dn] : null;
    if (is_array($children) && count($children) > 0) {
        foreach ($children as $child_dn) {
            $child_rdn = get_rdn($child_dn);
            $new_dest_dn = sprintf('%s,%s', $child_rdn, $dn_dst);
            r_copy_dn($ldapserver_src, $ldapserver_dst, $snapshottree, $child_dn, $new_dest_dn);
        }
    } else {
        return true;
    }
    return true;
}
예제 #3
0
function r_copy_dn($source_server_id, $dest_server_id, &$tree, $root_dn, $dest_dn)
{
    echo "<nobr>Copying " . htmlspecialchars($root_dn) . "...";
    flush();
    $copy_result = copy_dn($source_server_id, $root_dn, $dest_server_id, $dest_dn);
    if (!$copy_result) {
        global $R_COPY_ERROR;
        return false;
    }
    echo "<span style=\"color:green\">Success</span></nobr><br />\n";
    flush();
    $children = $tree[$root_dn];
    if (is_array($children) && count($children) > 0) {
        foreach ($children as $child_dn) {
            $child_rdn = get_rdn($child_dn);
            $new_dest_dn = $child_rdn . ',' . $dest_dn;
            r_copy_dn($source_server_id, $dest_server_id, $tree, $child_dn, $new_dest_dn);
        }
    } else {
        return true;
    }
    return true;
}