From 18dc7c783e80ab7ed8dc137a0b36317b49d7c073 Mon Sep 17 00:00:00 2001 From: swiergot Date: Tue, 22 Aug 2006 13:58:36 +0000 Subject: Added dsa's sorting improvement patch (closes #3370, #4091, #4097 and #4098). --- web/lib/pkgfuncs.inc | 120 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 89 insertions(+), 31 deletions(-) (limited to 'web/lib') diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 6fd8ad95..950de71d 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -707,26 +707,60 @@ function pkg_search_page($SID="") { print "\n"; print "\n"; - print " ".__("Search by"); - print "
\n"; + print " ".__("Search by"); + print "
\n"; + + print " \n"; + print "\n"; + + /* Status Safe-Unsafe */ + + # Added the code below to handle the safe package flag. + # So we can search for then for 'all' packages, 'safe' + # packages and 'unsafe' packages. + # Added by: dsa "Happily breaking the lang files ;oD" (Joking) + + print "\n"; + print " ".__("Status"); + print "
\n"; + + print " \n"; + print "\n"; + + /* End of Package Status */ - print " \n"; - print "\n"; + /* Sort by */ -/* print "\n"; + print "\n"; print " ".__("Sort by"); print "
\n"; print " \n"; print "\n"; -*/ + + /* End of Sort by */ + print "\n"; print " ".__("Per page"); print "
\n"; @@ -850,7 +886,7 @@ function pkg_search_page($SID="") { } else { $q.= "AND Username = '".mysql_escape_string($K)."' "; } - } elseif ($_REQUEST["SeB"] == "s") { + } elseif ($_REQUEST["SeB"] == "s") { if (!$has_where) { $q.= "WHERE SubmitterUID = ".uid_from_username($K)." "; $has_where = 1; @@ -869,7 +905,8 @@ function pkg_search_page($SID="") { } } } - if ($_REQUEST["do_MyPackages"] && $SID) { + + if ($_REQUEST["do_MyPackages"] && $SID) { # list packages that the user is a AUR Maintainer of, or if it the # vistior is a registered user, if they are the Maintainer. # @@ -896,8 +933,34 @@ function pkg_search_page($SID="") { $q.= "MaintainerUID = 0) "; } } - $order = $_REQUEST["SO"] == 'd' ? 'DESC' : 'ASC'; - switch ($_REQUEST["SB"]) { + + # Added the code below to handle the safe package flag. + # So we can search for then for 'all' packages, 'safe' + # packages and 'unsafe' packages. + # Added by: dsa + if ($_REQUEST["PaS"] <> "all") { + # Flagged Safe + if ($_REQUEST["PaS"] == "fs") + if (!$has_where) { + $q.= "WHERE Safe = 1 "; + $has_where = 1; + } else { + $q.= "AND Safe = 1 "; + } + + # Unflagged Safe + if ($_REQUEST["PaS"] == "us") + if (!$has_where) { + $q.= "WHERE Safe = 0 "; + $has_where = 1; + } else { + $q.= "AND Safe = 0 "; + } + } + + $order = $_REQUEST["SO"] == 'd' ? 'DESC' : 'ASC'; + + switch ($_REQUEST["SB"]) { case 'c': $q.= "ORDER BY CategoryID ".$order.", Name ASC, LocationID ASC "; break; @@ -920,7 +983,7 @@ function pkg_search_page($SID="") { $qnext = $q."LIMIT ".($O+$PP).", ".$PP; //next page's worth $q.= "LIMIT ".$O.", ".$PP; - print "\n"; + print "\n"; $result = db_query($q, $dbh); if (!$result) { print __("Error retrieving package list."); @@ -1033,13 +1096,7 @@ function pkg_search_page($SID="") { # } print "\n"; - # Solve the sorting problem, so we can force the - # passage of the sorting params to the next pages. - # Added by: dsa - print ""; - print ""; - - for ($i=0; $row = mysql_fetch_assoc($result); $i++) { + for ($i=0; $row = mysql_fetch_assoc($result); $i++) { (($i % 2) == 0) ? $c = "data1" : $c = "data2"; print "\n"; if ($SID) { @@ -1079,6 +1136,7 @@ function pkg_search_page($SID="") { } reset($pkgsearch_vars); $url.= "'>"; + if ($row["Safe"] == 1 || $locs[$row["LocationID"]] == "community") { $url.=""; } -- cgit v1.2.3-24-g4f1b