From dc3b13064cdb59dd12b200e7f8c73fd63126dea6 Mon Sep 17 00:00:00 2001 From: eric Date: Sat, 26 Jun 2004 13:21:04 +0000 Subject: mypkgs works, but need an 'action' table --- web/lib/aur.inc | 20 +++++++++++++++++++ web/lib/pkgs.inc | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 77 insertions(+), 3 deletions(-) (limited to 'web/lib') diff --git a/web/lib/aur.inc b/web/lib/aur.inc index f59e63a6..9407a401 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -202,6 +202,26 @@ function account_from_sid($sid="") { return $row[0]; } +# obtain the Users.ID if given their current SID +# +function uid_from_sid($sid="") { + if (!$sid) { + return ""; + } + $dbh = db_connect(); + $q = "SELECT Users.ID "; + $q.= "FROM Users, Sessions "; + $q.= "WHERE Users.ID = Sessions.UsersID "; + $q.= "AND Sessions.SessionID = '" . mysql_escape_string($sid) . "'"; + $result = db_query($q, $dbh); + if (!$result) { + return 0; + } + $row = mysql_fetch_row($result); + + return $row[0]; +} + # connect to the database # function db_connect() { diff --git a/web/lib/pkgs.inc b/web/lib/pkgs.inc index c11143e5..dfcebb93 100644 --- a/web/lib/pkgs.inc +++ b/web/lib/pkgs.inc @@ -35,11 +35,13 @@ function pkgLocations() { # display the search form in a boxSoft style # -function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) { +function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { + # SID: session id cookie # L: PackageLocations.ID # C: PackageCategories.ID # K: Keywords # SB: Sort by + # M: search "my packages" # O: Row offset # PP: Per page $locs = pkgLocations(); @@ -57,11 +59,20 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) { $OFFSET = 0; } + # grab info for user if they're logged in + # + if ($SID) { + $myuid = uid_from_sid($SID); + $acct = account_from_sid($SID); + } + + # The search form + # print "
\n"; print "\n"; print "\n"; print " \n"; print "\n"; print "\n"; @@ -143,9 +154,16 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) { print "\n"; print "\n"; + if ($SID) { + print "\n"; + } + print "\n"; print "
\n"; - print " ".__("Search Criteria")."\n"; + print " ".__("Search Criteria")."\n"; print "
 \n"; - print " \n"; + print " \n"; print " \n"; + print " \n"; + print "
\n"; @@ -156,6 +174,14 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) { print "
\n"; print "
\n"; + + # TODO need an "action" table in here like on /devel? It would + # allow the visitor to flag packages out-of-date, vote, adopt/disown? + # Probably need to think about the overall UI of this - the package + # name will be a link that goes to 'details'. There should also be + # a column for 'manage/edit' + + # query to pull out package info # $q = "SELECT Packages.*, IF(ISNULL(PackageID), 0, COUNT(*)) AS Votes "; @@ -184,6 +210,16 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) { $q.= "Description LIKE '%".mysql_escape_string($K)."%') "; } } + if ($M && $SID) { + if ($myuid) { + if (!$has_where) { + $q.= "WHERE MaintainerUID = ".$myuid." "; + $has_where = 1; + } else { + $q.= "AND MaintainerUID = ".$myuid." "; + } + } + } $q.= "GROUP BY PackageID "; switch ($SB) { @@ -201,6 +237,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) { break; } $q.= "LIMIT ".$OFFSET.", ".intval($PP); + $result = db_query($q, $dbh); if (!$result) { print __("No packages matched your search criteria."); @@ -222,6 +259,10 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) { print " \n"; print "\n"; print "\n"; + if ($SID) { + print " \n"; + } print " \n"; print " \n"; print "
 ".__("Location").""; + if ($row["OutOfDate"]) { + print ""; + } + print ""; + if ($row["OutOfDate"]) { + print ""; + } + print "\n"; + } print " "; print $locs[$row["LocationID"]].""; @@ -278,6 +330,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) { print " \n"; print " \n"; print " \n"; + print " \n"; print " \n"; print " \n"; print " \n"; @@ -291,6 +344,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) { print " \n"; print " \n"; print " \n"; + print " \n"; print " \n"; print " \n"; print " \n"; -- cgit v1.2.3-24-g4f1b