diff options
author | canyonknight <canyonknight@gmail.com> | 2012-05-25 23:42:42 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2012-07-06 11:27:04 +0200 |
commit | c15441762c2f6ab4438eaf2854c0ee3146a98b30 (patch) | |
tree | 54dac276a8e854ff4a76fed619af811740a1aaa2 /web/template | |
parent | 8a59cd620804909400ea526602bffa1e2f3d389c (diff) | |
download | aur-c15441762c2f6ab4438eaf2854c0ee3146a98b30.tar.gz aur-c15441762c2f6ab4438eaf2854c0ee3146a98b30.tar.xz |
Pull out DB code from trusted user page
* Move DB code in tu.php and tu.php and tu_list.php to new functions in
accfuncs.inc.php
* Centralization of DB code important in a future transition to PDO interface
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/template')
-rw-r--r-- | web/template/tu_list.php | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/web/template/tu_list.php b/web/template/tu_list.php index d8acd713..ce19da3c 100644 --- a/web/template/tu_list.php +++ b/web/template/tu_list.php @@ -14,9 +14,15 @@ </thead> <tbody> - <?php if (mysql_num_rows($result) == 0): ?> + <?php if (empty($result)): ?> <tr><td align="center" colspan="0"><?php print __("No results found.") ?></td></tr> - <?php else: for ($i = 0; $row = mysql_fetch_assoc($result); $i++): (($i % 2) == 0) ? $c = 'odd' : $c = 'even'; ?> + <?php else: while (list($indx, $row) = each($result)): + if ($indx % 2): + $c = "even"; + else: + $c = "odd"; + endif; + ?> <tr class="<?php print $c ?>"> <td><?php $row["Agenda"] = htmlspecialchars(substr($row["Agenda"], 0, $prev_Len)); ?> <a href="tu.php?id=<?php print $row['ID'] ?>"><?php print $row["Agenda"] ?></a></span></span> @@ -34,23 +40,15 @@ <td><?php print $row['Yes'] ?></td> <td><?php print $row['No'] ?></td> <td> - <?php - $q = "SELECT * FROM TU_Votes WHERE VoteID = " . $row['ID'] . " AND UserID = " . uid_from_sid($_COOKIE["AURSID"]); - $result_tulist = db_query($q, $dbh); - if ($result_tulist): - $hasvoted = mysql_num_rows($result_tulist); - else: - $hasvoted = 0; - endif; - if ($hasvoted == 0): ?> - <span style="color: red; font-weight: bold"><?php print __("No") ?></span> - <?php else: ?> + <?php if (tu_voted($row['ID'], uid_from_sid($_COOKIE["AURSID"]))): ?> <span style="color: green; font-weight: bold"><?php print __("Yes") ?></span> + <?php else: ?> + <span style="color: red; font-weight: bold"><?php print __("No") ?></span> <?php endif; ?> </td> </tr> <?php - endfor; + endwhile; endif; ?> </tbody> |