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/html/pkgsearch.php | 10 +++++---- web/lang/pkgs_po.inc | 15 +++++++++++++ web/lib/aur.inc | 20 +++++++++++++++++ web/lib/pkgs.inc | 60 +++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 98 insertions(+), 7 deletions(-) diff --git a/web/html/pkgsearch.php b/web/html/pkgsearch.php index 91a2d58e..9d4521ce 100644 --- a/web/html/pkgsearch.php +++ b/web/html/pkgsearch.php @@ -35,16 +35,18 @@ if ($atype && $_REQUEST["Action"] == "Something") { # } elseif ($_REQUEST["Action"] == "SearchPkgs") { - # do something else based on what the user specifies + # the visitor has requested search options and/or hit the less/more button # - pkg_search_page($_REQUEST["L"], $_REQUEST["C"], $_REQUEST["K"], - $_REQUEST["SB"], $_REQUEST["O"], $_REQUEST["PP"]); + pkg_search_page($_COOKIE["AURSID"], $_REQUEST["L"], $_REQUEST["C"], + $_REQUEST["K"], $_REQUEST["SB"], $_REQUEST["M"], $_REQUEST["O"], + $_REQUEST["PP"]); } else { # do the default thing - give the user a search form that they # can specify: location, category, maintainer, name, 'my pkgs' + # and display a list of packages based on no search options. # - pkg_search_page(); + pkg_search_page($_COOKIE["AURSID"]); } diff --git a/web/lang/pkgs_po.inc b/web/lang/pkgs_po.inc index 94294c74..20acf855 100644 --- a/web/lang/pkgs_po.inc +++ b/web/lang/pkgs_po.inc @@ -76,4 +76,19 @@ $_t["en"]["No packages matched your search criteria."] = "No packages matched yo # $_t["fr"]["No packages matched your search criteria."] = "--> Traduction française ici. <--"; # $_t["de"]["No packages matched your search criteria."] = "--> Deutsche Übersetzung hier. <--"; +$_t["en"]["My Packages"] = "My Packages"; +# $_t["es"]["My Packages"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["My Packages"] = "--> Traduction française ici. <--"; +# $_t["de"]["My Packages"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Go"] = "Go"; +# $_t["es"]["Go"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Go"] = "--> Traduction française ici. <--"; +# $_t["de"]["Go"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Out-of-date"] = "Out-of-date"; +# $_t["es"]["Out-of-date"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Out-of-date"] = "--> Traduction française ici. <--"; +# $_t["de"]["Out-of-date"] = "--> Deutsche Übersetzung hier. <--"; + ?> \ No newline at end of file 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