summaryrefslogtreecommitdiffstats
path: root/web/template/actions_form.php
diff options
context:
space:
mode:
authorcanyonknight <canyonknight@gmail.com>2012-05-23 15:22:51 -0400
committerLukas Fleischer <archlinux@cryptocrack.de>2012-07-06 11:26:53 +0200
commitc2b65f2b7bffeed46a2981f4eeb04e063c379ac0 (patch)
treeaf11ae83d59eacbad45fc78b8b37b89a98a4daa3 /web/template/actions_form.php
parent1eea2951fbebb5bb4dfc0c09ad7622f03e4a6471 (diff)
downloadaurweb-c2b65f2b7bffeed46a2981f4eeb04e063c379ac0.tar.xz
action_form.php: Pull out DB code
* Create new functions in pkgfuncs.inc.php with SQL queries from action_form.php * Centralization of DB code important in a future transition to PDO interface * Flip logic of vote and notify XHTML button to use function return rather than a more confusing NOT (!) logical operator statement Signed-off-by: canyonknight <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/template/actions_form.php')
-rw-r--r--web/template/actions_form.php32
1 files changed, 8 insertions, 24 deletions
diff --git a/web/template/actions_form.php b/web/template/actions_form.php
index 59a6e7a..e5ab7c2 100644
--- a/web/template/actions_form.php
+++ b/web/template/actions_form.php
@@ -3,33 +3,17 @@
<fieldset>
<input type="hidden" name="IDs[<?php echo $row['ID'] ?>]" value="1" />
<input type="hidden" name="ID" value="<?php echo $row['ID'] ?>" />
- <?php
- # Voting Button
- #
- $q = "SELECT * FROM PackageVotes WHERE UsersID = ". $uid;
- $q.= " AND PackageID = ".$row["ID"];
- $result = db_query($q, $dbh);
- if ($result):
- if (!mysql_num_rows($result)):
- ?>
- <input type="submit" class="button" name="do_Vote" value="<?php echo __("Vote") ?>" />
- <?php else: ?>
+
+ <?php if (user_voted($uid, $row['ID'])): ?>
<input type="submit" class="button" name="do_UnVote" value="<?php echo __("UnVote") ?>" />
- <?php endif; ?>
+ <?php else: ?>
+ <input type="submit" class="button" name="do_Vote" value="<?php echo __("Vote") ?>" />
<?php endif; ?>
- <?php
- # Comment Notify Button
- #
- $q = "SELECT * FROM CommentNotify WHERE UserID = ". $uid;
- $q.= " AND PkgID = ".$row["ID"];
- $result = db_query($q, $dbh);
- if ($result):
- if (!mysql_num_rows($result)):
- ?>
- <input type="submit" class="button" name="do_Notify" value="<?php echo __("Notify") ?>" title="<?php echo __("New Comment Notification") ?>" />
- <?php else: ?>
+
+ <?php if (user_notify($uid, $row['ID'])): ?>
<input type="submit" class="button" name="do_UnNotify" value="<?php echo __("UnNotify") ?>" title="<?php echo __("No New Comment Notification") ?>" />
- <?php endif; ?>
+ <?php else: ?>
+ <input type="submit" class="button" name="do_Notify" value="<?php echo __("Notify") ?>" title="<?php echo __("New Comment Notification") ?>" />
<?php endif; ?>
<?php if ($row["OutOfDateTS"] === NULL): ?>