diff --git a/lam/lib/listgroups.php b/lam/lib/listgroups.php index 11727e1f..715dd2ba 100644 --- a/lam/lib/listgroups.php +++ b/lam/lib/listgroups.php @@ -19,7 +19,7 @@ $Id$ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - This code displays a list of all Samba hosts. + This code displays a list of all groups. */ include_once ('../config/config.php'); @@ -57,7 +57,7 @@ else { // Groups have the attribute "posixGroup" $filter = "(objectClass=posixGroup)"; -$attrs = array("cn", "gidNumber", "memberUID", "description"); +$attrs = $attr_array; $sr = @ldap_search($_SESSION["ldap"]->server(), $_SESSION["config"]->get_GroupSuffix(), $filter, $attrs); @@ -70,17 +70,22 @@ 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 group table header echo "\n"; echo ""; // table header for ($k = 0; $k < sizeof($desc_array); $k++) { - echo ""; + echo ""; } echo "\n"; // print group list -for ($i = 0; $i < sizeof($info)-1; $i++) { // ignore last entry in array which is "count" +for ($i = 0; $i < sizeof($info); $i++) { // ignore last entry in array which is "count" 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])]); // generate links for group members if (strtolower($attr_array[$k]) == "memberuid") { @@ -119,9 +125,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 Group") . ""); +echo ("   " . _("Delete Group(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; +} + ?> diff --git a/lam/lib/listhosts.php b/lam/lib/listhosts.php index 448574c9..f8c5d32b 100644 --- a/lam/lib/listhosts.php +++ b/lam/lib/listhosts.php @@ -80,12 +80,11 @@ 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); $i++) { echo("
" . $desc_array[$k] . "" . $desc_array[$k] . "