2009-06-30 08:09:20 +00:00
|
|
|
<?php
|
2009-06-30 10:40:03 +00:00
|
|
|
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/mass_delete.php,v 1.16 2005/12/17 00:00:11 wurley Exp $
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
/**
|
2009-06-30 08:09:20 +00:00
|
|
|
* Enables user to mass delete multiple entries using checkboxes.
|
|
|
|
*
|
2009-06-30 09:29:51 +00:00
|
|
|
* Variables that come in via common.php
|
|
|
|
* - server_id
|
2009-06-30 08:09:20 +00:00
|
|
|
* Variables that come in as GET vars:
|
|
|
|
* - mass_delete - an array of DNs to delete in this form:
|
|
|
|
* Array (
|
|
|
|
* [o=myorg,dc=example,dc=com] => on
|
|
|
|
* [cn=bob,dc=example,dc=com] => on
|
|
|
|
* etc.
|
2009-06-30 09:29:51 +00:00
|
|
|
*
|
|
|
|
* @package phpLDAPadmin
|
|
|
|
*/
|
|
|
|
/**
|
2009-06-30 08:09:20 +00:00
|
|
|
*/
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
require './common.php';
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
if( $ldapserver->isReadOnly() )
|
2009-06-30 10:26:08 +00:00
|
|
|
pla_error(_('Unable to delete, server is in READY-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.'));
|
|
|
|
|
|
|
|
$confirmed = isset($_POST['confirmed']) ? true : false;
|
|
|
|
isset($_POST['mass_delete']) or
|
|
|
|
pla_error(_('Error calling mass_delete.php. Missing mass_delete in POST vars.'));
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
$mass_delete = $_POST['mass_delete'];
|
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
is_array($mass_delete) or
|
|
|
|
pla_error(_('mass_delete POST var is not an array.'));
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
$ldapserver->isMassDeleteEnabled() or
|
2009-06-30 10:26:08 +00:00
|
|
|
pla_error(_('Mass deletion is not enabled. Please enable it in config.php before proceeding.'));
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
require './header.php';
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '<body>';
|
|
|
|
printf('<h3 class="title">%s</h3>',_('Mass Deleting'));
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
if ($confirmed == true) {
|
|
|
|
printf('<h3 class="subtitle">'._('Deletion progress on server "%s"').'</h3>',$ldapserver->name);
|
|
|
|
echo '<blockquote>';
|
|
|
|
echo '<small>';
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
$successfully_delete_dns = array();
|
|
|
|
$failed_dns = array();
|
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
if (! is_array($mass_delete))
|
|
|
|
pla_error(_('Malformed mass_delete array.'));
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
if (count($mass_delete) == 0) {
|
|
|
|
echo '<br />';
|
|
|
|
printf('<center>%s</center>',_('You did not select any entries to delete.'));
|
2009-06-30 09:29:51 +00:00
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
// @todo: Should sort these entries, so that they are deleted in order, if a user selects children.
|
|
|
|
foreach ($mass_delete as $dn => $junk) {
|
|
|
|
printf(_('Deleting %s'),htmlspecialchars($dn));
|
2009-06-30 09:29:51 +00:00
|
|
|
flush();
|
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
if(run_hook('pre_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn))) {
|
|
|
|
$success = $ldapserver->delete($dn);
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
if ($success) {
|
|
|
|
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
|
|
|
printf(' <span style="color:green">%s</span>.<br />',_('Success'));
|
2009-06-30 09:29:51 +00:00
|
|
|
$successfully_delete_dns[] = $dn;
|
|
|
|
|
|
|
|
} else {
|
2009-06-30 10:26:08 +00:00
|
|
|
printf(' <span style="color:red">%s</span>.<br /> (%s)<br />',_('Failed'),$ldapserver->error());
|
2009-06-30 09:29:51 +00:00
|
|
|
$failed_dns[] = $dn;
|
|
|
|
}
|
2009-06-30 08:09:20 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
flush();
|
|
|
|
}
|
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '<blockquote>';
|
|
|
|
echo '</small>';
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
$failed_count = count($failed_dns);
|
|
|
|
$total_count = count($mass_delete);
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
if ($failed_count > 0)
|
|
|
|
printf('<span style="color: red; font-weight: bold;">'._('%s of %s entries failed to be deleted.').'</span>',$failed_count,$total_count);
|
|
|
|
else
|
|
|
|
printf('<span style="color: green; font-weight: bold;">%s</span>',_('All entries deleted successfully.'));
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '<script language="javascript">parent.left_frame.location.reload();</script>';
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
} else {
|
2009-06-30 10:26:08 +00:00
|
|
|
$n = count($mass_delete);
|
|
|
|
printf('<h3 class="subtitle">'._('Confirm mass delete of %s entries on server %s').'</h3>',$n,$ldapserver->name);
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo'<center>';
|
|
|
|
printf(_('Do you really want to delete %s %s %s'),
|
|
|
|
($n == 1? _('this') : _('these')),$n,($n == 1 ? _('entry') : _('entries')));
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '<form action="mass_delete.php" method="post">';
|
|
|
|
echo '<input type="hidden" name="confirmed" value="true" />';
|
|
|
|
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '<table><tr><td><ol>';
|
|
|
|
foreach ($mass_delete as $dn => $junk)
|
|
|
|
printf('<input type="hidden" name="mass_delete[%s]" value="on" /><li>%s</li>',htmlspecialchars($dn),htmlspecialchars($dn));
|
|
|
|
echo '</ol></td></tr></table>';
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
printf('<input class="scary" type="submit" value="%s" /></center>',_('Yes, delete!'));
|
|
|
|
echo '</form>';
|
|
|
|
}
|
2009-06-30 08:09:20 +00:00
|
|
|
?>
|