RELEASE 0.9.8

This commit is contained in:
Deon George
2009-06-30 20:26:08 +10:00
parent 1f7f96122f
commit fdee1bdbd1
242 changed files with 34529 additions and 34446 deletions

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/rename.php,v 1.27.2.2 2005/10/16 21:04:51 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/rename.php,v 1.29.2.3 2005/12/08 11:54:19 wurley Exp $
/**
* Renames a DN to a different name.
@@ -18,106 +18,60 @@
require './common.php';
if ($ldapserver->isReadOnly())
pla_error($lang['no_updates_in_read_only_mode']);
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error($lang['not_enough_login_info']);
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$dn = ($_POST['dn']);
$new_rdn = ($_POST['new_rdn']);
if (! $ldapserver->isBranchRenameEnabled()) {
$children = get_container_contents($ldapserver,$dn);
$children = $ldapserver->getContainerContents($dn);
if (count($children) > 0)
pla_error($lang['non_leaf_nodes_cannot_be_renamed']);
pla_error(_('You cannot rename an entry which has children entries (eg, the rename operation is not allowed on non-leaf entries)'));
}
$new_rdn = ($_POST['new_rdn']);
$container = get_container($dn);
$new_dn = sprintf('%s,%s',$new_rdn,$container);
if ($new_dn == $dn)
pla_error($lang['no_rdn_change']);
pla_error(_('You did not change the RDN'));
$old_dn_attr = explode('=',$dn);
$old_dn_attr = $old_dn_attr[0];
$old_dn_value = pla_explode_dn($dn);
$old_dn_value = explode('=',$old_dn_value[0],2);
$old_dn_value = $old_dn_value[1];
$new_dn_value = explode('=',$new_rdn,2);
if (count($new_dn_value) != 2 || ! isset($new_dn_value[1]))
pla_error($lang['invalid_rdn']);
pla_error(_('Invalid RDN value'));
$new_dn_attr = $new_dn_value[0];
$new_dn_value = $new_dn_value[1];
$success = run_hook ('pre_rename_entry', array ('server_id' => $ldapserver->server_id,
'old_dn' => $dn, 'new_dn' => $new_dn_value ) );
$success = run_hook('pre_rename_entry',array('server_id'=>$ldapserver->server_id,'old_dn'=>$dn,'new_dn'=>$new_dn_value));
if ($success) {
$success = false;
$deleteoldrdn = $old_dn_attr == $new_dn_attr;
if (! @ldap_rename($ldapserver->connect(), $dn, $new_rdn, $container, $deleteoldrdn ) ) {
pla_error($lang['could_not_rename'],
$ldapserver->error(),
$ldapserver->errno(), false );
} else
$success = true;
$success = $ldapserver->rename($dn,$new_rdn,$container,$deleteoldrdn);
} else {
pla_error($lang['could_not_rename'] );
pla_error(_('Could not rename the entry') );
}
if ($success ) {
run_hook ('post_rename_entry', array ('server_id' => $ldapserver->server_id, 'old_dn' => $dn,
'new_dn' => $new_dn_value ) );
if ($success) {
run_hook('post_rename_entry',array('server_id'=>$ldapserver->server_id,'old_dn'=>$dn,'new_dn'=>$new_dn_value));
if (array_key_exists('tree', $_SESSION ) ) {
$tree = $_SESSION['tree'];
$tree_icons = $_SESSION['tree_icons'];
$old_dn = $dn;
$edit_url = sprintf('template_engine.php?server_id=%s&dn=%s',$ldapserver->server_id,rawurlencode($new_dn));
// gotta search the whole tree for the entry (must be a leaf node since RDN changes
// cannot occur on parents)
foreach ($tree[$ldapserver->server_id] as $parent_dn => $children ) {
foreach ($children as $i => $child_dn ) {
if (0 == strcasecmp($child_dn, $old_dn ) )
$tree[$ldapserver->server_id][$parent_dn][$i] = $new_dn;
}
}
echo '<html><head>';
echo '<!-- refresh the tree view (with the new DN renamed) and redirect to the edit_dn page -->';
printf('<script language="javascript">parent.left_frame.location.reload();location.href="%s";</script>',$edit_url);
echo "<!-- If the JavaScript didn't work, here's a meta tag to do the job -->";
printf('<meta http-equiv="refresh" content="0; url=%s" />',$edit_url);
echo '</head><body>';
// Update the icon tree to reflect the change (remove the old DN and add the new one)
$tree_icons[ $ldapserver->server_id ][ $new_dn ] = $tree_icons[ $ldapserver->server_id ][ $old_dn ];
unset($tree_icons[ $ldapserver->server_id ][ $old_dn ] );
$_SESSION['tree'] = $tree;
$_SESSION['tree_icons'] = $tree_icons;
session_write_close();
$edit_url = sprintf('edit.php?server_id=%s&dn=%s',$ldapserver->server_id,rawurlencode("$new_rdn,$container"));
?>
<html>
<head>
<!-- refresh the tree view (with the new DN renamed)
and redirect to the edit_dn page -->
<script language="javascript">
parent.left_frame.location.reload();
location.href='<?php echo $edit_url; ?>';
</script>
<!-- If the JavaScript didn't work, here's a meta tag to do the job -->
<meta http-equiv="refresh" content="0; url=<?php echo $edit_url; ?>" />
</head>
<body>
<?php echo $lang['redirecting']; ?> <a href="<?php echo $edit_url; ?>"><?php echo $lang['here']; ?></a>
</body>
</html>
<?php }
printf('%s <a href="%s">%s</a>',_('Redirecting...'),$edit_url,_('here'));
echo '</body></html>';
}
?>