diff options
author | Callan Barrett <wizzomafizzo@gmail.com> | 2008-01-07 01:44:21 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-01-20 07:21:19 +0100 |
commit | 8c94552042115d2a7bb04de3b4f66cdf95f2a5de (patch) | |
tree | 88734e06dd9a123a0c6a5e243e48d5345ad415b6 /web/lib | |
parent | bf5c28cf2260df822efa72095af69cc119170a3e (diff) | |
download | aur-8c94552042115d2a7bb04de3b4f66cdf95f2a5de.tar.gz aur-8c94552042115d2a7bb04de3b4f66cdf95f2a5de.tar.xz |
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 <wizzomafizzo@gmail.com>
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/aurjson.class.php | 2 | ||||
-rw-r--r-- | web/lib/pkgfuncs.inc | 41 |
2 files changed, 37 insertions, 6 deletions
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php index e6e40ffb..2df8dd31 100644 --- a/web/lib/aurjson.class.php +++ b/web/lib/aurjson.class.php @@ -108,7 +108,7 @@ class AurJSON { private function info($pqdata) { $base_query = "SELECT ID,Name,Version,Description,URL,URLPath,License,NumVotes,OutOfDate FROM Packages WHERE "; - if is_numeric($pqdata) { + if ( is_numeric($pqdata) ) { // just using sprintf to coerce the pqd to an int // should handle sql injection issues, since sprintf will // bork if not an int, or convert the string to a number 0 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 "<input type='submit' class='button' name='do_Notify'"; echo " value='".__("Notify")."' title='".__("New Comment Notification")."'>"; } else { - echo "<input type='submit' class='button' name='do_UnNotify'"; + echo "<input type='submit' class='button' name='do_Notify'"; echo " value='".__("UnNotify")."' title='".__("No New Comment Notification")."'>"; } @@ -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 "<input type='submit' class='button' name='do_Delete'"; print " value='".__("Delete Packages")."'></td>\n"; print " <td align='center'>"; - print "<input type='submit' class='button' name='do_Vote'"; - print " value='".__("Vote")."'></td>\n"; + print "<input type='submit' class='button' name='do_Notify'"; + print " value='".__("Toggle Notify")."'></td>\n"; print " <td align='center'>"; - print "<input type='submit' class='button' name='do_UnVote'"; - print " value='".__("Un-Vote")."'></td>\n"; print "</tr>\n"; print "</table>\n"; print " </td>\n"; @@ -1023,6 +1042,10 @@ function pkg_search_page($SID="") { print " <th style='border-bottom: #666 1px solid; vertical-align:"; print " bottom'><span class='f2'>".__("Voted")."</span></th>\n"; } + if ($SID) { + print " <th style='border-bottom: #666 1px solid; vertical-align:"; + print " bottom'><span class='f2'>".__("Notify")."</span></th>\n"; + } print " <th style='border-bottom: #666 1px solid; vertical-align:"; print " bottom'><span class='f2'>".__("Description")."</a>"; print "</span></th>\n"; @@ -1091,6 +1114,14 @@ function pkg_search_page($SID="") { print " </span></td>\n"; } } + if ($SID) { + print " <td class='".$c."'><span class='f5'><span class='blue'>"; + if (isset($my_notify[$row["ID"]])) { + print " ".__("Yes")."</span></td>\n"; + } else { + print " </span></td>\n"; + } + } print " <td class='".$c."'><span class='f4'><span class='blue'>"; print $row["Description"]."</span></span></td>\n"; print " <td class='".$c."'><span class='f5'><span class='blue'>"; |