[Da-tools-commits] ./debian/userdir-ldap-cgi r91: make summaryattrs sortable [zobel]
Peter Palfrader
peter at palfrader.org
Sun May 25 16:05:17 UTC 2008
------------------------------------------------------------
revno: 91
committer: Peter Palfrader <peter at palfrader.org>
branch nick: userdir-ldap-cgi
timestamp: Sun 2008-05-25 18:05:17 +0200
message:
make summaryattrs sortable [zobel]
modified:
debian/changelog
machines.cgi
------------------------------------------------------------
revno: 87.1.3
committer: Martin Zobel-Helas <zobel at debian.org>
branch nick: userdir-ldap-cgi-common
timestamp: Sun 2008-05-18 17:35:27 +0200
message:
make summaryattrs sortable
modified:
machines.cgi
------------------------------------------------------------
revno: 87.1.4
committer: Martin Zobel-Helas <zobel at debian.org>
branch nick: userdir-ldap-cgi-common
timestamp: Sun 2008-05-18 18:37:17 +0200
message:
sort additionaly by host if $sortby != host
modified:
machines.cgi
-------------- next part --------------
=== modified file 'debian/changelog'
--- a/debian/changelog 2008-05-25 16:04:55 +0000
+++ b/debian/changelog 2008-05-25 16:05:17 +0000
@@ -2,8 +2,9 @@
* Make machines.cgi display the purpose attribute from LDAP [HE].
* Add VoIP field to CGI [zobel].
+ * make summaryattrs sortable [zobel].
- -- Peter Palfrader <weasel at debian.org> Sun, 25 May 2008 18:04:35 +0200
+ -- Peter Palfrader <weasel at debian.org> Sun, 25 May 2008 18:05:06 +0200
userdir-ldap-cgi (0.3.9) unstable; urgency=low
=== modified file 'machines.cgi'
--- a/machines.cgi 2008-03-14 20:17:51 +0000
+++ b/machines.cgi 2008-05-18 16:37:17 +0000
@@ -4,6 +4,7 @@
# (c) 1999 Randolph Chung. Licensed under the GPL. <tausq at debian.org>
# (c) 2004 Martin Schulze. Licensed under the GPL. <joey at debian.org>
# (c) 2006 Ryan Murray. Licensed under the GPL. <rmurray at debian.org>
+# (c) 2008 Martin Zobel-Helas. Licensed under the GPL. <zobel at debian.org>
use lib '.';
use strict vars;
@@ -86,6 +87,8 @@
my $query = new CGI;
my $host = lc($query->param('host'));
+my $sortby = lc($query->param('sortby')) || "host";
+my $sortorder = lc($query->param('sortorder')) || "asc";
&Util::HTMLSendHeader;
$ldap = Net::LDAP->new($config{ldaphost}) || &Util::HTMLError($!);
@@ -180,11 +183,25 @@
$hostdetails = "<h1>Summary</h1>\n";
$hostdetails .= "<table border=\"1\" width=\"90%\">\n<tr>";
foreach $key (@summaryorder) {
- $hostdetails .= "<th>$summaryattrs{$key}</th>";
+ if ($sortby ne $key) {
+ $hostdetails .= "<th><a href=\"machines.cgi?sortby=$key&sortorder=asc\">$summaryattrs{$key}</a></th>";
+ } else {
+ if ($sortorder ne "dsc") {
+ $hostdetails .= "<th><a href=\"machines.cgi?sortby=$key&sortorder=dsc\">$summaryattrs{$key}</a></th>";
+ } else {
+ $hostdetails .= "<th><a href=\"machines.cgi?sortby=$key&sortorder=asc\">$summaryattrs{$key}</a></th>";
+ }
+ }
}
$hostdetails .= "</tr>\n";
- foreach $host (sort(keys(%summary))) {
+ my @sorted;
+ if ($sortorder eq "asc") {
+ @sorted = sort {($summary{$a}->{$sortby} cmp $summary{$b}->{$sortby}) || ($summary{$a}->{'host'} cmp $summary{$b}->{'host'})} keys(%summary)
+ } else {
+ @sorted = sort {($summary{$b}->{$sortby} cmp $summary{$a}->{$sortby}) || ($summary{$a}->{'host'} cmp $summary{$b}->{'host'})} keys(%summary)
+ }
+ foreach $host (@sorted) {
$hostdetails .= "<tr>";
foreach $key (@summaryorder) {
$hostdetails .= "<td>$summary{$host}{$key} </td>";
More information about the Da-tools-commits
mailing list