phpldapadmin/htdocs/delete.php

53 lines
1.6 KiB
PHP
Raw Normal View History

2009-06-30 09:22:30 +00:00
<?php
2009-06-30 11:46:44 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete.php,v 1.27.2.2 2007/12/26 09:26:32 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.
*
* 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 08:05:37 +00:00
2009-06-30 11:46:44 +00:00
if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_delete', 'simple_delete'))
2009-06-30 10:46:00 +00:00
pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete entry')));
2009-06-30 08:07:14 +00:00
2009-06-30 10:46:00 +00:00
$entry['dn'] = get_request('dn');
if (! $entry['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:46:00 +00:00
if (! $ldapserver->dnExists($entry['dn']))
pla_error(sprintf(_('No such entry: %s'),'<b>'.pretty_print_dn($entry['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.
2009-06-30 10:46:00 +00:00
if (run_hook('pre_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn'])))
$result = $ldapserver->delete($entry['dn']);
2009-06-30 09:29:51 +00:00
else
2009-06-30 10:46:00 +00:00
pla_error(sprintf(_('Could not delete the entry: %s'),'<b>'.pretty_print_dn($entry['dn']).'</b>'));
2009-06-30 08:09:20 +00:00
2009-06-30 10:46:00 +00:00
if ($result) {
2009-06-30 09:29:51 +00:00
# Custom callback
2009-06-30 10:46:00 +00:00
run_hook('post_entry_delete',
array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn']));
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
system_message(array(
'title'=>_('Delete DN'),
'body'=>_('Successfully deleted DN ').sprintf('<b>%s</b>',$entry['dn']),
'type'=>'info'),
2009-06-30 11:46:44 +00:00
sprintf('index.php?server_id=%s',$ldapserver->server_id));
2009-06-30 08:05:37 +00:00
} else {
2009-06-30 10:46:00 +00:00
pla_error(sprintf(_('Could not delete the entry: %s'),'<b>'.pretty_print_dn($entry['dn']).'</b>'),
$ldapserver->error(),$ldapserver->errno());
2009-06-30 08:05:37 +00:00
}
2009-06-30 09:29:51 +00:00
?>