summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreric <eric>2004-06-26 15:21:04 +0200
committereric <eric>2004-06-26 15:21:04 +0200
commitdc3b13064cdb59dd12b200e7f8c73fd63126dea6 (patch)
treef203062484b4f1b78d76ffef607526ad22399f13
parent5cbbf11c8bf72a1b80dc72e27d5737c7d79a5903 (diff)
downloadaur-dc3b13064cdb59dd12b200e7f8c73fd63126dea6.tar.gz
aur-dc3b13064cdb59dd12b200e7f8c73fd63126dea6.tar.xz
mypkgs works, but need an 'action' table
-rw-r--r--web/html/pkgsearch.php10
-rw-r--r--web/lang/pkgs_po.inc15
-rw-r--r--web/lib/aur.inc20
-rw-r--r--web/lib/pkgs.inc60
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 "<center>\n";
print "<table cellspacing='3' class='boxSoft'>\n";
print "<tr>\n";
print " <td class='boxSoftTitle' align='right'>\n";
- print " <span class='boxSoftTitle'>".__("Search Criteria")."</span>\n";
+ print " <span class='f3'>".__("Search Criteria")."</span>\n";
print " </td>\n";
print "</tr>\n";
print "<tr>\n";
@@ -143,9 +154,16 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
print "</td>\n";
print "<td align='right' valign='bottom'>&nbsp;\n";
- print " <input type='submit' class='button' value='Go'>\n";
+ print " <input type='submit' class='button' value='".__("Go")."'>\n";
print "</td>\n";
+ if ($SID) {
+ print "<td align='right' valign='bottom'>&nbsp;\n";
+ print " <input type='submit' class='button' name='M'";
+ print " value='".__("My Packages")."'>\n";
+ print "</td>\n";
+ }
+
print "</tr>\n";
print "</table>\n";
@@ -156,6 +174,14 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
print "</center>\n";
print "<br />\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 " <td class='boxSoft'>\n";
print "<table width='100%' cellspacing='0' cellpadding='2'>\n";
print "<tr>\n";
+ if ($SID) {
+ print " <th style='border-bottom: #666 1px solid; vertical-align:";
+ print " bottom'>&nbsp;</th>\n";
+ }
print " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'><span class='f2'>".__("Location")."</span></th>\n";
print " <th style='border-bottom: #666 1px solid; vertical-align:";
@@ -239,6 +280,17 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
for ($i=0; $row = mysql_fetch_assoc($result); $i++) {
(($i % 2) == 0) ? $c = "data1" : $c = "data2";
print "<tr>\n";
+ if ($SID) {
+ print " <td class='".$c."'>";
+ if ($row["OutOfDate"]) {
+ print "<span style='background-color: red'>";
+ }
+ print "<input type='checkbox' name='PIDs[]' value='".$row["ID"]."'>";
+ if ($row["OutOfDate"]) {
+ print "</span>";
+ }
+ print "</td>\n";
+ }
print " <td class='".$c."'><span class='f5'><span class='blue'>";
print $locs[$row["LocationID"]]."</span></span></td>\n";
print " <td class='".$c."'><span class='f5'><span class='blue'>";
@@ -278,6 +330,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
print " <input type='hidden' name='Action' value='SearchPkgs'>\n";
print " <input type='hidden' name='O' value='".($OFFSET-intval($PP))."'>\n";
print " <input type='hidden' name='L' value='".$L."'>\n";
+ print " <input type='hidden' name='M' value='".$M."'>\n";
print " <input type='hidden' name='C' value='".$C."'>\n";
print " <input type='hidden' name='K' value='".$K."'>\n";
print " <input type='hidden' name='SB' value='".$SB."'>\n";
@@ -291,6 +344,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
print " <input type='hidden' name='Action' value='SearchPkgs'>\n";
print " <input type='hidden' name='O' value='".($OFFSET+intval($PP))."'>\n";
print " <input type='hidden' name='L' value='".$L."'>\n";
+ print " <input type='hidden' name='M' value='".$M."'>\n";
print " <input type='hidden' name='C' value='".$C."'>\n";
print " <input type='hidden' name='K' value='".$K."'>\n";
print " <input type='hidden' name='SB' value='".$SB."'>\n";