From 8c94552042115d2a7bb04de3b4f66cdf95f2a5de Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Mon, 7 Jan 2008 09:44:21 +0900 Subject: Add notify column in search results and notify button Adds a column to search results showing if a package has comment notification enabled and adds support for toggling notify for multiple packages from search Signed-off-by: Callan Barrett --- web/lib/pkgfuncs.inc | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'web/lib/pkgfuncs.inc') diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index eaeeca8b..f560ef91 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -265,6 +265,26 @@ function pkgvotes_from_sid($sid="") { return $pkgs; } +# array of package ids that you're being notified for +# *yoink* +# +function pkgnotify_from_sid($sid="") { + $pkgs = array(); + if (!$sid) {return $pkgs;} + $dbh = db_connect(); + $q = "SELECT PkgID "; + $q.= "FROM CommentNotify, Users, Sessions "; + $q.= "WHERE Users.ID = Sessions.UsersID "; + $q.= "AND Users.ID = CommentNotify.UserID "; + $q.= "AND Sessions.SessionID = '".mysql_real_escape_string($sid)."'"; + $result = db_query($q, $dbh); + if ($result) { + while ($row = mysql_fetch_row($result)) { + $pkgs[$row[0]] = 1; + } + } + return $pkgs; +} # display package details # @@ -475,7 +495,7 @@ function package_details($id=0, $SID="") { echo ""; } else { - echo ""; } @@ -636,6 +656,7 @@ function pkg_search_page($SID="") { $myuid = uid_from_sid($SID); $acct = account_from_sid($SID); $my_votes = pkgvotes_from_sid($SID); + $my_notify = pkgnotify_from_sid($SID); } # The search form @@ -964,11 +985,9 @@ function pkg_search_page($SID="") { print "\n"; print " "; - print "\n"; + print "\n"; print " "; - print "\n"; print "\n"; print "\n"; print " \n"; @@ -1023,6 +1042,10 @@ function pkg_search_page($SID="") { print " ".__("Voted")."\n"; } + if ($SID) { + print " ".__("Notify")."\n"; + } print " ".__("Description").""; print "\n"; @@ -1091,6 +1114,14 @@ function pkg_search_page($SID="") { print " \n"; } } + if ($SID) { + print " "; + if (isset($my_notify[$row["ID"]])) { + print "  ".__("Yes")."\n"; + } else { + print " \n"; + } + } print " "; print $row["Description"]."\n"; print " "; -- cgit v1.2.3-24-g4f1b