phpldapadmin/htdocs/mass_delete.php

148 lines
5.0 KiB
PHP
Raw Normal View History

2009-06-30 08:09:20 +00:00
<?php
2009-06-30 09:29:51 +00:00
/**
2009-07-06 05:19:42 +00:00
* Displays a last chance confirmation form to delete a DN.
2009-06-30 09:29:51 +00:00
*
* @package phpLDAPadmin
2009-07-06 05:19:42 +00:00
* @subpackage Page
2009-06-30 09:29:51 +00:00
*/
2009-07-06 05:19:42 +00:00
2009-06-30 09:29:51 +00:00
/**
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-07-06 05:19:42 +00:00
# The DN we are working with
$request = array();
$request['dn'] = get_request('dn','REQUEST');
2009-07-07 09:40:48 +00:00
if (! $request['dn'])
system_message(array(
'title'=>_('No entry selected'),
'body'=>_('No entry was selected to delete'),
'type'=>'warn'),'index.php');
2009-07-06 05:19:42 +00:00
if (! is_array($request['dn']))
$request['dn'] = array($request['dn']);
$request['children'] = array();
$request['parent'] = array();
foreach ($request['dn'] as $dn) {
# Check if the entry exists.
if (! $dn || ! $app['server']->dnExists($dn))
system_message(array(
'title'=>_('Entry does not exist'),
'body'=>sprintf('%s (%s/%s)',_('The entry does not exist and will be ignored'),$dn),
'type'=>'error'));
# We search all children, not only the visible children in the tree
if (! in_array_ignore_case($dn,$request['children'])) {
$request['children'] = array_merge($request['children'],$app['server']->getContainerContents($dn,null,0,'(objectClass=*)',LDAP_DEREF_NEVER));
array_push($request['parent'],$dn);
}
}
2009-06-30 10:46:00 +00:00
2009-07-06 05:19:42 +00:00
printf('<h3 class="title">%s</h3>',_('Mass Delete'));
printf('<h3 class="subtitle">%s: <b>%s</b></h3>',_('Server'),$app['server']->getName());
echo "\n";
2009-06-30 10:26:08 +00:00
2009-07-06 05:19:42 +00:00
echo '<center>';
2010-02-24 15:03:10 +00:00
echo '<table class="forminput" border="0">';
2009-06-30 08:09:20 +00:00
2009-07-06 05:19:42 +00:00
if (count($request['parent']) == 1)
2010-02-24 15:03:10 +00:00
printf('<tr><td colspan="4"><b>%s</b></td></tr>',_('Are you sure you want to permanently delete this object?'));
2009-07-06 05:19:42 +00:00
else
2010-02-24 15:03:10 +00:00
printf('<tr><td colspan="4"><b>%s</b></td></tr>',_('Are you sure you want to permanently delete these objects?'));
2009-06-30 08:09:20 +00:00
2010-02-24 15:03:10 +00:00
echo '<tr><td colspan="4">&nbsp;</td></tr>';
printf('<tr><td style="width: 10%%;">%s:</td><td colspan="3" style="width: 75%%;"><b>%s</b></td></tr>',_('Server'),$app['server']->getName());
2009-06-30 08:09:20 +00:00
2009-07-06 05:19:42 +00:00
foreach ($request['parent'] as $dn)
2010-02-24 15:03:10 +00:00
printf('<tr><td style="width: 10%%;"><acronym title="%s">%s</acronym></td><td colspan="3" style="width: 75%%;"><b>%s</b></td></tr>',
2009-07-06 05:19:42 +00:00
_('Distinguished Name'),_('DN'),$dn);
2009-06-30 08:09:20 +00:00
2010-02-24 15:03:10 +00:00
echo '<tr><td colspan="4">&nbsp;</td></tr>';
2009-06-30 08:09:20 +00:00
2009-07-06 05:19:42 +00:00
$request['delete'] = $request['parent'];
2009-06-30 08:09:20 +00:00
2009-07-06 05:19:42 +00:00
if (count($request['children'])) {
2010-02-24 15:03:10 +00:00
printf('<tr><td colspan="4"><b>%s</b></td></tr>',_('Permanently delete all children also?'));
echo '<tr><td colspan="4">&nbsp;</td></tr>';
2009-06-30 09:29:51 +00:00
2009-07-06 05:19:42 +00:00
# We need to see if the children have children
$query = array();
$query['scope'] = 'sub';
$query['attrs'] = array('dn');
$query['size_limit'] = 0;
$query['deref'] = LDAP_DEREF_NEVER;
2009-06-30 09:29:51 +00:00
2009-07-06 05:19:42 +00:00
$request['search'] = array();
foreach ($request['children'] as $dn) {
$query['base'] = $dn;
$request['search'] = array_merge($request['search'],$app['server']->query($query,null));
2009-06-30 09:29:51 +00:00
}
2009-07-06 05:19:42 +00:00
foreach ($request['search'] as $value)
array_push($request['delete'],$value['dn']);
2009-06-30 09:29:51 +00:00
2009-07-06 05:19:42 +00:00
echo '<tr>';
2010-02-24 15:03:10 +00:00
echo '<td colspan="4">';
2009-07-06 05:19:42 +00:00
printf(_('This request also includes %s children entries.'),count($request['children']));
echo '</td></tr>';
2009-06-30 08:09:20 +00:00
2010-02-24 15:03:10 +00:00
printf('<tr><td colspan="4">%s</td></tr>',
2009-07-06 05:19:42 +00:00
sprintf(_('phpLDAPadmin can also recursively delete all %s of the child entries. See below for a list of all the entries that this action will delete. Do you want to do this?'),count($request['children'])));
2009-06-30 09:29:51 +00:00
2010-02-24 15:03:10 +00:00
echo '<tr><td colspan="4">&nbsp;</td></tr>';
2009-06-30 09:29:51 +00:00
2010-02-24 15:03:10 +00:00
printf('<tr><td colspan="4"><small>%s</small></td></tr>',
2009-07-06 05:19:42 +00:00
_('Note: this is potentially very dangerous and you do this at your own risk. This operation cannot be undone. Take into consideration aliases, referrals, and other things that may cause problems.'));
echo "\n";
2009-06-30 09:29:51 +00:00
2010-02-24 15:03:10 +00:00
echo '<tr><td colspan="4">&nbsp;</td></tr>';
2009-06-30 09:29:51 +00:00
2009-07-06 05:19:42 +00:00
echo "\n";
2009-06-30 09:29:51 +00:00
2010-02-24 15:03:10 +00:00
printf('<tr><td colspan="4"><center><b>%s</b></center></td></tr>',_('List of entries to be deleted:'));
echo '<tr><td colspan="4">&nbsp;</td></tr>';
2009-06-30 09:29:51 +00:00
2009-07-06 05:19:42 +00:00
$i = 0;
2010-02-24 15:03:10 +00:00
echo '<tr><td colspan="4"><center>';
2009-07-06 05:19:42 +00:00
printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,count($request['delete'])));
foreach ($request['delete'] as $key => $value)
printf('<option>%s. %s</option>',++$i,htmlspecialchars(dn_unescape($value)));
echo '</select>';
echo '</center></td></tr>';
echo "\n";
2009-06-30 08:09:20 +00:00
2010-02-24 15:03:10 +00:00
echo '<tr><td colspan="4">&nbsp;</td></tr>';
2009-06-30 10:26:08 +00:00
}
2009-07-06 05:19:42 +00:00
echo '<tr>';
2010-02-24 15:03:10 +00:00
echo '<td colspan="2" style="width: 50%; text-align: center;">';
2009-07-06 05:19:42 +00:00
echo '<form action="cmd.php" method="post">';
echo '<input type="hidden" name="cmd" value="rdelete" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
foreach ($request['parent'] as $dn)
printf('<input type="hidden" name="dn[]" value="%s" />',htmlspecialchars($dn));
printf('<input type="submit" value="%s" />',sprintf(_('Delete all %s objects'),count($request['delete'])));
echo '</form>';
echo '</center></td>';
2010-02-24 15:03:10 +00:00
echo '<td colspan="2" style="width: 50%; text-align: center;">';
2009-07-06 05:19:42 +00:00
echo '<form action="cmd.php" method="get">';
echo '<input type="hidden" name="cmd" value="template_engine" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="submit" name="submit" value="%s" />',_('Cancel'));
echo '</form>';
echo '</center></td>';
echo '</tr>';
echo "\n";
echo '</table>';
echo '</center>';
echo '<br />';
2009-06-30 08:09:20 +00:00
?>