display abstract DNs

This commit is contained in:
Roland Gruber 2010-05-28 18:49:59 +00:00
parent ce5f6e812f
commit 0c0c9968a3
5 changed files with 37 additions and 12 deletions

View File

@ -673,4 +673,25 @@ function cleanLDAPResult($entries) {
return $entries;
}
/**
* Transforms a DN into a more user friendly format.
* E.g. "dc=company,dc=de" is transformed to "company > de".
*
* @param String $dn DN
* @return String transformed DN
*/
function getAbstractDN($dn) {
if ($dn == '') {
return '';
}
$parts = explode(',', $dn);
for ($i = 0; $i < sizeof($parts); $i++) {
$subparts = explode('=', $parts[$i]);
if (sizeof($subparts) == 2) {
$parts[$i] = $subparts[1];
}
}
return implode(' > ', $parts);
}
?>

View File

@ -635,9 +635,9 @@ class lamList {
echo ("<select class=\"" . $this->type . "\" size=1 name=\"suffix\" onchange=\"listOUchanged('" . $this->type . "', this)\">\n");
for ($i = 0; $i < sizeof($this->possibleSuffixes); $i++) {
if ($this->suffix == $this->possibleSuffixes[$i]) {
echo ("<option selected>" . $this->possibleSuffixes[$i] . "</option>\n");
echo ("<option value=\"" . $this->possibleSuffixes[$i] . "\" selected>" . getAbstractDN($this->possibleSuffixes[$i]) . "</option>\n");
}
else echo("<option>" . $this->possibleSuffixes[$i] . "</option>\n");
else echo("<option value=\"" . $this->possibleSuffixes[$i] . "\">" . getAbstractDN($this->possibleSuffixes[$i]) . "</option>\n");
}
echo ("</select>\n");
}

View File

@ -1542,14 +1542,14 @@ class accountContainer {
// loop through all suffixes
$rootsuffix = $_SESSION['config']->get_Suffix($this->type);
foreach ($_SESSION['ldap']->search_units($rootsuffix) as $suffix) {
echo "<option ";
echo '<option value="' . $suffix . '" ';
if ($this->dn == $suffix) {
echo 'selected';
}
echo ">" . $suffix . "</option>\n";
echo ">" . getAbstractDN($suffix) . "</option>\n";
}
if (!($this->dn == '') && !in_array($this->dn, $_SESSION['ldap']->search_units($rootsuffix))) {
echo "<option selected>" . $this->dn . "</option>\n";;
echo '<option value="' . $this->dn . '" selected>' . getAbstractDN($this->dn) . "</option>\n";;
}
echo "</select>\n";
echo '&nbsp;&nbsp;&nbsp;&nbsp;';

View File

@ -244,12 +244,10 @@ class asteriskExtension extends baseModule {
array('kind' => 'text', 'text' => _("Extension owners") . '*'),
array('kind' => 'input', 'name' => 'form_subpage_' . get_class($this) . '_user_open', 'type' => 'submit', 'value' => _('Change')),
array('kind' => 'help', 'value' => 'member'));
for ($i = 0; $i < sizeof($this->attributes['member']); $i++) {
}
$memberPart = array();
if (isset($this->attributes['member'])) {
for ($i = 0; $i < sizeof($this->attributes['member']); $i++) {
$memberPart[] = array(array('kind' => 'text', 'text' => $this->attributes['member'][$i]));
$memberPart[] = array(array('kind' => 'text', 'text' => getAbstractDN($this->attributes['member'][$i])));
}
}
$return[] = array(
@ -280,10 +278,13 @@ class asteriskExtension extends baseModule {
for ($i = 0; $i < sizeof($entries); $i++) {
$dn = $entries[$i]['dn'];
if (isset($dn) && (!isset($this->attributes['member']) || !in_array($dn, $this->attributes['member']))) {
$users_dn[] = $dn;
$users_dn[] = array($dn, getAbstractDN($dn));
}
}
$members = $this->attributes['member'];
for ($i = 0; $i < sizeof($members); $i++) {
$members[$i] = array($members[$i], getAbstractDN($members[$i]));
}
$return[] = array(array('kind' => 'table', 'value' => array(
array(
array('kind' => 'table', 'value' => array(
@ -306,7 +307,7 @@ class asteriskExtension extends baseModule {
array('kind' => 'fieldset', 'legend' => _("Extension owners"), 'value' => array(
array(
array('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Selected users"), 'value' => array (
array(array('kind' => 'select', 'name' => 'removeusers', 'size' => '15', 'multiple' => true, 'options' => $members)))
array(array('kind' => 'select', 'name' => 'removeusers', 'size' => '15', 'multiple' => true, 'options' => $members, 'descriptiveOptions' => true)))
),
array('kind' => 'table', 'value' => array(
array(array('kind' => 'input', 'type' => 'submit', 'name' => 'addusers_button', 'value' => '<=', 'td' => array('align' => 'center'))),
@ -314,7 +315,7 @@ class asteriskExtension extends baseModule {
array(array('kind' => 'help', 'value' => 'member', 'td' => array('align' => 'center')))
)),
array('kind' => 'fieldset', 'td' => array('valign' => 'top'), 'legend' => _("Available users"), 'value' => array(
array(array('kind' => 'select', 'name' => 'addusers', 'size' => '15', 'multiple' => true, 'options' => $users_dn)))
array(array('kind' => 'select', 'name' => 'addusers', 'size' => '15', 'multiple' => true, 'options' => $users_dn, 'descriptiveOptions' => true)))
)
)
))

View File

@ -1061,6 +1061,9 @@ class inetOrgPerson extends baseModule implements passwordService {
$dnUsers = array_keys($dnUsers);
usort($dnUsers, array($_SESSION['ldap'], 'cmp_array'));
array_unshift($dnUsers, '-');
for ($i = 0; $i < sizeof($dnUsers); $i++) {
$dnUsers[$i] = array($dnUsers[$i], getAbstractDN($dnUsers[$i]));
}
$optionsSelected = array();
if (isset($this->attributes['manager'][0])) {
$optionsSelected[] = $this->attributes['manager'][0];
@ -1070,7 +1073,7 @@ class inetOrgPerson extends baseModule implements passwordService {
}
$return[] = array(
array('kind' => 'text', 'text' => _('Manager')),
array('kind' => 'select', 'name' => 'manager', 'size' => '1',
array('kind' => 'select', 'name' => 'manager', 'size' => '1', 'descriptiveOptions' => true,
'options' => $dnUsers, 'options_selected' => $optionsSelected),
array('kind' => 'help', 'value' => 'manager'));
}