summaryrefslogtreecommitdiffstats
path: root/web/html/pkgsearch.php
diff options
context:
space:
mode:
authoreric <eric>2004-07-10 22:51:56 +0200
committereric <eric>2004-07-10 22:51:56 +0200
commitd17e406ac61094a0ad6d433c8e24be9b8b140959 (patch)
tree805443d8b20b0e8057b1f81df59c47382122dc06 /web/html/pkgsearch.php
parentae26c9ce2a0bfe6ed0f5282f08cb672364de1c19 (diff)
downloadaur-d17e406ac61094a0ad6d433c8e24be9b8b140959.tar.gz
aur-d17e406ac61094a0ad6d433c8e24be9b8b140959.tar.xz
pkgsearch is done (except for some serious debugging)
Diffstat (limited to 'web/html/pkgsearch.php')
-rw-r--r--web/html/pkgsearch.php261
1 files changed, 247 insertions, 14 deletions
diff --git a/web/html/pkgsearch.php b/web/html/pkgsearch.php
index 6524b51c..546ed2b5 100644
--- a/web/html/pkgsearch.php
+++ b/web/html/pkgsearch.php
@@ -6,11 +6,15 @@ set_lang(); # this sets up the visitor's language
check_sid(); # see if they're still logged in
html_header(); # print out the HTML header
-# define variables used during pkgsearch
+# enable debugging
#
-$pkgsearch_vars = array("O", "L", "C", "K", "SB", "PP", "do_MyPackages");
+$DBUG = 0;
+if ($DBUG) {
+ print "<pre>\n";
+ print_r($_REQUEST);
+ print "</pre>\n";
+}
-
# get login privileges
#
if (isset($_COOKIE["AURSID"])) {
@@ -24,6 +28,9 @@ if (isset($_COOKIE["AURSID"])) {
# grab the list of Package IDs to be operated on
#
isset($_REQUEST["IDs"]) ? $ids = $_REQUEST["IDs"] : $ids = array();
+#isset($_REQUEST["All_IDs"]) ?
+# $all_ids = explode(":", $_REQUEST["All_IDs"]) :
+# $all_ids = array();
# determine what button the visitor clicked
@@ -34,15 +41,75 @@ if (isset($_REQUEST["do_Flag"])) {
print "<br />\n";
} else {
- # Flag the packages in $ids array, and unflag any other
- # packages listed in $_REQUEST["All_IDs"]
- #
- print "flagging<br />\n";
+
+ if (!empty($ids)) {
+ $dbh = db_connect();
+
+ # Flag the packages in $ids array
+ #
+ $first = 1;
+ while (list($pid, $v) = each($ids)) {
+ if ($first) {
+ $first = 0;
+ $flag = $pid;
+ } else {
+ $flag .= ", ".$pid;
+ }
+ }
+ $q = "UPDATE Packages SET OutOfDate = 1 ";
+ $q.= "WHERE ID IN (" . $flag . ")";
+ db_query($q, $dbh);
+
+ print "<p>\n";
+ print __("The selected packages have been flagged out-of-date.");
+ print "</p>\n";
+ } else {
+ print "<p>\n";
+ print __("You did not select any packages to flag.");
+ print "</p>\n";
+ }
pkgsearch_results_link();
}
+} elseif (isset($_REQUEST["do_UnFlag"])) {
+ if (!$atype) {
+ print __("You must be logged in before you can unflag packages.");
+ print "<br />\n";
+
+ } else {
+
+ if (!empty($ids)) {
+ $dbh = db_connect();
+
+ # Un-Flag the packages in $ids array
+ #
+ $first = 1;
+ while (list($pid, $v) = each($ids)) {
+ if ($first) {
+ $first = 0;
+ $unflag = $pid;
+ } else {
+ $unflag .= ", ".$pid;
+ }
+ }
+ $q = "UPDATE Packages SET OutOfDate = 0 ";
+ $q.= "WHERE ID IN (" . $unflag . ")";
+ db_query($q, $dbh);
+
+ print "<p>\n";
+ print __("The selected packages have been unflagged.");
+ print "</p>\n";
+ } else {
+ print "<p>\n";
+ print __("You did not select any packages to unflag.");
+ print "</p>\n";
+ }
+
+ pkgsearch_results_link();
+
+ }
} elseif (isset($_REQUEST["do_Disown"])) {
if (!$atype) {
@@ -52,7 +119,45 @@ if (isset($_REQUEST["do_Flag"])) {
} else {
# Disown the packages in $ids array
#
- print "disowning<br />\n";
+ if (!empty($ids)) {
+ $dbh = db_connect();
+
+ # Disown the packages in $ids array
+ #
+ $first = 1;
+ while (list($pid, $v) = each($ids)) {
+ if ($first) {
+ $first = 0;
+ $disown = $pid;
+ } else {
+ $disown .= ", ".$pid;
+ }
+ }
+ $atype = account_from_sid($_COOKIE["AURSID"]);
+ if ($atype == "Trusted User" || $atype == "Developer") {
+ $field = "AURMaintainerUID";
+ } elseif ($atype == "User") {
+ $field = "MaintainerUID";
+ } else {
+ $field = "";
+ }
+
+ if ($field) {
+ $q = "UPDATE Packages ";
+ $q.= "SET ".$field." = 0 ";
+ $q.= "WHERE ID IN (" . $disown . ") ";
+ $q.= "AND ".$field." = ".uid_from_sid($_COOKIE["AURSID"]);
+ db_query($q, $dbh);
+ }
+
+ print "<p>\n";
+ print __("The selected packages have been disowned.");
+ print "</p>\n";
+ } else {
+ print "<p>\n";
+ print __("You did not select any packages to disowned.");
+ print "</p>\n";
+ }
pkgsearch_results_link();
@@ -67,7 +172,45 @@ if (isset($_REQUEST["do_Flag"])) {
} else {
# Adopt the packages in $ids array
#
- print "adopting<br />\n";
+ if (!empty($ids)) {
+ $dbh = db_connect();
+
+ # Adopt the packages in $ids array
+ #
+ $first = 1;
+ while (list($pid, $v) = each($ids)) {
+ if ($first) {
+ $first = 0;
+ $adopt = $pid;
+ } else {
+ $adopt .= ", ".$pid;
+ }
+ }
+ $atype = account_from_sid($_COOKIE["AURSID"]);
+ if ($atype == "Trusted User" || $atype == "Developer") {
+ $field = "AURMaintainerUID";
+ } elseif ($atype == "User") {
+ $field = "MaintainerUID";
+ } else {
+ $field = "";
+ }
+
+ if ($field) {
+ $q = "UPDATE Packages ";
+ $q.= "SET ".$field." = ".uid_from_sid($_COOKIE["AURSID"])." ";
+ $q.= "WHERE ID IN (" . $adopt . ") ";
+ $q.= "AND ".$field." = 0";
+ db_query($q, $dbh);
+ }
+
+ print "<p>\n";
+ print __("The selected packages have been adopted.");
+ print "</p>\n";
+ } else {
+ print "<p>\n";
+ print __("You did not select any packages to adopt.");
+ print "</p>\n";
+ }
pkgsearch_results_link();
@@ -80,10 +223,102 @@ if (isset($_REQUEST["do_Flag"])) {
print "<br />\n";
} else {
- # vote on the packages in $ids array. 'unvote' for any packages
- # listed in the $_REQUEST["All_IDs"] array.
+ # vote on the packages in $ids array.
+ #
+ if (!empty($ids)) {
+ $dbh = db_connect();
+ $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]);
+ $uid = uid_from_sid($_COOKIE["AURSID"]);
+ # $vote_ids will contain the string of Package.IDs that
+ # the visitor hasn't voted for already
+ #
+ $first = 1;
+ while (list($pid, $v) = each($ids)) {
+ if (!isset($my_votes[$pid])) {
+ # cast a vote for this package
+ #
+ if ($first) {
+ $first = 0;
+ $vote_ids = $pid;
+ $vote_clauses = "(".$uid.", ".$pid.")";
+ } else {
+ $vote_ids .= ", ".$pid;
+ $vote_clauses .= ", (".$uid.", ".$pid.")";
+ }
+ }
+ }
+ # only vote for packages the user hasn't already voted for
+ #
+ $q = "UPDATE Packages SET NumVotes = NumVotes + 1 ";
+ $q.= "WHERE ID IN (".$vote_ids.")";
+ db_query($q, $dbh);
+
+ $q = "INSERT INTO PackageVotes (UsersID, PackageID) VALUES ";
+ $q.= $vote_clauses;
+ db_query($q, $dbh);
+
+ print "<p>\n";
+ print __("Your votes have been cast for the selected packages.");
+ print "</p>\n";
+
+ } else {
+ print "<p>\n";
+ print __("You did not select any packages to vote for.");
+ print "</p>\n";
+ }
+
+ pkgsearch_results_link();
+
+ }
+
+
+} elseif (isset($_REQUEST["do_UnVote"])) {
+ if (!$atype) {
+ print __("You must be logged in before you can un-vote for packages.");
+ print "<br />\n";
+
+ } else {
+ # un-vote on the packages in $ids array.
#
- print "voting<br />\n";
+ if (!empty($ids)) {
+ $dbh = db_connect();
+ $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]);
+ $uid = uid_from_sid($_COOKIE["AURSID"]);
+ # $unvote_ids will contain the string of Package.IDs that
+ # the visitor has voted for and wants to unvote.
+ #
+ $first = 1;
+ while (list($pid, $v) = each($ids)) {
+ if (isset($my_votes[$pid])) {
+ # cast a un-vote for this package
+ #
+ if ($first) {
+ $first = 0;
+ $unvote_ids = $pid;
+ } else {
+ $unvote_ids .= ", ".$pid;
+ }
+ }
+ }
+ # only un-vote for packages the user has already voted for
+ #
+ $q = "UPDATE Packages SET NumVotes = NumVotes - 1 ";
+ $q.= "WHERE ID IN (".$unvote_ids.")";
+ db_query($q, $dbh);
+
+ $q = "DELETE FROM PackageVotes WHERE UsersID = ".$uid." ";
+ $q.= "AND PackageID IN (".$unvote_ids.")";
+ db_query($q, $dbh);
+
+ print "<p>\n";
+ print __("Your votes have been removed from the selected packages.");
+ print "</p>\n";
+
+ } else {
+ print "<p>\n";
+ print __("You did not select any packages to un-vote for.");
+ print "</p>\n";
+ }
pkgsearch_results_link();
@@ -101,8 +336,6 @@ if (isset($_REQUEST["do_Flag"])) {
print "<br />\n";
pkgsearch_results_link();
- print "</center>\n";
- print "<br />\n";
} else {