summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorsimo <simo>2005-05-06 05:58:26 +0200
committersimo <simo>2005-05-06 05:58:26 +0200
commited17d0f69e3f8f88ed8f23ad12543022636fd87a (patch)
tree1d9b6eecf3f6694a116754178af3e7f60aa6a5af /web
parent90eadf0252fcb7358b7e915bae8dc57e70c65750 (diff)
downloadaur-ed17d0f69e3f8f88ed8f23ad12543022636fd87a.tar.gz
aur-ed17d0f69e3f8f88ed8f23ad12543022636fd87a.tar.xz
Added vote button to detail page (bug#2638)
X's only show up if user can delete comment
Diffstat (limited to 'web')
-rw-r--r--web/html/packages.php15
-rw-r--r--web/lib/pkgfuncs.inc27
2 files changed, 34 insertions, 8 deletions
diff --git a/web/html/packages.php b/web/html/packages.php
index 210f1354..604ba72c 100644
--- a/web/html/packages.php
+++ b/web/html/packages.php
@@ -372,7 +372,11 @@ if (isset($_REQUEST["do_Flag"])) {
print "</p>\n";
}
- pkgsearch_results_link();
+ if (isset($_REQUEST["ID"])) {
+ pkgdetails_link($_REQUEST["ID"]);
+ } else {
+ pkgsearch_results_link();
+ }
}
@@ -425,7 +429,11 @@ if (isset($_REQUEST["do_Flag"])) {
print "</p>\n";
}
- pkgsearch_results_link();
+ if (isset($_REQUEST["ID"])) {
+ pkgdetails_link($_REQUEST["ID"]);
+ } else {
+ pkgsearch_results_link();
+ }
}
@@ -436,10 +444,11 @@ if (isset($_REQUEST["do_Flag"])) {
print __("Error trying to retrieve package details.")."<br />\n";
} else {
- package_details($_REQUEST["ID"]);
+ package_details($_REQUEST["ID"], $_COOKIE["AURSID"]);
}
print "<br />\n";
+ # FIXME: If someone hits the detail page's vote button, this link dies
pkgsearch_results_link();
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index dd168da7..b0e570fd 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -246,7 +246,7 @@ function pkgvotes_from_sid($sid="") {
# display package details
#
-function package_details($id=0) {
+function package_details($id=0, $SID="") {
global $_REQUEST;
global $pkgsearch_vars;
$q = "SELECT Packages.*,Location,Category ";
@@ -392,10 +392,12 @@ function package_details($id=0) {
print " <td valign='top' style='padding-right: 10' colspan='2'>";
print "<table class='boxSoft' width='100%'>";
print "<tr><td class='boxSoftTitle'><span class='f3'>";
- $durl = "<a href='/pkgedit.php?del_Comment=1";
- $durl.= "&comment_id=".$carr["ID"]."&ID=".$row["ID"];
- $durl.= "'><img src='/images/x.png' border='0'";
- $durl.= " alt=\"".__("Delete comment")."\"></a>";
+ if (canDeleteComment($carr["ID"], account_from_sid($SID), $SID)) {
+ $durl = "<a href='/pkgedit.php?del_Comment=1";
+ $durl.= "&comment_id=".$carr["ID"]."&ID=".$row["ID"];
+ $durl.= "'><img src='/images/x.png' border='0'";
+ $durl.= " alt=\"".__("Delete comment")."\"></a>";
+ }
print $durl . "&nbsp;&nbsp;";
print __("Comment by: %h%s%h on %h%s%h",
array("<b>",$carr["UserName"],"</b>",
@@ -423,6 +425,21 @@ function package_details($id=0) {
print __("Add Comment")."\">";
print "</form>\n";
print " </td>";
+ if ($SID) {
+ print "<td><form action='/packages.php' method='post'>\n";
+ print "<input type='hidden' name='IDs[".$row["ID"]."]' value='1'>\n";
+ print "<input type='hidden' name='ID' value='".$row["ID"]."'>\n";
+ $q = "SELECT * FROM PackageVotes WHERE UsersID = ".uid_from_sid($SID);
+ $q.= " AND PackageID = ".$row["ID"];
+ if (!mysql_num_rows(db_query($q, $dbh))) {
+ print "<input type='submit' class='button' name='do_Vote'";
+ print " value='".__("Vote")."'>";
+ } else {
+ print "<input type='submit' class='button' name='do_UnVote'";
+ print " value='".__("Un-Vote")."'>";
+ }
+ print "</form></td>\n";
+ }
print "</tr>\n";
print "</table>\n";