mypkgs works, but need an 'action' table

This commit is contained in:
eric 2004-06-26 13:21:04 +00:00
parent 5cbbf11c8b
commit dc3b13064c
4 changed files with 98 additions and 7 deletions

View file

@ -35,16 +35,18 @@ if ($atype && $_REQUEST["Action"] == "Something") {
# #
} elseif ($_REQUEST["Action"] == "SearchPkgs") { } 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"], pkg_search_page($_COOKIE["AURSID"], $_REQUEST["L"], $_REQUEST["C"],
$_REQUEST["SB"], $_REQUEST["O"], $_REQUEST["PP"]); $_REQUEST["K"], $_REQUEST["SB"], $_REQUEST["M"], $_REQUEST["O"],
$_REQUEST["PP"]);
} else { } else {
# do the default thing - give the user a search form that they # do the default thing - give the user a search form that they
# can specify: location, category, maintainer, name, 'my pkgs' # 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"]);
} }

View file

@ -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["fr"]["No packages matched your search criteria."] = "--> Traduction française ici. <--";
# $_t["de"]["No packages matched your search criteria."] = "--> Deutsche Übersetzung hier. <--"; # $_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. <--";
?> ?>

View file

@ -202,6 +202,26 @@ function account_from_sid($sid="") {
return $row[0]; 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 # connect to the database
# #
function db_connect() { function db_connect() {

View file

@ -35,11 +35,13 @@ function pkgLocations() {
# display the search form in a boxSoft style # 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 # L: PackageLocations.ID
# C: PackageCategories.ID # C: PackageCategories.ID
# K: Keywords # K: Keywords
# SB: Sort by # SB: Sort by
# M: search "my packages"
# O: Row offset # O: Row offset
# PP: Per page # PP: Per page
$locs = pkgLocations(); $locs = pkgLocations();
@ -57,11 +59,20 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
$OFFSET = 0; $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 "<center>\n";
print "<table cellspacing='3' class='boxSoft'>\n"; print "<table cellspacing='3' class='boxSoft'>\n";
print "<tr>\n"; print "<tr>\n";
print " <td class='boxSoftTitle' align='right'>\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 " </td>\n";
print "</tr>\n"; print "</tr>\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>\n";
print "<td align='right' valign='bottom'>&nbsp;\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"; 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 "</tr>\n";
print "</table>\n"; print "</table>\n";
@ -156,6 +174,14 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
print "</center>\n"; print "</center>\n";
print "<br />\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 # query to pull out package info
# #
$q = "SELECT Packages.*, IF(ISNULL(PackageID), 0, COUNT(*)) AS Votes "; $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)."%') "; $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 "; $q.= "GROUP BY PackageID ";
switch ($SB) { switch ($SB) {
@ -201,6 +237,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
break; break;
} }
$q.= "LIMIT ".$OFFSET.", ".intval($PP); $q.= "LIMIT ".$OFFSET.", ".intval($PP);
$result = db_query($q, $dbh); $result = db_query($q, $dbh);
if (!$result) { if (!$result) {
print __("No packages matched your search criteria."); 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 " <td class='boxSoft'>\n";
print "<table width='100%' cellspacing='0' cellpadding='2'>\n"; print "<table width='100%' cellspacing='0' cellpadding='2'>\n";
print "<tr>\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 " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'><span class='f2'>".__("Location")."</span></th>\n"; print " bottom'><span class='f2'>".__("Location")."</span></th>\n";
print " <th style='border-bottom: #666 1px solid; vertical-align:"; 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++) { for ($i=0; $row = mysql_fetch_assoc($result); $i++) {
(($i % 2) == 0) ? $c = "data1" : $c = "data2"; (($i % 2) == 0) ? $c = "data1" : $c = "data2";
print "<tr>\n"; 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 " <td class='".$c."'><span class='f5'><span class='blue'>";
print $locs[$row["LocationID"]]."</span></span></td>\n"; print $locs[$row["LocationID"]]."</span></span></td>\n";
print " <td class='".$c."'><span class='f5'><span class='blue'>"; 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='Action' value='SearchPkgs'>\n";
print " <input type='hidden' name='O' value='".($OFFSET-intval($PP))."'>\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='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='C' value='".$C."'>\n";
print " <input type='hidden' name='K' value='".$K."'>\n"; print " <input type='hidden' name='K' value='".$K."'>\n";
print " <input type='hidden' name='SB' value='".$SB."'>\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='Action' value='SearchPkgs'>\n";
print " <input type='hidden' name='O' value='".($OFFSET+intval($PP))."'>\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='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='C' value='".$C."'>\n";
print " <input type='hidden' name='K' value='".$K."'>\n"; print " <input type='hidden' name='K' value='".$K."'>\n";
print " <input type='hidden' name='SB' value='".$SB."'>\n"; print " <input type='hidden' name='SB' value='".$SB."'>\n";