mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Revamped pkg_search_page()
- Reduced database hits - Improved speed - Improved sanity (slightly) - Fixed searches,buttons,gizmos Signed-off-by: Simo Leone <simo@archlinux.org>
This commit is contained in:
parent
da3b397ac9
commit
99e65b28d8
3 changed files with 499 additions and 551 deletions
|
@ -18,8 +18,6 @@ if (isset($_GET['ID'])) {
|
|||
}
|
||||
} else if (!empty($_GET['K'])) {
|
||||
$title = "Search: " . $_GET['K'];
|
||||
} else if (!empty($_GET['do_MyPackages'])) {
|
||||
$title = __("My Packages");
|
||||
} else {
|
||||
$title = __("Packages");
|
||||
}
|
||||
|
@ -520,7 +518,7 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
# do_More/do_Less/do_Search/do_MyPackages - just do a search
|
||||
# just do a search
|
||||
#
|
||||
pkg_search_page($_COOKIE["AURSID"]);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ include_once("config.inc");
|
|||
|
||||
# define variables used during pkgsearch
|
||||
#
|
||||
$pkgsearch_vars = array("O", "L", "C", "K", "SB", "SO", "PP", "do_MyPackages", "do_Orphans", "SeB");
|
||||
$pkgsearch_vars = array("O", "L", "C", "K", "SB", "SO", "PP", "do_Orphans", "SeB");
|
||||
|
||||
# Make sure this visitor can delete the requested package comment
|
||||
# They can delete if they were the comment submitter, or if they are a TU/Dev
|
||||
|
@ -374,7 +374,7 @@ function package_details($id=0, $SID="") {
|
|||
while (list($k, $darr) = each($deps)) {
|
||||
$url = "<a href='/packages.php?do_Details=1&ID=".$darr[0];
|
||||
while(list($k, $var) = each($pkgsearch_vars)) {
|
||||
if (($var == "do_MyPackages" || $var == "do_Orphans") && $_REQUEST[$var]) {
|
||||
if (($var == "do_Orphans") && $_REQUEST[$var]) {
|
||||
$url .= "&".$var."=1";
|
||||
} else {
|
||||
$url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
|
||||
|
@ -404,7 +404,7 @@ function package_details($id=0, $SID="") {
|
|||
while (list($k, $darr) = each($deps)) {
|
||||
$url = "<a href='/packages.php?do_Details=1&ID=".$darr[0];
|
||||
while(list($k, $var) = each($pkgsearch_vars)) {
|
||||
if (($var == "do_MyPackages" || $var == "do_Orphans") && $_REQUEST[$var]) {
|
||||
if (($var == "do_Orphans") && $_REQUEST[$var]) {
|
||||
$url .= "&".$var."=1";
|
||||
} else {
|
||||
$url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
|
||||
|
@ -591,70 +591,91 @@ function package_details($id=0, $SID="") {
|
|||
}
|
||||
|
||||
|
||||
# display the search form in a boxSoft style
|
||||
#
|
||||
/* pkg_search_page(SID)
|
||||
* outputs the body of search/search results page
|
||||
*
|
||||
* parameters:
|
||||
* SID - current Session ID
|
||||
* preconditions:
|
||||
* package search page has been accessed
|
||||
* request variables have not been sanitized
|
||||
*
|
||||
* request vars:
|
||||
* O - starting result number
|
||||
* PP - number of search hits per page
|
||||
* L - package location ID number
|
||||
* C - package category ID number
|
||||
* K - package search string
|
||||
* SO - search hit sort order:
|
||||
* values: a - ascending
|
||||
* d - descending
|
||||
* SB - sort search hits by:
|
||||
* values: l - package location
|
||||
* c - package category
|
||||
* n - package name
|
||||
* v - number of votes
|
||||
* m - maintainer username
|
||||
* SeB- property that search string (K) represents
|
||||
* values: nd - package name&description
|
||||
* m - package maintainer's username
|
||||
* s - package submitter's username
|
||||
* do_Orphans - boolean. whether to search packages
|
||||
* without a maintainer
|
||||
*
|
||||
*
|
||||
* These two are actually handled in packages.php.
|
||||
*
|
||||
* IDs- integer array of ticked packages' IDs
|
||||
* action - action to be taken on ticked packages
|
||||
* values: do_Flag - Flag out-of-date
|
||||
* do_UnFlag - Remove out-of-date flag
|
||||
* do_Adopt - Adopt
|
||||
* do_Disown - Disown
|
||||
* do_Delete - Delete
|
||||
* do_Notify - Toggle notification
|
||||
*/
|
||||
function pkg_search_page($SID="") {
|
||||
global $_REQUEST;
|
||||
global $pkgsearch_vars;
|
||||
# SID: session id cookie
|
||||
|
||||
$locs = pkgLocations();
|
||||
$cats = pkgCategories();
|
||||
$devs = getDevelopers();
|
||||
$tus = getTrustedUsers();
|
||||
$users = getUsers();
|
||||
// establish a db connection
|
||||
$dbh = db_connect();
|
||||
|
||||
// get commonly used variables...
|
||||
// TODO: REDUCE DB HITS.
|
||||
// grab info for user if they're logged in
|
||||
if ($SID)
|
||||
$myuid = uid_from_sid($SID);
|
||||
// get a list of package locations
|
||||
$locs = pkgLocations();
|
||||
// get a list of package categories
|
||||
$cats = pkgCategories(); //meow
|
||||
|
||||
# determine paging variables
|
||||
#
|
||||
if (intval($_GET['O'])) {
|
||||
$O = $_GET['O'];
|
||||
// sanitize paging variables
|
||||
//
|
||||
if (isset($_REQUEST['O'])) {
|
||||
$O = intval($_REQUEST['O']);
|
||||
if ($O < 0)
|
||||
$O = 0;
|
||||
} else {
|
||||
$O = 0;
|
||||
}
|
||||
$_REQUEST["PP"] ? $PP = intval($_REQUEST["PP"]) : $PP = 25;
|
||||
if ($PP < 25) {$PP = 25;}
|
||||
if ($PP > 100) {$PP = 100;}
|
||||
|
||||
if ($_REQUEST["do_Search"] && $_REQUEST["do_Search"] != 1) {
|
||||
# reset the offset to zero if they hit Go
|
||||
#
|
||||
$_REQUEST["do_MyPackages"] = 0;
|
||||
$_REQUEST["do_Orphans"] = 0;
|
||||
$O = 0;
|
||||
}
|
||||
if ($_REQUEST["do_MyPackages"] && $_REQUEST["do_MyPackages"] != 1) {
|
||||
# reset the offset to zero if they hit My Packages
|
||||
#
|
||||
$_REQUEST["do_Search"] = 0;
|
||||
$_REQUEST["do_Orphans"] = 0;
|
||||
$O = 0;
|
||||
}
|
||||
if (!empty($_REQUEST['do_Orphans']) && $_REQUEST['do_Orphans'] != 1) {
|
||||
# reset the offset to zero if they hit Orphans
|
||||
#
|
||||
$_REQUEST["do_Search"] = 0;
|
||||
$_REQUEST["do_MyPackages"] = 0;
|
||||
$O = 0;
|
||||
}
|
||||
$_REQUEST["O"] = $O; # so that pkg_search_results() works
|
||||
|
||||
|
||||
# grab info for user if they're logged in
|
||||
#
|
||||
if ($SID) {
|
||||
$myuid = uid_from_sid($SID);
|
||||
$acct = account_from_sid($SID);
|
||||
$my_votes = pkgvotes_from_sid($SID);
|
||||
$my_notify = pkgnotify_from_sid($SID);
|
||||
if (isset($_REQUEST["PP"])) {
|
||||
$PP = intval($_REQUEST["PP"]);
|
||||
if ($PP < 25)
|
||||
$PP = 25;
|
||||
else if ($PP > 100)
|
||||
$PP = 100;
|
||||
} else {
|
||||
$PP = 25;
|
||||
}
|
||||
|
||||
# The search form
|
||||
#
|
||||
print "<form action='/packages.php' method='post'>\n";
|
||||
#print "<form action='/packages.php' method='get'>\n";
|
||||
print "<input type='hidden' name='O' value='".$O."'>\n";
|
||||
// The search form - XXX: split into own function?
|
||||
//
|
||||
// FIXME: highly fugly. whoever makes this use
|
||||
// less print statements gets a cookie
|
||||
// FIXME: ugly html. whoever un-tables this gets
|
||||
// another cookie
|
||||
print "<form action='/packages.php' method='get'>\n";
|
||||
print "<input type='hidden' name='O' value='0'>\n";
|
||||
|
||||
print "<center>\n";
|
||||
print "<table cellspacing='3' class='boxSoft'>\n";
|
||||
|
@ -703,9 +724,7 @@ function pkg_search_page($SID="") {
|
|||
print "</span></span><br />\n";
|
||||
print " <input type='text' name='K' size='20'";
|
||||
|
||||
# Added to trim() to avoid the problem described in #6191
|
||||
$K = trim(str_replace("\"", "", $_REQUEST["K"])); # TODO better testing for SQL trickery...
|
||||
|
||||
$K = trim(htmlspecialchars($_REQUEST["K"], ENT_QUOTES));
|
||||
print " value=\"".stripslashes($K)."\" maxlength='35'>\n";
|
||||
print "</td>\n";
|
||||
|
||||
|
@ -744,7 +763,7 @@ function pkg_search_page($SID="") {
|
|||
print " </select>\n";
|
||||
print "</td>\n";
|
||||
|
||||
# Added to break put the buttons in a new line
|
||||
// Added to break put the buttons in a new line
|
||||
print"</tr></table><center><table><tr>";
|
||||
|
||||
print "<td align='right' valign='bottom'> \n";
|
||||
|
@ -764,89 +783,67 @@ function pkg_search_page($SID="") {
|
|||
print "</tr>\n";
|
||||
print "</table>\n";
|
||||
print "</center>\n";
|
||||
print "</form>\n";
|
||||
print "<br />\n";
|
||||
|
||||
# query to pull out package info
|
||||
#
|
||||
# $q = "SELECT Packages.*, IF(ISNULL(PackageID), 0, COUNT(*)) AS Votes ";
|
||||
# $q.= "FROM Packages LEFT JOIN PackageVotes ";
|
||||
# $q.= "ON Packages.ID = PackageVotes.PackageID ";
|
||||
$q = "SELECT * FROM Users RIGHT JOIN Packages ";
|
||||
$q.= "ON (Users.ID = Packages.MaintainerUID) ";
|
||||
$q.= "WHERE DummyPkg != 1 ";
|
||||
$has_where = 1;
|
||||
|
||||
if (intval($_REQUEST["L"])) {
|
||||
if (!$has_where) {
|
||||
$q.= "WHERE LocationID = ".intval($_REQUEST["L"])." ";
|
||||
} else {
|
||||
$q .= "AND LocationID = ".intval($_REQUEST["L"])." ";
|
||||
// FIXME: pull out DB-related code. all of it.
|
||||
// this one's worth a choco-chip cookie,
|
||||
// one of those nice big soft ones
|
||||
|
||||
// build the package search query
|
||||
//
|
||||
$q = "SELECT SQL_CALC_FOUND_ROWS ";
|
||||
if ($SID) {
|
||||
$q .= "CommentNotify.UserID AS Notify,
|
||||
PackageVotes.UsersID AS Voted, ";
|
||||
}
|
||||
$has_where = 1;
|
||||
$q .= "Users.Username AS Maintainer,
|
||||
PackageCategories.Category,
|
||||
PackageLocations.Location,
|
||||
Packages.Name, Packages.Version, Packages.Description, Packages.NumVotes,
|
||||
Packages.ID, Packages.OutOfDate
|
||||
|
||||
FROM PackageCategories, PackageLocations, Packages
|
||||
LEFT JOIN Users ON (Packages.MaintainerUID = Users.ID) ";
|
||||
if ($SID) {
|
||||
$q .= "LEFT JOIN PackageVotes
|
||||
ON (Packages.ID = PackageVotes.PackageID AND PackageVotes.UsersID = ".$myuid.")
|
||||
LEFT JOIN CommentNotify
|
||||
ON (Packages.ID = CommentNotify.PkgID AND CommentNotify.UserID = ".$myuid.") ";
|
||||
}
|
||||
$q .= "WHERE
|
||||
Packages.CategoryID = PackageCategories.ID
|
||||
AND Packages.LocationID = PackageLocations.ID
|
||||
AND Packages.DummyPkg = 0 ";
|
||||
|
||||
// TODO: possibly do string matching on category and
|
||||
// location to make request variable values more sensible
|
||||
if (intval($_REQUEST["L"])) {
|
||||
$q .= "AND Packages.LocationID = ".intval($_REQUEST["L"])." ";
|
||||
}
|
||||
if (intval($_REQUEST["C"])) {
|
||||
if (!$has_where) {
|
||||
$q.= "WHERE CategoryID = ".intval($_REQUEST["C"])." ";
|
||||
$has_where = 1;
|
||||
} else {
|
||||
$q.= "AND CategoryID = ".intval($_REQUEST["C"])." ";
|
||||
$q.= "AND Packages.CategoryID = ".intval($_REQUEST["C"])." ";
|
||||
}
|
||||
}
|
||||
if ($K) {
|
||||
#search by maintainer
|
||||
|
||||
if ($_REQUEST['K']) {
|
||||
$K = mysql_real_escape_string(trim($_REQUEST['K']));
|
||||
//search by maintainer
|
||||
if ($_REQUEST["SeB"] == "m"){
|
||||
if (!$has_where) {
|
||||
$q.= "WHERE Username = '".mysql_real_escape_string($K)."' ";
|
||||
$has_where = 1;
|
||||
} else {
|
||||
$q.= "AND Username = '".mysql_real_escape_string($K)."' ";
|
||||
}
|
||||
$q.= "AND Users.Username = '".$K."' ";
|
||||
} elseif ($_REQUEST["SeB"] == "s") {
|
||||
if (!$has_where) {
|
||||
$q.= "WHERE SubmitterUID = ".uid_from_username($K)." ";
|
||||
$has_where = 1;
|
||||
// FIXME: this shouldn't be making 2 queries
|
||||
// kill the call to uid_from_username
|
||||
$q.= "AND SubmitterUID = ".uid_from_username($_REQUEST['K'])." ";
|
||||
// the default behavior, query the name/description
|
||||
} else {
|
||||
$q.= "AND SubmitterUID = ".uid_from_username($K)." ";
|
||||
}
|
||||
# the default behaivior, query the name/description
|
||||
} else {
|
||||
if (!$has_where) {
|
||||
$q.= "WHERE (Name LIKE '%".mysql_real_escape_string($K)."%' OR ";
|
||||
$q.= "Description LIKE '%".mysql_real_escape_string($K)."%') ";
|
||||
$has_where = 1;
|
||||
} else {
|
||||
$q.= "AND (Name LIKE '%".mysql_real_escape_string($K)."%' OR ";
|
||||
$q.= "Description LIKE '%".mysql_real_escape_string($K)."%') ";
|
||||
}
|
||||
$q.= "AND (Name LIKE '%".$K."%' OR ";
|
||||
$q.= "Description LIKE '%".$K."%') ";
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST["do_MyPackages"] && $SID) {
|
||||
# list packages that the user is a AUR Maintainer of, or if it the
|
||||
# vistior is a registered user, if they are the Maintainer.
|
||||
#
|
||||
if ($myuid) {
|
||||
if (!$has_where) {
|
||||
$q.= "WHERE (AURMaintainerUID = ".$myuid." OR ";
|
||||
$has_where = 1;
|
||||
} else {
|
||||
$q.= "AND (AURMaintainerUID = ".$myuid." OR ";
|
||||
}
|
||||
//$q.= "MaintainerUID = ".$myuid." OR SubmitterUID = ".$myuid.") ";
|
||||
$q.= "MaintainerUID = ".$myuid.") ";
|
||||
}
|
||||
}
|
||||
if ($_REQUEST["do_Orphans"]) {
|
||||
# List packages that have neither a Maintainer nor AURMaintainer
|
||||
#
|
||||
if (!$has_where) {
|
||||
$q.= "WHERE (AURMaintainerUID = 0 AND ";
|
||||
$q.= "MaintainerUID = 0) ";
|
||||
$has_where = 1;
|
||||
} else {
|
||||
$q.= "AND (AURMaintainerUID = 0 AND ";
|
||||
$q.= "MaintainerUID = 0) ";
|
||||
}
|
||||
$q.= "AND MaintainerUID = 0 ";
|
||||
}
|
||||
|
||||
$order = $_REQUEST["SO"] == 'd' ? 'DESC' : 'ASC';
|
||||
|
@ -865,7 +862,7 @@ function pkg_search_page($SID="") {
|
|||
$SB = 'v';
|
||||
break;
|
||||
case 'm':
|
||||
$q.= "ORDER BY Username ".$order.", Name ASC, LocationID ASC ";
|
||||
$q.= "ORDER BY Maintainer ".$order.", Name ASC, LocationID ASC ";
|
||||
$SB = 'm';
|
||||
break;
|
||||
case 'a':
|
||||
|
@ -877,13 +874,12 @@ function pkg_search_page($SID="") {
|
|||
break;
|
||||
}
|
||||
|
||||
$allresults = mysql_num_rows(db_query($q, $dbh));
|
||||
|
||||
$qnext = $q."LIMIT ".($O+$PP).", ".$PP; //next page's worth
|
||||
$q.= "LIMIT ".$O.", ".$PP;
|
||||
|
||||
$result = db_query($q, $dbh);
|
||||
$total = mysql_result(db_query('SELECT FOUND_ROWS() AS Total', $dbh), 0);
|
||||
|
||||
print "<form action='/packages.php' method='post'>\n";
|
||||
print "<center>\n";
|
||||
print "<table cellspacing='3' class='boxSoft'>\n";
|
||||
print "<tr>\n";
|
||||
|
@ -899,15 +895,15 @@ function pkg_search_page($SID="") {
|
|||
print "<div class='pgboxbody'>";
|
||||
print __("Error retrieving package list.");
|
||||
print "</div>";
|
||||
} elseif (!mysql_num_rows($result)) {
|
||||
} elseif ($total == 0) {
|
||||
print "<div class='pgboxbody'>";
|
||||
print __("No packages matched your search criteria.");
|
||||
print "</div>";
|
||||
} else {
|
||||
# print out package search results
|
||||
#
|
||||
// print out package search results
|
||||
//
|
||||
|
||||
# SO_next used to change sort order on header click
|
||||
// SO_next used to change sort order on header click
|
||||
if ($_REQUEST["SO"] == "d"){
|
||||
$SO_next="a";
|
||||
$SO = 'd';
|
||||
|
@ -922,19 +918,19 @@ function pkg_search_page($SID="") {
|
|||
}
|
||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||
print " bottom'><span class='f2'>";
|
||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=l&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Location")."</a>";
|
||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=l&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Location")."</a>";
|
||||
print "</span></th>\n";
|
||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||
print " bottom'><span class='f2'>";
|
||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=c&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Category")."</a>";
|
||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=c&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Category")."</a>";
|
||||
print "</span></th>\n";
|
||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||
print " bottom'><span class='f2'>";
|
||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=n&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Name")."</a>";
|
||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=n&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Name")."</a>";
|
||||
print "</span></th>\n";
|
||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||
print " bottom'><span class='f2'>";
|
||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=v&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Votes")."</a>";
|
||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=v&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Votes")."</a>";
|
||||
print "</span></th>\n";
|
||||
if ($SID) {
|
||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||
|
@ -949,13 +945,8 @@ function pkg_search_page($SID="") {
|
|||
print "</span></th>\n";
|
||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||
print " bottom'><span class='f2'>";
|
||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=m&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Maintainer")."</a>";
|
||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=m&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Maintainer")."</a>";
|
||||
print "</span></th>\n";
|
||||
# REMOVED LINK TO 'pkgmgmnt.php'
|
||||
# if ($SID) {
|
||||
# print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||
# print " bottom'><span class='f2'>".__("Manage")."</span></th>\n";
|
||||
# }
|
||||
print "</tr>\n";
|
||||
|
||||
for ($i=0; $row = mysql_fetch_assoc($result); $i++) {
|
||||
|
@ -967,20 +958,15 @@ function pkg_search_page($SID="") {
|
|||
}
|
||||
print " <td class='".$c."'>";
|
||||
print "<input type='checkbox' name='IDs[".$row["ID"]."]' value='1'>";
|
||||
# if ($i == 0) {
|
||||
# $all_ids = $row["ID"];
|
||||
# } else {
|
||||
# $all_ids .= ":".$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 $row["Location"]."</span></span></td>\n";
|
||||
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
||||
print $cats[$row["CategoryID"]]."</span></span></td>\n";
|
||||
print $row["Category"]."</span></span></td>\n";
|
||||
print " <td class='".$c."'><span class='f4'>";
|
||||
$url = "<a href='/packages.php?";
|
||||
$url .= "ID=";
|
||||
|
@ -994,15 +980,13 @@ function pkg_search_page($SID="") {
|
|||
print " ".$row["NumVotes"]."</span></span></td>\n";
|
||||
if ($SID) {
|
||||
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
||||
if (isset($my_votes[$row["ID"]])) {
|
||||
if (isset($row["Voted"])) {
|
||||
print " ".__("Yes")."</span></td>\n";
|
||||
} else {
|
||||
print " </span></td>\n";
|
||||
}
|
||||
}
|
||||
if ($SID) {
|
||||
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
||||
if (isset($my_notify[$row["ID"]])) {
|
||||
if (isset($row["Notify"])) {
|
||||
print " ".__("Yes")."</span></td>\n";
|
||||
} else {
|
||||
print " </span></td>\n";
|
||||
|
@ -1012,40 +996,14 @@ function pkg_search_page($SID="") {
|
|||
print $row["Description"]."</span></span></td>\n";
|
||||
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
||||
|
||||
# print the package manager, also determine if it is managed
|
||||
#
|
||||
$managed = 1;
|
||||
# if (isset($devs[$row["AURMaintainerUID"]])) {
|
||||
# print $devs[$row["AURMaintainerUID"]]["Username"];
|
||||
# } else
|
||||
# if (isset($tus[$row["MaintainerUID"]])) {
|
||||
# print $tus[$row["MaintainerUID"]]["Username"];
|
||||
if (isset($users[$row["MaintainerUID"]])) {
|
||||
# Add a link to the user packages, e.g, if you click on the Solve the sorting problem, so we can force the
|
||||
# maintainer name, you will be redirected to a page with the user packages.
|
||||
$user = $users[$row["MaintainerUID"]]["Username"];
|
||||
print "<a href='packages.php?K=".$user."&SeB=m'>".$users[$row["MaintainerUID"]]["Username"]."</a>";
|
||||
if (isset($row["Maintainer"])) {
|
||||
print "<a href='packages.php?K=".$row['Maintainer']."&SeB=m'>".$row['Maintainer']."</a>";
|
||||
} else {
|
||||
print "<span style='color: blue; font-style: italic;'>";
|
||||
print __("orphan");
|
||||
print "</span>";
|
||||
$managed = 0;
|
||||
}
|
||||
print "</span></span></td>\n";
|
||||
|
||||
# REMOVED LINK TO 'pkgmgmnt.php'
|
||||
# # print the managed link if applicable
|
||||
# #
|
||||
# if (canManagePackage($myuid, $row["AURMaintainerUID"],
|
||||
# $row["MaintainerUID"], $row["SubmitterUID"], $managed)) {
|
||||
# $manage_url = "<a href='/pkgmgmnt.php?ID=";
|
||||
# $manage_url.= $row["ID"]."'><span class='black'>Manage</span></a>";
|
||||
# print " <td class='".$c."'><span class='f4'>";
|
||||
# print $manage_url."</span></td>\n";
|
||||
# } else {
|
||||
# print "<td class='".$c."'><span class='f4'> </span></td>\n";
|
||||
# }
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
}
|
||||
|
@ -1053,17 +1011,10 @@ function pkg_search_page($SID="") {
|
|||
print " </td>\n";
|
||||
print "</tr>\n";
|
||||
print "</table>\n";
|
||||
# print "<input type='hidden' name='All_IDs' value='".$all_ids."'>\n";
|
||||
if ($_REQUEST["do_MyPackages"]) {
|
||||
print "<input type='hidden' name='do_MyPackages' value='1'>\n";
|
||||
}
|
||||
if ($_REQUEST["do_Orphans"]) {
|
||||
print "<input type='hidden' name='do_Orphans' value='1'>\n";
|
||||
}
|
||||
|
||||
if ($SID) {
|
||||
# The 'Actions' box
|
||||
#
|
||||
// The 'Actions' box
|
||||
//
|
||||
print "<div style='text-align: right; padding: 5px 5% 5px 0'>";
|
||||
print "<select name='action'>";
|
||||
print "<option>" . __("Actions") . "</option>";
|
||||
|
@ -1084,23 +1035,23 @@ function pkg_search_page($SID="") {
|
|||
print " <table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
|
||||
print " <tr>\n";
|
||||
|
||||
# figure out the results to use
|
||||
// figure out the results to use
|
||||
$first = $O + 1;
|
||||
|
||||
if (($PP+$O) > $allresults) {
|
||||
$last = $allresults;
|
||||
if (($PP+$O) > $total) {
|
||||
$last = $total;
|
||||
} else {
|
||||
$last = $PP + $O;
|
||||
}
|
||||
|
||||
# print number of results
|
||||
# ok this styling sucks
|
||||
# patches welcome!
|
||||
// print number of results
|
||||
// ok this styling sucks
|
||||
// patches welcome!
|
||||
print "<tr><td align='center' colspan='0'><span class='f4'><span class='blue'>";
|
||||
print __("Showing results %s - %s of %s", array($first, $last, $allresults));
|
||||
print __("Showing results %s - %s of %s", array($first, $last, $total));
|
||||
print "</span></span></td></tr>";
|
||||
|
||||
# first print the legend
|
||||
// first print the legend
|
||||
print " <td colspan='2' align='center'>";
|
||||
print " <span class='f5'>\n";
|
||||
if ($SID) {
|
||||
|
@ -1110,24 +1061,23 @@ function pkg_search_page($SID="") {
|
|||
print " </tr>";
|
||||
|
||||
|
||||
# now print the forward and back buttons on the bottom
|
||||
# LEFT
|
||||
// now print the forward and back buttons on the bottom
|
||||
// LEFT
|
||||
print " <tr>";
|
||||
print " <td align='left'>";
|
||||
if (($O-$PP) >= 0) {
|
||||
print "<a href='/packages.php?O=" . ($O - $PP) . "&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>";
|
||||
print "<a href='/packages.php?O=" . ($O - $PP) . "&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>";
|
||||
} else if ($O<$PP && $O>0) {
|
||||
print "<a href='/packages.php?O=0&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>";
|
||||
print "<a href='/packages.php?O=0&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>";
|
||||
}
|
||||
print " </td>";
|
||||
# RIGHT
|
||||
// RIGHT
|
||||
print " <td align='right'>";
|
||||
if (mysql_num_rows(db_query($qnext, $dbh))) {
|
||||
if ($total - $PP - $O > 0) {
|
||||
print "<a href='/packages.php?O=" . ($O + $PP) .
|
||||
"&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"]) .
|
||||
"&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"] .
|
||||
"&do_MyPackages=".$_REQUEST["do_MyPackages"] .
|
||||
"&do_Orphans=".isset($_REQUEST["do_Orphans"])."'>" .
|
||||
"&do_Orphans=".$_REQUEST["do_Orphans"]."'>" .
|
||||
__("More") . "</a>";
|
||||
}
|
||||
print " </td>\n";
|
||||
|
@ -1143,5 +1093,5 @@ function pkg_search_page($SID="") {
|
|||
return;
|
||||
}
|
||||
|
||||
# vim: ts=2 sw=2 noet ft=php
|
||||
# vim: ts=4 sw=4 et ft=php
|
||||
?>
|
||||
|
|
|
@ -48,7 +48,7 @@ if (isset($_COOKIE["AURSID"])) {
|
|||
?>
|
||||
<li><a href="/logout.php"><?php print __("Logout"); ?></a></li>
|
||||
<li><a href="/pkgsubmit.php"><?php print __("Submit"); ?></a></li>
|
||||
<li><a href="/packages.php?do_MyPackages=1"><?php print __("My Packages"); ?></a></li>
|
||||
<li><a href="/packages.php?SeB=m&K=<?php print username_from_sid($_COOKIE["AURSID"]); ?>"><?php print __("My Packages"); ?></a></li>
|
||||
<?php
|
||||
if (account_from_sid($_COOKIE["AURSID"]) == "Trusted User"
|
||||
|| account_from_sid($_COOKIE["AURSID"]) == "Developer") {
|
||||
|
|
Loading…
Add table
Reference in a new issue