summaryrefslogtreecommitdiff
path: root/modules/poll
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-08-25 09:25:49 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-08-25 09:25:49 +0000
commit801756e7e69cfc8a22d8c1c612a31391872c35bc (patch)
tree3d70f6ee8d720628bf87039193a4fac07a1e6613 /modules/poll
parent92914245608123f9e011d1e9d4cf8c057bc9e8a8 (diff)
downloadbrdo-801756e7e69cfc8a22d8c1c612a31391872c35bc.tar.gz
brdo-801756e7e69cfc8a22d8c1c612a31391872c35bc.tar.bz2
#111127 by chx: cache node_load(), so heavy operations loading data from external sources and only invoked once (note that you should do everything dynamic in the view op, not the load op)
Diffstat (limited to 'modules/poll')
-rw-r--r--modules/poll/poll.module37
1 files changed, 19 insertions, 18 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index b7bafdcc8..14936a2af 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -299,24 +299,6 @@ function poll_load($node) {
while ($choice = db_fetch_array($result)) {
$poll->choice[$choice['chorder']] = $choice;
}
-
- // Determine whether or not this user is allowed to vote
- $poll->allowvotes = FALSE;
- if (user_access('vote on polls') && $poll->active) {
- if ($user->uid) {
- $result = db_fetch_object(db_query('SELECT chorder FROM {poll_votes} WHERE nid = %d AND uid = %d', $node->nid, $user->uid));
- }
- else {
- $result = db_fetch_object(db_query("SELECT chorder FROM {poll_votes} WHERE nid = %d AND hostname = '%s'", $node->nid, ip_address()));
- }
- if (isset($result->chorder)) {
- $poll->vote = $result->chorder;
- }
- else {
- $poll->vote = -1;
- $poll->allowvotes = TRUE;
- }
- }
return $poll;
}
@@ -382,6 +364,25 @@ function poll_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE) {
global $user;
$output = '';
+ // Determine whether or not this user is allowed to vote
+ $poll->allowvotes = FALSE;
+ if (user_access('vote on polls') && $poll->active) {
+ if ($user->uid) {
+ $result = db_fetch_object(db_query('SELECT chorder FROM {poll_votes} WHERE nid = %d AND uid = %d', $node->nid, $user->uid));
+ }
+ else {
+ $result = db_fetch_object(db_query("SELECT chorder FROM {poll_votes} WHERE nid = %d AND hostname = '%s'", $node->nid, ip_address()));
+ }
+ if (isset($result->chorder)) {
+ $poll->vote = $result->chorder;
+ }
+ else {
+ $poll->vote = -1;
+ $poll->allowvotes = TRUE;
+ }
+ }
+
+
// Special display for side-block
if ($block) {
// No 'read more' link