phpldapadmin/htdocs/delete_form.php

158 lines
6.5 KiB
PHP
Raw Permalink Normal View History

2009-06-30 09:22:30 +00:00
<?php
2009-06-30 09:29:51 +00:00
/**
* Displays a last chance confirmation form to delete a DN.
2009-06-30 09:29:51 +00:00
*
* @package phpLDAPadmin
* @subpackage Page
2009-06-30 09:29:51 +00:00
*/
2009-06-30 09:29:51 +00:00
/**
2009-06-30 08:05:37 +00:00
*/
2009-06-30 09:22:30 +00:00
require './common.php';
2009-06-30 08:05:37 +00:00
# The DN we are working with
$request = array();
$request['dn'] = get_request('dn','GET');
2009-06-30 09:29:51 +00:00
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->setDN($request['dn']);
$request['page']->accept();
$request['template'] = $request['page']->getTemplate();
# Check if the entry exists.
if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
system_message(array(
'title'=>_('Entry does not exist'),
'body'=>sprintf('%s (%s)',_('The entry does not exist'),$request['dn']),
'type'=>'error'),'index.php');
2009-06-30 08:05:37 +00:00
2009-06-30 10:46:00 +00:00
# We search all children, not only the visible children in the tree
$request['children'] = $app['server']->getContainerContents($request['dn'],null,0,'(objectClass=*)',LDAP_DEREF_NEVER);
2009-06-30 08:05:37 +00:00
printf('<h3 class="title">%s %s</h3>',_('Delete'),htmlspecialchars(get_rdn($request['dn'])));
2009-06-30 10:26:08 +00:00
printf('<h3 class="subtitle">%s: <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>',
_('Server'),$app['server']->getName(),_('Distinguished Name'),$request['dn']);
2009-06-30 10:40:33 +00:00
echo "\n";
echo '<center>';
2009-06-30 08:05:37 +00:00
if (count($request['children'])) {
2009-06-30 10:26:08 +00:00
printf('<b>%s</b><br /><br />',_('Permanently delete all children also?'));
2009-06-30 09:29:51 +00:00
$search['href'] = htmlspecialchars(sprintf('cmd.php?cmd=query_engine&server_id=%s&filter=%s&base=%s&scope=sub&query=none&format=list',
$app['server']->getIndex(),rawurlencode('objectClass=*'),rawurlencode($request['dn'])));
$query = array();
$query['base'] = $request['dn'];
$query['scope'] = 'sub';
$query['attrs'] = array('dn');
$query['size_limit'] = 0;
$query['deref'] = LDAP_DEREF_NEVER;
$request['search'] = $app['server']->query($query,null);
2009-06-30 08:05:37 +00:00
2010-02-24 15:03:10 +00:00
echo '<table class="forminput" border="0">';
2009-06-30 10:40:33 +00:00
echo '<tr>';
2010-02-24 15:03:10 +00:00
echo '<td colspan="2">';
printf(_('This entry is the root of a sub-tree containing %s entries.'),count($request['search']));
2009-06-30 10:46:00 +00:00
printf(' <small>(<a href="%s">%s</a>)</small>',
$search['href'],_('view entries'));
echo '</td></tr>';
2009-06-30 10:40:33 +00:00
2010-02-24 15:03:10 +00:00
echo '<tr><td colspan="2">&nbsp;</td></tr>';
2009-06-30 10:46:00 +00:00
2010-02-24 15:03:10 +00:00
printf('<tr><td colspan="2">%s</td></tr>',
sprintf(_('phpLDAPadmin can recursively delete this entry and all %s of its children. See below for a list of all the entries that this action will delete. Do you want to do this?'),count($request['search'])));
2009-06-30 10:40:33 +00:00
2010-02-24 15:03:10 +00:00
echo '<tr><td colspan="2">&nbsp;</td></tr>';
2009-06-30 10:46:00 +00:00
2010-02-24 15:03:10 +00:00
printf('<tr><td colspan="2"><small>%s</small></td></tr>',
2009-06-30 10:40:33 +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";
echo '<tr>';
2010-02-24 15:03:10 +00:00
echo '<td style="width: 50%; text-align: center;">';
2010-03-13 09:45:40 +00:00
echo '<form action="cmd.php" method="post" id="delete_form">';
2009-06-30 10:46:00 +00:00
echo '<input type="hidden" name="cmd" value="rdelete" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="dn" value="%s" />',$request['template']->getDNEncode(false));
2010-03-13 09:45:40 +00:00
//@todo need to refresh the tree after a delete
printf('<input type="submit" value="%s" %s />',
sprintf(_('Delete all %s objects'),count($request['search'])),
(isAjaxEnabled() ? sprintf('onclick="return ajSUBMIT(\'BODY\',document.getElementById(\'delete_form\'),\'%s\');"',_('Deleting Object(s)')) : ''));
2009-06-30 10:40:33 +00:00
echo '</form>';
2010-02-24 15:03:10 +00:00
echo '</td>';
2009-06-30 10:40:33 +00:00
2010-02-24 15:03:10 +00:00
echo '<td style="width: 50%; text-align: center;">';
2009-06-30 10:46:00 +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="hidden" name="dn" value="%s" />',$request['template']->getDNEncode(false));
2010-03-13 09:45:40 +00:00
printf('<input type="submit" name="submit" value="%s" %s />',
_('Cancel'),
(isAjaxEnabled() ? sprintf('onclick="return ajDISPLAY(\'BODY\',\'cmd=template_engine&server_id=%s&dn=%s\',\'%s\');"',$app['server']->getIndex(),$request['template']->getDNEncode(),_('Retrieving DN')) : ''));
2009-06-30 10:40:33 +00:00
echo '</form>';
2010-02-24 15:03:10 +00:00
echo '</td>';
2009-06-30 10:40:33 +00:00
echo '</tr>';
echo "\n";
echo '</table>';
echo "\n";
echo '<br /><br />';
echo _('List of entries to be deleted:');
echo '<br />';
2009-06-30 10:46:00 +00:00
$i = 0;
printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,count($request['search'])));
foreach ($request['search'] as $key => $value)
printf('<option>%s. %s</option>',++$i,dn_unescape($value['dn']));
2009-06-30 10:40:33 +00:00
echo '</select>';
echo "\n";
} else {
2010-02-24 15:03:10 +00:00
echo '<table class="forminput" border="0">';
2009-06-30 10:40:33 +00:00
2010-02-24 15:03:10 +00:00
printf('<tr><td colspan="4">%s</td></tr>',_('Are you sure you want to permanently delete this object?'));
echo '<tr><td colspan="4">&nbsp;</td></tr>';
2009-06-30 10:40:33 +00:00
2010-02-24 15:03:10 +00:00
printf('<tr><td style="width: 10%%;">%s:</td><td colspan="3" style="width: 75%%;"><b>%s</b></td></tr>',_('Server'),$app['server']->getName());
printf('<tr><td style="width: 10%%;"><acronym title="%s">%s</acronym></td><td colspan="3" style="width: 75%%;"><b>%s</b></td></tr>',
_('Distinguished Name'),_('DN'),$request['dn']);
2010-02-24 15:03:10 +00:00
echo '<tr><td colspan="4">&nbsp;</td></tr>';
2009-06-30 10:40:33 +00:00
echo "\n";
echo '<tr>';
2010-02-24 15:03:10 +00:00
echo '<td colspan="2" style="width: 50%; text-align: center;">';
2010-03-13 09:45:40 +00:00
echo '<form action="cmd.php" method="post" id="delete_form">';
2009-06-30 10:46:00 +00:00
echo '<input type="hidden" name="cmd" value="delete" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="dn" value="%s" />',$request['template']->getDNEncode(false));
2010-03-13 09:45:40 +00:00
//@todo need to refresh the tree after a delete
printf('<input type="submit" name="submit" value="%s" %s />',
_('Delete'),
(isAjaxEnabled() ? sprintf('onclick="return ajSUBMIT(\'BODY\',document.getElementById(\'delete_form\'),\'%s\');"',_('Deleting Object(s)')) : ''));
2009-06-30 10:40:33 +00:00
echo '</form>';
2010-02-24 15:03:10 +00:00
echo '</td>';
echo '<td colspan="2" style="width: 50%; text-align: center;">';
2009-06-30 10:40:33 +00:00
2009-06-30 10:46:00 +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="hidden" name="dn" value="%s" />',$request['template']->getDNEncode(false));
2010-03-13 09:45:40 +00:00
printf('<input type="submit" name="submit" value="%s" %s />',
_('Cancel'),
(isAjaxEnabled() ? sprintf('onclick="return ajDISPLAY(\'BODY\',\'cmd=template_engine&server_id=%s&dn=%s\',\'%s\');"',$app['server']->getIndex(),$request['template']->getDNEncode(),_('Retrieving DN')) : ''));
2009-06-30 10:40:33 +00:00
echo '</form>';
2010-02-24 15:03:10 +00:00
echo '</td>';
2009-06-30 10:40:33 +00:00
echo '</tr>';
echo '</table>';
echo "\n";
}
echo '</center>';
echo '<br />';
?>