phpldapadmin/htdocs/entry_chooser.php

116 lines
3.5 KiB
PHP
Raw Normal View History

2009-06-30 08:05:37 +00:00
<?php
2009-06-30 10:26:08 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/entry_chooser.php,v 1.27.2.4 2005/12/31 03:13:48 wurley Exp $
2009-06-30 08:05:37 +00:00
2009-06-30 09:29:51 +00:00
/**
* Display a selection (popup window) to pick a DN.
*
* @package phpLDAPadmin
*/
/**
*/
2009-06-30 09:22:30 +00:00
require './common.php';
2009-06-30 08:07:14 +00:00
2009-06-30 09:29:51 +00:00
$container = isset($_GET['container']) ? rawurldecode($_GET['container']) : false;
$return_form_element = isset($_GET['form_element']) ? htmlspecialchars($_GET['form_element']) : null;
$rdn = isset($_GET['rdn']) ? htmlspecialchars($_GET['rdn']) : null;
2009-06-30 08:05:37 +00:00
2009-06-30 09:29:51 +00:00
include "./header.php";
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
printf('<h3 class="subtitle">%s</h3>',_('Entry Chooser'));
2009-06-30 09:22:30 +00:00
flush();
?>
2009-06-30 10:26:08 +00:00
<script type="text/javascript" language="javascript">
function returnDN(dn) {
2009-06-30 09:22:30 +00:00
opener.document.<?php echo $return_form_element; ?>.value = dn;
close();
}
</script>
<?php
2009-06-30 09:29:51 +00:00
if ($container) {
2009-06-30 10:26:08 +00:00
printf('%s<b>%s</b>',_('Server: '),htmlspecialchars($ldapserver->name));
echo '<br />';
printf('%s<b>%s</b>',_('Looking in: '),htmlspecialchars($container));
echo '<br />';
2009-06-30 08:05:37 +00:00
}
2009-06-30 08:07:14 +00:00
/* Has the use already begun to descend into a specific server tree? */
2009-06-30 09:29:51 +00:00
if (isset($ldapserver) && $container !== false) {
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 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
$dn_list = $ldapserver->getContainerContents($container,0,'(objectClass=*)',$config->GetValue('deref','tree'));
2009-06-30 09:29:51 +00:00
sort($dn_list);
foreach ($ldapserver->getBaseDN() as $base_dn) {
2009-06-30 09:40:37 +00:00
if (DEBUG_ENABLED)
2009-06-30 10:26:08 +00:00
debug_log('entry_chooser.php: Comparing BaseDN [%s] with container [%s]',64,$base_dn,$container);
2009-06-30 09:29:51 +00:00
if (! pla_compare_dns($container,$base_dn)) {
$parent_container = false;
2009-06-30 10:26:08 +00:00
$up_href = sprintf('entry_chooser.php?form_element=%s&amp;rdn=%s',$return_form_element,$rdn);
2009-06-30 09:29:51 +00:00
break;
} else {
$parent_container = get_container($container);
2009-06-30 10:26:08 +00:00
$up_href = sprintf('entry_chooser.php?form_element=%s&amp;rdn=%s&amp;server_id=%s&amp;container=%s',
2009-06-30 09:29:51 +00:00
$return_form_element,$rdn,$ldapserver->server_id,rawurlencode($parent_container));
}
2009-06-30 08:05:37 +00:00
}
2009-06-30 10:26:08 +00:00
echo '&nbsp;';
printf('<a href="%s" style="text-decoration:none"><img src="images/up.png" /> %s</a>',$up_href,_('Back Up...'));
echo '<br />';
2009-06-30 09:29:51 +00:00
if (! count($dn_list))
2009-06-30 10:26:08 +00:00
printf('&nbsp;&nbsp;&nbsp;(%s)<br />',_('no entries'));
2009-06-30 09:29:51 +00:00
2009-06-30 08:05:37 +00:00
else
2009-06-30 09:29:51 +00:00
foreach ($dn_list as $dn) {
$href = sprintf("javascript:returnDN('%s%s')",($rdn ? "$rdn," : ''),$dn);
2009-06-30 10:26:08 +00:00
echo '&nbsp;&nbsp;&nbsp;';
printf('<a href="entry_chooser.php?server_id=%s&amp;form_element=%s&amp;rdn=%s&amp;container=%s"><img src="images/plus.png" /></a>',
2009-06-30 09:29:51 +00:00
$ldapserver->server_id,$return_form_element,$rdn,rawurlencode($dn));
printf('<a href="%s">%s</a>',$href,htmlspecialchars($dn));
2009-06-30 10:26:08 +00:00
echo '<br />';
2009-06-30 08:05:37 +00:00
}
2009-06-30 09:29:51 +00:00
2009-06-30 08:07:14 +00:00
/* draw the root of the selection tree (ie, list all the servers) */
2009-06-30 09:29:51 +00:00
} else {
foreach ($ldapservers->GetServerList() as $id) {
$ldapserver = $ldapservers->Instance($id);
if ($ldapserver->isVisible()) {
if (! $ldapserver->haveAuthInfo())
continue;
2009-06-30 08:07:14 +00:00
else {
2009-06-30 09:29:51 +00:00
printf('<b>%s</b>',htmlspecialchars($ldapserver->name));
2009-06-30 10:26:08 +00:00
echo '<br />';
2009-06-30 09:29:51 +00:00
foreach ($ldapserver->getBaseDN() as $dn) {
if (! $dn) {
2009-06-30 10:26:08 +00:00
printf('<small>&nbsp;&nbsp;&nbsp;(%s)</small><br />',_('Could not determine base DN'));
2009-06-30 09:29:51 +00:00
} else {
$href = sprintf("javascript:returnDN('%s%s')",($rdn ? "$rdn," : ''),$dn);
2009-06-30 10:26:08 +00:00
echo '&nbsp;&nbsp;&nbsp;';
printf('<a href="entry_chooser.php?server_id=%s&amp;form_element=%s&amp;rdn=%s&amp;container=%s"><img src="images/plus.png" /></a> ',
2009-06-30 09:29:51 +00:00
$ldapserver->server_id,$return_form_element,$rdn,rawurlencode($dn));
printf('<a href="%s">%s</a>',$href,htmlspecialchars($dn));
2009-06-30 10:26:08 +00:00
echo '<br />';
2009-06-30 09:29:51 +00:00
}
2009-06-30 08:07:14 +00:00
}
}
2009-06-30 08:05:37 +00:00
}
}
}
?>