Latest SANDPIT - MERGE from CVS (MERGE-GIT)
This commit is contained in:
@@ -1,125 +1,123 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/entry_chooser.php,v 1.31.2.5 2008/12/12 12:20:22 wurley Exp $
|
||||
// $Header$
|
||||
|
||||
/**
|
||||
* Display a selection (popup window) to pick a DN.
|
||||
*
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Page
|
||||
*/
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
include './common.php';
|
||||
include HTDOCDIR.'header.php';
|
||||
|
||||
$entry = array();
|
||||
$entry['container'] = get_request('container','GET');
|
||||
$entry['element'] = get_request('form_element','GET');
|
||||
$entry['rdn'] = get_request('rdn','GET');
|
||||
$www['page'] = new page();
|
||||
|
||||
$request = array();
|
||||
$request['container'] = get_request('container','GET');
|
||||
$request['element'] = get_request('form_element','GET');
|
||||
$request['rdn'] = get_request('rdn','GET');
|
||||
|
||||
echo '<body>';
|
||||
echo '<div class="popup">';
|
||||
printf('<h3 class="subtitle">%s</h3>',_('Entry Chooser'));
|
||||
?>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
function returnDN(dn) {
|
||||
opener.document.<?php echo $entry['element']; ?>.value = dn;
|
||||
close();
|
||||
}
|
||||
</script>
|
||||
echo '<script type="text/javascript" language="javascript">';
|
||||
echo ' function returnDN(dn) {';
|
||||
printf(' opener.document.%s.value = dn;',$request['element']);
|
||||
echo ' close();';
|
||||
echo ' }';
|
||||
echo '</script>';
|
||||
|
||||
<?php
|
||||
echo '<table class="forminput" width=100% border=0>';
|
||||
if ($entry['container']) {
|
||||
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']));
|
||||
if ($request['container']) {
|
||||
printf('<tr><td class="heading" colspan=3>%s:</td><td>%s</td></tr>',_('Server'),$app['server']->getName());
|
||||
printf('<tr><td class="heading" colspan=3>%s:</td><td>%s</td></tr>',_('Looking in'),$request['container']);
|
||||
echo '<tr><td class="blank" colspan=4> </td></tr>';
|
||||
}
|
||||
|
||||
/* Has the use already begun to descend into a specific server tree? */
|
||||
if (isset($ldapserver) && ! is_null($entry['container'])) {
|
||||
# Has the user already begun to descend into a specific server tree?
|
||||
if (isset($app['server']) && ! is_null($request['container'])) {
|
||||
|
||||
if (! $ldapserver->haveAuthInfo())
|
||||
error(_('Not enough information to login to server. Please check your configuration.'),'error','index.php');
|
||||
$request['children'] = $app['server']->getContainerContents($request['container'],null,0,'(objectClass=*)',$_SESSION[APPCONFIG]->getValue('deref','tree'));
|
||||
sort($request['children']);
|
||||
|
||||
$entry['children'] = $ldapserver->getContainerContents($entry['container'],0,'(objectClass=*)',$_SESSION[APPCONFIG]->GetValue('deref','tree'));
|
||||
sort($entry['children']);
|
||||
|
||||
foreach ($ldapserver->getBaseDN() as $base_dn) {
|
||||
foreach ($app['server']->getBaseDN() as $base) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Comparing BaseDN [%s] with container [%s]',64,__FILE__,__LINE__,__METHOD__,$base_dn,$entry['container']);
|
||||
debug_log('Comparing BaseDN [%s] with container [%s]',64,__FILE__,__LINE__,__METHOD__,$base,$request['container']);
|
||||
|
||||
if (! pla_compare_dns($entry['container'],$base_dn)) {
|
||||
if (! pla_compare_dns($request['container'],$base)) {
|
||||
$parent_container = false;
|
||||
$href['up'] = htmlspecialchars(sprintf('entry_chooser.php?form_element=%s&rdn=%s',$entry['element'],$entry['rdn']));
|
||||
$href['up'] = sprintf('entry_chooser.php?form_element=%s&rdn=%s',$request['element'],rawurlencode($request['rdn']));
|
||||
break;
|
||||
|
||||
} else {
|
||||
$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)));
|
||||
$parent_container = $app['server']->getContainer($request['container']);
|
||||
$href['up'] = sprintf('entry_chooser.php?form_element=%s&rdn=%s&server_id=%s&container=%s',
|
||||
$request['element'],$request['rdn'],$app['server']->getIndex(),rawurlencode($parent_container));
|
||||
}
|
||||
}
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td class="blank"> </td>';
|
||||
printf('<td class="icon"><a href="%s"><img src="%s/up.png" alt="Up" /></a></td>',$href['up'],IMGDIR);
|
||||
printf('<td colspan=2><a href="%s">%s</a></td>',$href['up'],_('Back Up...'));
|
||||
printf('<td colspan=2><a href="%s">%s...</a></td>',$href['up'],_('Back Up'));
|
||||
echo '</tr>';
|
||||
|
||||
if (! count($entry['children']))
|
||||
if (! count($request['children']))
|
||||
printf('<td class="blank" colspan=2> </td><td colspan=2">(%s)</td>',_('no entries'));
|
||||
|
||||
else
|
||||
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)));
|
||||
foreach ($request['children'] as $dn) {
|
||||
$href['return'] = sprintf("javascript:returnDN('%s%s')",($request['rdn'] ? sprintf('%s,',$request['rdn']) : ''),rawurlencode($dn));
|
||||
$href['expand'] = sprintf('entry_chooser.php?server_id=%s&form_element=%s&rdn=%s&container=%s',
|
||||
$app['server']->getIndex(),$request['element'],$request['rdn'],rawurlencode($dn));
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td class="blank"> </td>';
|
||||
printf('<td class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>',$href['expand'],IMGDIR);
|
||||
|
||||
printf('<td colspan=2><a href="%s">%s</a></td>',$href['return'],htmlspecialchars($dn));
|
||||
printf('<td colspan=2><a href="%s">%s</a></td>',$href['return'],$dn);
|
||||
echo '</tr>';
|
||||
echo "\n\n";
|
||||
}
|
||||
|
||||
/* draw the root of the selection tree (ie, list all the servers) */
|
||||
# Draw the root of the selection tree (ie, list all the servers)
|
||||
} else {
|
||||
foreach ($_SESSION[APPCONFIG]->ldapservers->GetServerList() as $id) {
|
||||
foreach ($_SESSION[APPCONFIG]->getServerList() as $index => $server) {
|
||||
if ($server->isLoggedIn(null)) {
|
||||
printf('<tr><td class="heading" colspan=3>%s:</td><td class="heading">%s</td></tr>',_('Server'),$server->getName());
|
||||
foreach ($server->getBaseDN() as $dn) {
|
||||
if (! $dn) {
|
||||
printf('<tr><td class="blank"> </td><td colspan=3>(%s)</td></tr>',_('Could not determine base DN'));
|
||||
|
||||
$ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance($id);
|
||||
} else {
|
||||
$href['return'] = sprintf("javascript:returnDN('%s%s')",($request['rdn'] ? sprintf('%s,',$request['rdn']) : ''),rawurlencode($dn));
|
||||
$href['expand'] = htmlspecialchars(sprintf('entry_chooser.php?server_id=%s&form_element=%s&rdn=%s&container=%s',
|
||||
$server->getIndex(),$request['element'],$request['rdn'],rawurlencode($dn)));
|
||||
|
||||
if ($ldapserver->isVisible()) {
|
||||
|
||||
if (! $ldapserver->haveAuthInfo())
|
||||
continue;
|
||||
|
||||
else {
|
||||
printf('<tr><td class="heading" colspan=3>%s:</td><td class="heading">%s</td></tr>',_('Server'),htmlspecialchars($ldapserver->name));
|
||||
foreach ($ldapserver->getBaseDN() as $dn) {
|
||||
if (! $dn) {
|
||||
printf('<tr><td class="blank"> </td><td colspan=3>(%s)</td></tr>',_('Could not determine base DN'));
|
||||
|
||||
} else {
|
||||
$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="blank"> </td>';
|
||||
printf('<td colspan=2 class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>',$href['expand'],IMGDIR);
|
||||
printf('<td colspan=2><a href="%s">%s</a></td>',$href['return'],htmlspecialchars($dn));
|
||||
}
|
||||
echo '<tr>';
|
||||
echo '<td class="blank"> </td>';
|
||||
printf('<td colspan=2 class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>',$href['expand'],IMGDIR);
|
||||
printf('<td colspan=2><a href="%s">%s</a></td>',$href['return'],$dn);
|
||||
}
|
||||
|
||||
echo '<tr><td class="blank" colspan=4> </td></tr>';
|
||||
}
|
||||
|
||||
echo '<tr><td class="blank" colspan=4> </td></tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
echo '</div>';
|
||||
echo '</body>';
|
||||
|
||||
# Capture the output and put into the body of the page.
|
||||
$www['body'] = new block();
|
||||
$www['body']->SetBody(ob_get_contents());
|
||||
$www['page']->block_add('body',$www['body']);
|
||||
ob_end_clean();
|
||||
|
||||
# Render the popup.
|
||||
$www['page']->display(array('CONTROL'=>false,'FOOT'=>false,'HEAD'=>false,'TREE'=>false));
|
||||
?>
|
||||
|
Reference in New Issue
Block a user