phpldapadmin/htdocs/entry_chooser.php

125 lines
4.6 KiB
PHP
Raw Normal View History

2009-06-30 08:05:37 +00:00
<?php
2009-06-30 11:46:44 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/entry_chooser.php,v 1.31.2.2 2007/12/29 08:24:10 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
2009-06-30 10:46:00 +00:00
include './common.php';
include HTDOCDIR.'header.php';
2009-06-30 08:07:14 +00:00
2009-06-30 10:46:00 +00:00
$entry['container'] = get_request('container','GET');
$entry['element'] = get_request('form_element','GET');
$entry['rdn'] = get_request('rdn','GET');
2009-06-30 08:05:37 +00:00
2009-06-30 10:46:00 +00:00
echo '<body>';
echo '<div class="entry_chooser">';
printf('<h3>%s</h3>',_('Entry Chooser'));
2009-06-30 09:22:30 +00:00
?>
2009-06-30 10:26:08 +00:00
<script type="text/javascript" language="javascript">
function returnDN(dn) {
2009-06-30 10:46:00 +00:00
opener.document.<?php echo $entry['element']; ?>.value = dn;
2009-06-30 09:22:30 +00:00
close();
}
</script>
<?php
2009-06-30 10:46:00 +00:00
echo '<table class="entry_chooser" border=0>';
if ($entry['container']) {
printf('<tr><td class="head" colspan=3>%s:</td><td class="value">%s</td></tr>',_('Server'),htmlspecialchars($ldapserver->name));
printf('<tr><td class="head" colspan=3>%s:</td><td class="value">%s</td></tr>',_('Looking in'),htmlspecialchars($entry['container']));
echo '<tr><td class="spacer" colspan=4>&nbsp;</td></tr>';
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 10:46:00 +00:00
if (isset($ldapserver) && ! is_null($entry['container'])) {
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.'));
2009-06-30 09:29:51 +00:00
2009-06-30 11:46:44 +00:00
$entry['children'] = $ldapserver->getContainerContents($entry['container'],0,'(objectClass=*)',$_SESSION[APPCONFIG]->GetValue('deref','tree'));
2009-06-30 10:46:00 +00:00
sort($entry['children']);
2009-06-30 09:29:51 +00:00
foreach ($ldapserver->getBaseDN() as $base_dn) {
2009-06-30 10:46:00 +00:00
if (DEBUG_ENABLED)
2009-06-30 11:46:44 +00:00
debug_log('Comparing BaseDN [%s] with container [%s]',64,__FILE__,__LINE__,__METHOD__,$base_dn,$entry['container']);
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
if (! pla_compare_dns($entry['container'],$base_dn)) {
2009-06-30 09:29:51 +00:00
$parent_container = false;
2009-06-30 10:46:00 +00:00
$href['up'] = htmlspecialchars(sprintf('entry_chooser.php?form_element=%s&rdn=%s',$entry['element'],$entry['rdn']));
2009-06-30 09:29:51 +00:00
break;
} else {
2009-06-30 10:46:00 +00:00
$parent_container = get_container($entry['container']);
$href['up'] = htmlspecialchars(sprintf('entry_chooser.php?form_element=%s&rdn=%s&server_id=%s&container=%s',
$entry['element'],$entry['rdn'],$ldapserver->server_id,rawurlencode($parent_container)));
2009-06-30 09:29:51 +00:00
}
2009-06-30 08:05:37 +00:00
}
2009-06-30 10:46:00 +00:00
echo '<tr>';
echo '<td class="spacer">&nbsp;</td>';
printf('<td class="icon"><a href="%s"><img src="images/up.png" alt="Up" /></a></td>',$href['up']);
printf('<td class="value" colspan=2><a href="%s">%s</a></td>',$href['up'],_('Back Up...'));
echo '</tr>';
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
if (! count($entry['children']))
printf('<td class="spacer" colspan=2>&nbsp;</td><td class="body" colspan=2">(%s)</td>',_('no entries'));
2009-06-30 09:29:51 +00:00
2009-06-30 08:05:37 +00:00
else
2009-06-30 10:46:00 +00:00
foreach ($entry['children'] as $dn) {
$href['return'] = sprintf("javascript:returnDN('%s%s')",($entry['rdn'] ? sprintf('%s,',$entry['rdn']) : ''),rawurlencode($dn));
$href['expand'] = htmlspecialchars(sprintf('entry_chooser.php?server_id=%s&form_element=%s&rdn=%s&container=%s',
$ldapserver->server_id,$entry['element'],$entry['rdn'],rawurlencode($dn)));
echo '<tr>';
echo '<td class="spacer">&nbsp;</td>';
printf('<td class="icon"><a href="%s"><img src="images/plus.png" alt="Plus" /></a></td>',$href['expand']);
printf('<td colspan=2 class="body"><a href="%s">%s</a></td>',$href['return'],htmlspecialchars($dn));
echo '</tr>';
echo "\n\n";
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 {
2009-06-30 11:46:44 +00:00
foreach ($_SESSION[APPCONFIG]->ldapservers->GetServerList() as $id) {
2009-06-30 09:29:51 +00:00
2009-06-30 11:46:44 +00:00
$ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance($id);
2009-06-30 09:29:51 +00:00
if ($ldapserver->isVisible()) {
if (! $ldapserver->haveAuthInfo())
continue;
2009-06-30 08:07:14 +00:00
else {
2009-06-30 10:46:00 +00:00
printf('<tr><td class="head" colspan=3>%s:</td><td class="value">%s</td></tr>',_('Server'),htmlspecialchars($ldapserver->name));
2009-06-30 09:29:51 +00:00
foreach ($ldapserver->getBaseDN() as $dn) {
if (! $dn) {
2009-06-30 10:46:00 +00:00
printf('<tr><td class="spacer">&nbsp;</td><td class="body" colspan=3>(%s)</td></tr>',_('Could not determine base DN'));
2009-06-30 09:29:51 +00:00
} else {
2009-06-30 10:46:00 +00:00
$href['return'] = sprintf("javascript:returnDN('%s%s')",($entry['rdn'] ? sprintf('%s,',$entry['rdn']) : ''),rawurlencode($dn));
$href['expand'] = htmlspecialchars(sprintf('entry_chooser.php?server_id=%s&form_element=%s&rdn=%s&container=%s',
$ldapserver->server_id,$entry['element'],$entry['rdn'],rawurlencode($dn)));
echo '<tr>';
echo '<td class="spacer">&nbsp;</td>';
printf('<td colspan=2 class="icon"><a href="%s"><img src="images/plus.png" alt="Plus" /></a></td>',$href['expand']);
printf('<td colspan=2 class="body"><a href="%s">%s</a></td>',$href['return'],htmlspecialchars($dn));
2009-06-30 09:29:51 +00:00
}
2009-06-30 08:07:14 +00:00
}
2009-06-30 10:46:00 +00:00
echo '<tr><td class="spacer" colspan=4>&nbsp;</td></tr>';
2009-06-30 08:07:14 +00:00
}
2009-06-30 08:05:37 +00:00
}
}
}
2009-06-30 10:46:00 +00:00
echo '</table>';
echo '</div>';
echo '</body></html>';
2009-06-30 08:05:37 +00:00
?>