phpldapadmin/htdocs/entry_chooser.php

126 lines
4.6 KiB
PHP
Raw Normal View History

2009-06-30 08:05:37 +00:00
<?php
2009-06-30 11:52:55 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/entry_chooser.php,v 1.31.2.5 2008/12/12 12:20:22 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 11:52:55 +00:00
$entry = array();
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>';
2009-06-30 11:51:50 +00:00
echo '<div class="popup">';
printf('<h3 class="subtitle">%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 11:51:50 +00:00
echo '<table class="forminput" width=100% border=0>';
2009-06-30 10:46:00 +00:00
if ($entry['container']) {
2009-06-30 11:51:50 +00:00
printf('<tr><td class="heading" colspan=3>%s:</td><td>%s</td></tr>',_('Server'),htmlspecialchars($ldapserver->name));
printf('<tr><td class="heading" colspan=3>%s:</td><td>%s</td></tr>',_('Looking in'),htmlspecialchars($entry['container']));
echo '<tr><td class="blank" 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 11:52:55 +00:00
error(_('Not enough information to login to server. Please check your configuration.'),'error','index.php');
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>';
2009-06-30 11:51:50 +00:00
echo '<td class="blank">&nbsp;</td>';
2009-06-30 11:52:55 +00:00
printf('<td class="icon"><a href="%s"><img src="%s/up.png" alt="Up" /></a></td>',$href['up'],IMGDIR);
2009-06-30 11:51:50 +00:00
printf('<td colspan=2><a href="%s">%s</a></td>',$href['up'],_('Back Up...'));
2009-06-30 10:46:00 +00:00
echo '</tr>';
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
if (! count($entry['children']))
2009-06-30 11:51:50 +00:00
printf('<td class="blank" colspan=2>&nbsp;</td><td 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>';
2009-06-30 11:51:50 +00:00
echo '<td class="blank">&nbsp;</td>';
2009-06-30 11:52:55 +00:00
printf('<td class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>',$href['expand'],IMGDIR);
2009-06-30 10:46:00 +00:00
2009-06-30 11:51:50 +00:00
printf('<td colspan=2><a href="%s">%s</a></td>',$href['return'],htmlspecialchars($dn));
2009-06-30 10:46:00 +00:00
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 11:51:50 +00:00
printf('<tr><td class="heading" colspan=3>%s:</td><td class="heading">%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 11:51:50 +00:00
printf('<tr><td class="blank">&nbsp;</td><td 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>';
2009-06-30 11:51:50 +00:00
echo '<td class="blank">&nbsp;</td>';
2009-06-30 11:52:55 +00:00
printf('<td colspan=2 class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>',$href['expand'],IMGDIR);
2009-06-30 11:51:50 +00:00
printf('<td colspan=2><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
2009-06-30 11:51:50 +00:00
echo '<tr><td class="blank" 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>';
2009-06-30 11:51:50 +00:00
echo '</body>';
2009-06-30 08:05:37 +00:00
?>