RELEASE 0.9.5
This commit is contained in:
36
copy.php
36
copy.php
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/copy.php,v 1.25 2004/08/15 17:35:25 uugdave Exp $
|
||||
|
||||
|
||||
/*
|
||||
* copy.php
|
||||
@@ -12,8 +14,6 @@
|
||||
|
||||
require realpath( 'common.php' );
|
||||
|
||||
session_start();
|
||||
|
||||
$source_dn = $_POST['old_dn'];
|
||||
$dest_dn = $_POST['new_dn'];
|
||||
$encoded_dn = rawurlencode( $source_dn );
|
||||
@@ -29,19 +29,20 @@ have_auth_info( $source_server_id ) or pla_error( $lang['not_enough_login_info']
|
||||
check_server_id( $dest_server_id ) or pla_error( $lang['bad_server_id'] );
|
||||
have_auth_info( $dest_server_id ) or pla_error( $lang['not_enough_login_info'] );
|
||||
|
||||
include 'header.php';
|
||||
include './header.php';
|
||||
|
||||
/* Error checking */
|
||||
if( 0 == strlen( trim( $dest_dn ) ) )
|
||||
pla_error( $lang['copy_dest_dn_blank'] );
|
||||
if( dn_exists( $dest_server_id, $dest_dn ) )
|
||||
pla_error( sprintf( $lang['copy_dest_already_exists'], $dest_dn ) );
|
||||
if( ! dn_exists( $dest_server_id, get_container( $dest_dn ) ) )
|
||||
pla_error( sprintf( $lang['copy_dest_container_does_not_exist'], get_container($dest_dn) ) );
|
||||
if( pla_compare_dns( $source_dn,$dest_dn ) == 0 && $source_server_id == $dest_server_id )
|
||||
pla_error( $lang['copy_source_dest_dn_same'] );
|
||||
if( dn_exists( $dest_server_id, $dest_dn ) )
|
||||
pla_error( sprintf( $lang['copy_dest_already_exists'], pretty_print_dn( $dest_dn ) ) );
|
||||
if( ! dn_exists( $dest_server_id, get_container( $dest_dn ) ) )
|
||||
pla_error( sprintf( $lang['copy_dest_container_does_not_exist'], pretty_print_dn( get_container($dest_dn) ) ) );
|
||||
|
||||
if( $do_recursive ) {
|
||||
$filter = isset( $_POST['filter'] ) ? $_POST['filter'] : '(objectClass=*)';
|
||||
// build a tree similar to that of the tree browser to give to r_copy_dn
|
||||
$snapshot_tree = array();
|
||||
echo "<body>\n";
|
||||
@@ -51,7 +52,7 @@ if( $do_recursive ) {
|
||||
echo "<small>\n";
|
||||
echo $lang['copy_building_snapshot'];
|
||||
flush();
|
||||
build_tree( $source_server_id, $source_dn, $snapshot_tree );
|
||||
build_tree( $source_server_id, $source_dn, $snapshot_tree, $filter );
|
||||
echo " <span style=\"color:green\">" . $lang['success'] . "</span><br />\n";
|
||||
flush();
|
||||
|
||||
@@ -69,8 +70,11 @@ if( $copy_result )
|
||||
$edit_url="edit.php?server_id=$dest_server_id&dn=" . rawurlencode( $dest_dn );
|
||||
$new_rdn = get_rdn( $dest_dn );
|
||||
$container = get_container( $dest_dn );
|
||||
if( session_is_registered( 'tree' ) )
|
||||
|
||||
if( array_key_exists( 'tree', $_SESSION ) )
|
||||
{
|
||||
// do we not have a tree and tree icons yet? Build a new ones.
|
||||
initialize_session_tree();
|
||||
$tree = $_SESSION['tree'];
|
||||
$tree_icons = $_SESSION['tree_icons'];
|
||||
if( isset( $tree[$dest_server_id][$container] ) )
|
||||
@@ -92,7 +96,7 @@ if( $copy_result )
|
||||
</script>
|
||||
<br />
|
||||
<center>
|
||||
<?php echo $lang['copy_successful_like_to']. "<a href=\"$edit_url\">" . $lang['copy_view_new_entry'] ."</a>?"?>
|
||||
<?php echo $lang['copy_successful_like_to']. "<a href=\"$edit_url\">" . $lang['copy_view_new_entry'] ."</a>"?>
|
||||
</center>
|
||||
<br />
|
||||
<br />
|
||||
@@ -141,7 +145,10 @@ function r_copy_dn( $source_server_id, $dest_server_id, $tree, $root_dn, $dest_d
|
||||
function copy_dn( $source_server_id, $source_dn, $dest_server_id, $dest_dn )
|
||||
{
|
||||
global $ds, $lang;
|
||||
$ds = pla_ldap_connect( $dest_server_id ) or pla_error( $lang['could_not_connect'] );
|
||||
|
||||
$ds = pla_ldap_connect( $dest_server_id );
|
||||
pla_ldap_connection_is_error( $ds );
|
||||
|
||||
$attrs = get_object_attrs( $source_server_id, $source_dn );
|
||||
$new_entry = $attrs;
|
||||
// modify the prefix-value (ie "bob" in cn=bob) to match the destination DN's value.
|
||||
@@ -167,14 +174,13 @@ function copy_dn( $source_server_id, $source_dn, $dest_server_id, $dest_dn )
|
||||
}
|
||||
}
|
||||
|
||||
function build_tree( $source_server_id, $root_dn, &$tree )
|
||||
function build_tree( $source_server_id, $root_dn, &$tree, $filter='(objectClass=*)' )
|
||||
{
|
||||
$children = get_container_contents( $source_server_id, $root_dn );
|
||||
$children = get_container_contents( $source_server_id, $root_dn, 0, $filter );
|
||||
if( is_array( $children ) && count( $children ) > 0 )
|
||||
{
|
||||
$tree[ $root_dn ] = $children;
|
||||
foreach( $children as $child_dn )
|
||||
build_tree( $source_server_id, $child_dn, $tree );
|
||||
build_tree( $source_server_id, $child_dn, $tree, $filter );
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user