Sort list of attributes available to add

This commit is contained in:
Timothy Warren 2019-02-12 15:56:13 -05:00
parent 78813e18f9
commit 23dc06e79c
2 changed files with 19 additions and 3 deletions

View File

@ -73,6 +73,7 @@ if (get_request('meth','REQUEST') != 'ajax') {
echo '<select name="single_item_attr">'; echo '<select name="single_item_attr">';
$attr_list = [];
foreach ($attr['avail'] as $attribute) { foreach ($attr['avail'] as $attribute) {
# Is there a user-friendly translation available for this attribute? # Is there a user-friendly translation available for this attribute?
if ($attribute->haveFriendlyName()) if ($attribute->haveFriendlyName())
@ -84,7 +85,14 @@ if (get_request('meth','REQUEST') != 'ajax') {
$attr_display = $attribute->getName(FALSE); $attr_display = $attribute->getName(FALSE);
} }
printf('<option value="%s">%s</option>',htmlspecialchars($attribute->getName()),$attr_display); $attr_list[htmlspecialchars($attribute->getName())] = $attr_display;
}
ksort($attr_list);
foreach($attr_list as $name => $value)
{
printf('<option value="%s">%s</option>', $name, $value);
} }
echo '</select>'; echo '</select>';
@ -201,9 +209,17 @@ if (get_request('meth','REQUEST') != 'ajax') {
'ADDATTR',$app['server']->getIndex(),$request['template']->getDNEncode(),_('Please Wait')); 'ADDATTR',$app['server']->getIndex(),$request['template']->getDNEncode(),_('Please Wait'));
printf('<option value="%s">%s</option>','',''); printf('<option value="%s">%s</option>','','');
$attr_list = [];
foreach ($request['template']->getAvailAttrs() as $attribute) foreach ($request['template']->getAvailAttrs() as $attribute)
{ {
printf('<option value="%s">%s</option>', htmlspecialchars($attribute->getName()), $attribute->getFriendlyName()); $attr_list[htmlspecialchars($attribute->getName())] = $attribute->getFriendlyName();
}
asort($attr_list);
foreach($attr_list as $name => $label)
{
printf('<option value="%s">%s</option>', $name, $label);
} }
echo '</select>'; echo '</select>';

View File

@ -72,7 +72,7 @@ if (count($request['template']->getLDAPmodify(true))) {
if (! $attribute->getOldValues()) if (! $attribute->getOldValues())
{ {
printf('<span style='color: green'>[%s]</span>',_('attribute doesnt exist')); } printf('<span style="color: green">[%s]</span>',_('attribute doesnt exist')); }
$dv = $attribute->getRemovedValues(); $dv = $attribute->getRemovedValues();
foreach ($attribute->getOldValues() as $key => $value) { foreach ($attribute->getOldValues() as $key => $value) {