summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorsimo <simo>2005-11-27 04:05:27 +0000
committersimo <simo>2005-11-27 04:05:27 +0000
commit70af7c7d5c5945039f494ca5f9e435bc515db18e (patch)
tree009c36a334c9f4cca8819ce29c698eaff5098e8d /web/lib
parentfbd7b5a9d4119cf53629f2b01a2a6ca39c29ea07 (diff)
downloadaurweb-70af7c7d5c5945039f494ca5f9e435bc515db18e.tar.xz
add search by submitter functionality
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/aur.inc19
-rw-r--r--web/lib/pkgfuncs.inc19
2 files changed, 33 insertions, 5 deletions
diff --git a/web/lib/aur.inc b/web/lib/aur.inc
index ed2ff64..81e5a45 100644
--- a/web/lib/aur.inc
+++ b/web/lib/aur.inc
@@ -542,5 +542,24 @@ function rm_rf($dirname="") {
return;
}
+# obtain the uid given a Users.Username
+#
+function uid_from_username($username="")
+{
+ if (!$username) {
+ return "";
+ }
+ $dbh = db_connect();
+ $q = "SELECT ID FROM Users WHERE Username = '".mysql_escape_string($username)
+ ."'";
+ $result = db_query($q, $dbh);
+ if (!$result) {
+ return "None";
+ }
+ $row = mysql_fetch_row($result);
+
+ return $row[0];
+}
+
# vim: ts=2 sw=2 noet ft=php
?>
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 19d205d..d339922 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -677,6 +677,9 @@ function pkg_search_page($SID="") {
print " <option value=m";
$_REQUEST["SeB"] == "m" ? print " selected> " : print "> ";
print __("Maintainer")."</option>\n";
+ print " <option value=s";
+ $_REQUEST["SeB"] == "s" ? print " selected> " : print "> ";
+ print __("Submitter")."</option>\n";
print " </select>\n";
print "</td>\n";
@@ -800,14 +803,20 @@ function pkg_search_page($SID="") {
#search by maintainer
if ($_REQUEST["SeB"] == "m"){
if (!$has_where) {
- $q.= "WHERE Username = '".mysql_escape_string($K)."' ";
+ $q.= "WHERE Username = '".mysql_escape_string($K)."' ";
$has_where = 1;
- } else {
- $q.= "AND Username = '".mysql_escape_string($K)."' ";
- }
+ } else {
+ $q.= "AND Username = '".mysql_escape_string($K)."' ";
+ }
+ } elseif ($_REQUEST["SeB"] == "s") {
+ if (!$has_where) {
+ $q.= "WHERE SubmitterUID = ".uid_from_username($K)." ";
+ $has_where = 1;
+ } else {
+ $q.= "AND SubmitterUID = ".uid_from_username($K)." ";
}
# the default behaivior, query the name/description
- else {
+ } else {
if (!$has_where) {
$q.= "WHERE (Name LIKE '%".mysql_escape_string($K)."%' OR ";
$q.= "Description LIKE '%".mysql_escape_string($K)."%') ";