phpldapadmin/htdocs/delete.php

56 lines
1.6 KiB
PHP
Raw Normal View History

2009-06-30 09:22:30 +00:00
<?php
2009-06-30 10:40:03 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete.php,v 1.26 2005/12/17 00:00:11 wurley Exp $
2009-06-30 08:05:37 +00:00
2009-06-30 09:29:51 +00:00
/**
2009-06-30 08:05:37 +00:00
* Deletes a DN and presents a "job's done" message.
*
2009-06-30 09:29:51 +00:00
* Variables that come in via common.php
* - server_id
2009-06-30 08:05:37 +00:00
* Variables that come in as POST vars:
* - dn (rawurlencoded)
2009-06-30 09:29:51 +00:00
*
* @package phpLDAPadmin
*/
/**
2009-06-30 08:05:37 +00:00
*/
2009-06-30 09:29:51 +00:00
require './common.php';
2009-06-30 08:05:37 +00:00
2009-06-30 09:29:51 +00:00
if ($ldapserver->isReadOnly())
2009-06-30 10:26:08 +00:00
pla_error(_('You cannot perform updates while server is in read-only mode'));
2009-06-30 09:29:51 +00:00
if (! $ldapserver->haveAuthInfo())
2009-06-30 10:26:08 +00:00
pla_error(_('Not enough information to login to server. Please check your configuration.'));
2009-06-30 08:05:37 +00:00
2009-06-30 09:29:51 +00:00
$dn = $_POST['dn'];
2009-06-30 08:07:14 +00:00
2009-06-30 09:29:51 +00:00
if (is_null($dn))
2009-06-30 10:26:08 +00:00
pla_error(_('You must specify a DN'));
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
if (! $ldapserver->dnExists($dn))
pla_error(sprintf(_('No such entry: %s'),'<b>'.pretty_print_dn($dn).'</b>'));
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
# Check the user-defined custom callback first.
if (run_hook('pre_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn)))
$del_result = $ldapserver->delete($dn);
2009-06-30 09:29:51 +00:00
else
2009-06-30 10:26:08 +00:00
pla_error(sprintf(_('Could not delete the entry: %s'),'<b>'.pretty_print_dn($dn).'</b>'));
2009-06-30 08:09:20 +00:00
2009-06-30 09:29:51 +00:00
if ($del_result) {
# Custom callback
2009-06-30 10:26:08 +00:00
run_hook('post_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn));
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
include './header.php';
echo '<body>';
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
echo '<script type="text/javascript" language="javascript">parent.left_frame.location.reload();</script>';
echo '<br /><br />';
printf('<center>'._('Entry %s deleted successfully.').'</center>','<b>'.pretty_print_dn($dn).'</b>');
echo '</body>';
2009-06-30 08:05:37 +00:00
} else {
2009-06-30 10:26:08 +00:00
pla_error(sprintf(_('Could not delete the entry: %s'),'<b>'.pretty_print_dn($dn).'</b>'),
$ldapserver->error(),$ldapserver->errno());
2009-06-30 08:05:37 +00:00
}
2009-06-30 10:26:08 +00:00
echo '</html>';
2009-06-30 09:29:51 +00:00
?>