From 35bf6395b8d83a023a24353fdf4b0e21ca68d309 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 28 Oct 2003 19:32:10 +0000 Subject: [PATCH] fixed sorting of DNs --- lam/templates/lists/listdomains.php | 16 ++++++++++++---- lam/templates/lists/listgroups.php | 16 ++++++++++++---- lam/templates/lists/listhosts.php | 16 ++++++++++++---- lam/templates/lists/listusers.php | 22 +++++++++++++++------- 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/lam/templates/lists/listdomains.php b/lam/templates/lists/listdomains.php index f5a25f66..af456f69 100644 --- a/lam/templates/lists/listdomains.php +++ b/lam/templates/lists/listdomains.php @@ -251,11 +251,19 @@ function cmp_array($a, $b) { // sort specifies the sort column global $sort; global $attr_array; - // sort by first attribute with name $sort + // sort by first column if no attribute is given if (!$sort) $sort = strtolower($attr_array[0]); - if ($a[$sort][0] == $b[$sort][0]) return 0; - else if ($a[$sort][0] == max($a[$sort][0], $b[$sort][0])) return 1; - else return -1; + if ($sort != "dn") { + // sort by first attribute with name $sort + if ($a[$sort][0] == $b[$sort][0]) return 0; + else if ($a[$sort][0] == max($a[$sort][0], $b[$sort][0])) return 1; + else return -1; + } + else { + if ($a[$sort] == $b[$sort]) return 0; + else if ($a[$sort] == max($a[$sort], $b[$sort])) return 1; + else return -1; + } } diff --git a/lam/templates/lists/listgroups.php b/lam/templates/lists/listgroups.php index 9416301f..47f6a399 100644 --- a/lam/templates/lists/listgroups.php +++ b/lam/templates/lists/listgroups.php @@ -364,11 +364,19 @@ function cmp_array($a, $b) { // sort specifies the sort column global $sort; global $attr_array; - // sort by first attribute with name $sort + // sort by first column if no attribute is given if (!$sort) $sort = strtolower($attr_array[0]); - if ($a[$sort][0] == $b[$sort][0]) return 0; - else if ($a[$sort][0] == max($a[$sort][0], $b[$sort][0])) return 1; - else return -1; + if ($sort != "dn") { + // sort by first attribute with name $sort + if ($a[$sort][0] == $b[$sort][0]) return 0; + else if ($a[$sort][0] == max($a[$sort][0], $b[$sort][0])) return 1; + else return -1; + } + else { + if ($a[$sort] == $b[$sort]) return 0; + else if ($a[$sort] == max($a[$sort], $b[$sort])) return 1; + else return -1; + } } // save variables to session diff --git a/lam/templates/lists/listhosts.php b/lam/templates/lists/listhosts.php index fc3df04b..a5b13572 100644 --- a/lam/templates/lists/listhosts.php +++ b/lam/templates/lists/listhosts.php @@ -355,11 +355,19 @@ function cmp_array($a, $b) { // sort specifies the sort column global $sort; global $attr_array; - // sort by first attribute with name $sort + // sort by first column if no attribute is given if (!$sort) $sort = strtolower($attr_array[0]); - if ($a[$sort][0] == $b[$sort][0]) return 0; - else if ($a[$sort][0] == max($a[$sort][0], $b[$sort][0])) return 1; - else return -1; + if ($sort != "dn") { + // sort by first attribute with name $sort + if ($a[$sort][0] == $b[$sort][0]) return 0; + else if ($a[$sort][0] == max($a[$sort][0], $b[$sort][0])) return 1; + else return -1; + } + else { + if ($a[$sort] == $b[$sort]) return 0; + else if ($a[$sort] == max($a[$sort], $b[$sort])) return 1; + else return -1; + } } // save variables to session diff --git a/lam/templates/lists/listusers.php b/lam/templates/lists/listusers.php index 9a74d4d2..425e933b 100644 --- a/lam/templates/lists/listusers.php +++ b/lam/templates/lists/listusers.php @@ -415,14 +415,22 @@ function draw_navigation_bar ($user_count) { // 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) { - // sortattrib specifies the sort column - global $sortattrib; - global $attr_array; - // sort by first attribute with name $sortattrib + // sortattrib specifies the sort column + global $sortattrib; + global $attr_array; + // sort by first attribute with name $sortattrib if (!$sortattrib) $sortattrib = strtolower($attr_array[0]); - if ($a[$sortattrib][0] == $b[$sortattrib][0]) return 0; - else if ($a[$sortattrib][0] == max($a[$sortattrib][0], $b[$sortattrib][0])) return 1; - else return -1; + if ($sortattrib != "dn") { + // sort by first column if no attribute is given + if ($a[$sortattrib][0] == $b[$sortattrib][0]) return 0; + else if ($a[$sortattrib][0] == max($a[$sortattrib][0], $b[$sortattrib][0])) return 1; + else return -1; + } + else { + if ($a[$sortattrib] == $b[$sortattrib]) return 0; + else if ($a[$sortattrib] == max($a[$sortattrib], $b[$sortattrib])) return 1; + else return -1; + } } // save variables to session