diff --git a/lam/lib/listhosts.php b/lam/lib/listhosts.php index 048a5c3f..448574c9 100644 --- a/lam/lib/listhosts.php +++ b/lam/lib/listhosts.php @@ -70,17 +70,23 @@ else echo ("

" . _("LDAP Search failed! Please che echo ("
\n"); +// delete first array entry which is "count" +array_shift($info); +// sort rows by sort column ($list) +usort($info, "cmp_array"); + // print host table header echo "\n"; echo ""; // table header for ($k = 0; $k < sizeof($desc_array); $k++) { - echo ""; + echo ""; } echo "\n"; // print host list -for ($i = 0; $i < sizeof($info)-1; $i++) { // ignore last entry in array which is "count" + +for ($i = 0; $i < sizeof($info); $i++) { echo(""); // print all attribute entries seperated by "; " if (sizeof($info[$i][strtolower($attr_array[$k])]) > 0) { + // delete first array entry which is "count" array_shift($info[$i][strtolower($attr_array[$k])]); echo implode("; ", $info[$i][strtolower($attr_array[$k])]); } @@ -101,9 +108,23 @@ for ($i = 0; $i < sizeof($info)-1; $i++) { // ignore last entry in array which i echo ("
" . $desc_array[$k] . "" . $desc_array[$k] . "
"); echo ("

 

\n"); echo (""); -echo ("\n"); +echo ("\n"); echo ("
"); -echo (" 
" . _("New Host") . ""); +echo ("   " . _("Delete Host(s)") . "
\n"); echo ("
\n"); echo "\n"; + +// compare function used for usort-method +// rows are sorted with the first attribute entry of the sort column +// if objects have attributes with multiple values the others are ignored +function cmp_array($a, $b) { + // list specifies the sort column + global $list; + // sort by first attribute with name $list + if (!$list) $list = 0; + if ($a[$list][0] == $b[$list][0]) return 0; + else if ($a[$list][0] == max($a[$list][0], $b[$list][0])) return 1; + else return -1; +} + ?>