From d17e406ac61094a0ad6d433c8e24be9b8b140959 Mon Sep 17 00:00:00 2001 From: eric Date: Sat, 10 Jul 2004 20:51:56 +0000 Subject: pkgsearch is done (except for some serious debugging) --- web/lib/aur.inc | 1 + web/lib/pkgfuncs.inc | 86 ++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 71 insertions(+), 16 deletions(-) (limited to 'web/lib') diff --git a/web/lib/aur.inc b/web/lib/aur.inc index 26e538ad..005c5642 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -423,6 +423,7 @@ function html_header() { # function html_footer($ver="") { print "\n\n\n"; + print "
\n"; print " \n"; print " \n"; print "\n"; diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index ae306577..0b7a0003 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -1,14 +1,20 @@ "; print __("Go back to %hsearch results%h.", array($url_data, "")); + print "\n
\n"; return; } @@ -113,9 +120,32 @@ function package_sources($pkgid=0) { return $sources; } + +# grab array of Package.IDs that I've voted for: $pkgs[1234] = 1, ... +# +function pkgvotes_from_sid($sid="") { + $pkgs = array(); + if (!$sid) {return $pkgs;} + $dbh = db_connect(); + $q = "SELECT PackageID "; + $q.= "FROM PackageVotes, Users, Sessions "; + $q.= "WHERE Users.ID = Sessions.UsersID "; + $q.= "AND Users.ID = PackageVotes.UsersID "; + $q.= "AND Sessions.SessionID = '".mysql_escape_string($sid)."'"; + $result = db_query($q, $dbh); + if ($result) { + while ($row = mysql_fetch_row($result)) { + $pkgs[$row[0]] = 1; + } + } + return $pkgs; +} + + # display package details # function package_details($id=0) { + global $_REQUEST; global $pkgsearch_vars; $q = "SELECT *,Location,Category "; $q.= "FROM Packages,PackageLocations,PackageCategories "; @@ -190,7 +220,11 @@ function package_details($id=0) { while (list($k, $darr) = each($deps)) { $url = "".$darr[1]."
\n"; @@ -252,12 +286,13 @@ function pkg_search_page($SID="") { if ($O < 0) { $O = 0; } - if ($_REQUEST["do_Search"]) { - # reset the offset to zero if they hit Go/My Packages + if ($_REQUEST["do_Search"] && $_REQUEST["do_Search"] != 1) { + # reset the offset to zero if they hit Go # $_REQUEST["do_MyPackages"] = 0; $O = 0; } + $_REQUEST["O"] = $O; # so that pkg_search_results() works # grab info for user if they're logged in @@ -265,6 +300,7 @@ function pkg_search_page($SID="") { if ($SID) { $myuid = uid_from_sid($SID); $acct = account_from_sid($SID); + $my_votes = pkgvotes_from_sid($SID); } # The search form @@ -438,10 +474,6 @@ function pkg_search_page($SID="") { break; } $q.= "LIMIT ".$O.", ".$PP; - print $q."
\n"; - print "
\n";
-	print_r($_REQUEST);
-	print "
\n"; $result = db_query($q, $dbh); if (!$result) { @@ -470,6 +502,9 @@ function pkg_search_page($SID="") { print "\n"; print " "; + print "\n"; + print " "; print "\n"; print " "; @@ -478,6 +513,9 @@ function pkg_search_page($SID="") { print " "; print "\n"; + print " "; + print "\n"; print "\n"; print "\n"; print " \n"; @@ -512,6 +550,10 @@ function pkg_search_page($SID="") { print " bottom'>".__("Name")."\n"; print " ".__("Votes")."\n"; + if ($SID) { + print " ".__("Vote")."\n"; + } print " ".__("Description")."\n"; print " "; } - print ""; - if ($i == 0) { - $all_ids = $row["ID"]; - } else { - $all_ids .= ":".$row["ID"]; - } + print ""; +# if ($i == 0) { +# $all_ids = $row["ID"]; +# } else { +# $all_ids .= ":".$row["ID"]; +# } if ($row["OutOfDate"]) { print ""; } @@ -554,7 +596,11 @@ function pkg_search_page($SID="") { # php.net recommends htmlentities(urlencode(data)), but that # doesn't work! # - $url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var])); + if ($var == "do_MyPackages" && $_REQUEST[$var]) { + $url .= "&".$var."=1"; + } else { + $url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var])); + } } reset($pkgsearch_vars); $url.= "'>".$row["Name"]; @@ -562,6 +608,14 @@ function pkg_search_page($SID="") { print $url."\n"; print " "; print "   ".$row["NumVotes"]."\n"; + if ($SID) { + print " "; + if (isset($my_votes[$row["ID"]])) { + print "  ".__("Yes")."\n"; + } else { + print " \n"; + } + } print " "; print $row["Description"]."\n"; print " "; @@ -598,7 +652,7 @@ function pkg_search_page($SID="") { print " \n"; print "\n"; print "\n"; - print "\n"; +# print "\n"; if ($_REQUEST["do_MyPackages"]) { print "\n"; } -- cgit v1.2.3-24-g4f1b