isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
$dn = $_POST['dn'];
if (! $dn)
pla_error(_('You must specify a DN'));
if (! $ldapserver->dnExists($dn))
pla_error(sprintf(_('No such entry: %s'),htmlspecialchars($dn)));
include './header.php';
echo '
';
printf(''._('Deleting %s').'
',htmlspecialchars(get_rdn($dn)));
printf('%s
',_('Recursive delete progress'));
echo '
';
echo '';
flush();
# prevent script from bailing early on a long delete
@set_time_limit(0);
$del_result = pla_rdelete($ldapserver,$dn);
echo '
';
if ($del_result) {
echo '';
printf(_('Entry %s and sub-tree deleted successfully.'),''.htmlspecialchars($dn).'');
} else {
pla_error(sprintf(_('Could not delete the entry: %s'),htmlspecialchars($dn)),
$ldapserver->error(),$ldapserver->errno());
}
function pla_rdelete($ldapserver,$dn) {
$children = $ldapserver->getContainerContents($dn);
if (! is_array($children) || count($children) == 0) {
printf(''._('Deleting %s').'...',htmlspecialchars($dn));
flush();
if (run_hook('pre_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn)))
if ($ldapserver->delete($dn)) {
run_hook('post_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn));
printf(' %s
',_('Success'));
return true;
} else {
pla_error(sprintf(_('Failed to delete entry %s'),htmlspecialchars($dn)),
$ldapserver->error(),$ldapserver->errno());
}
} else {
foreach ($children as $child_dn)
pla_rdelete($ldapserver,$child_dn);
printf(''._('Deleting %s').'...',htmlspecialchars($dn));
flush();
if (run_hook('pre_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn)))
if ($ldapserver->delete($dn)) {
run_hook('post_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn));
printf(' %s
',_('Success'));
return true;
} else {
pla_error(sprintf(_('Failed to delete entry %s'),htmlspecialchars($dn)),
$ldapserver->error(),$ldapserver->errno());
}
}
}
?>