diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-01-21 14:42:16 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-01-21 14:42:16 +0000 |
commit | b20de4c1c97ee01fca20e7703b1bcf4f0e714667 (patch) | |
tree | 6c1560357e8c88b130cbab93e0ebaf1663333157 | |
parent | daf4acf2bec7324069b1e80071f4a596b8067757 (diff) | |
download | brdo-b20de4c1c97ee01fca20e7703b1bcf4f0e714667.tar.gz brdo-b20de4c1c97ee01fca20e7703b1bcf4f0e714667.tar.bz2 |
- Patch #360785 by Dave Reid: add timestamp to {poll_votes}.
-rw-r--r-- | modules/poll/poll.install | 20 | ||||
-rw-r--r-- | modules/poll/poll.module | 4 | ||||
-rw-r--r-- | modules/poll/poll.pages.inc | 10 |
3 files changed, 28 insertions, 6 deletions
diff --git a/modules/poll/poll.install b/modules/poll/poll.install index b560aad0b..04b7ad5a5 100644 --- a/modules/poll/poll.install +++ b/modules/poll/poll.install @@ -120,6 +120,12 @@ function poll_schema() { 'default' => '', 'description' => 'The IP address this vote is from unless the voter was logged in.', ), + 'timestamp' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The timestamp of the vote creation.', + ), ), 'primary key' => array('nid', 'uid', 'hostname'), 'indexes' => array( @@ -141,3 +147,17 @@ function poll_update_7001() { db_rename_table($ret, 'poll_votes', 'poll_vote'); return $ret; } + +/** + * Add timestamp field to {poll_votes}. + */ +function poll_update_7002() { + $ret = array(); + $field = array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ); + db_add_field($ret, 'poll_votes', 'timestamp', $field); + return $ret; +} diff --git a/modules/poll/poll.module b/modules/poll/poll.module index f280276b6..101528975 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -629,10 +629,10 @@ function poll_vote($form, &$form_state) { global $user; if ($user->uid) { - db_query('INSERT INTO {poll_vote} (nid, chid, uid) VALUES (%d, %d, %d)', $node->nid, $choice, $user->uid); + db_query('INSERT INTO {poll_vote} (nid, chid, uid, timestamp) VALUES (%d, %d, %d, %d)', $node->nid, $choice, $user->uid, REQUEST_TIME); } else { - db_query("INSERT INTO {poll_vote} (nid, chid, hostname) VALUES (%d, %d, '%s')", $node->nid, $choice, ip_address()); + db_query("INSERT INTO {poll_vote} (nid, chid, hostname, timestamp) VALUES (%d, %d, '%s', %d)", $node->nid, $choice, ip_address(), REQUEST_TIME); } // Add one to the votes. diff --git a/modules/poll/poll.pages.inc b/modules/poll/poll.pages.inc index 20a9179eb..4851b9987 100644 --- a/modules/poll/poll.pages.inc +++ b/modules/poll/poll.pages.inc @@ -32,15 +32,17 @@ function poll_votes($node) { $output = t('This table lists all the recorded votes for this poll. If anonymous users are allowed to vote, they will be identified by the IP address of the computer they used when they voted.'); $header[] = array('data' => t('Visitor'), 'field' => 'u.name'); - $header[] = array('data' => t('Vote'), 'field' => 'pv.chorder'); - $header[] = array('data' => t('Vote'), 'field' => 'pc.weight'); + $header[] = array('data' => t('Vote'), 'field' => 'pc.chtext'); + $header[] = array('data' => t('Timestamp'), 'field' => 'pv.timestamp', 'sort' => 'desc'); - $result = pager_query("SELECT pv.chid, pv.uid, pv.hostname, u.name FROM {poll_vote} pv INNER JOIN {poll_choice} pc ON pv.chid = pc.chid LEFT JOIN {users} u ON pv.uid = u.uid WHERE pv.nid = %d". tablesort_sql($header), 20, 0, NULL, $node->nid); + $result = pager_query("SELECT pv.chid, pv.uid, pv.hostname, pv.timestamp, pv.nid, pc.chtext, u.name FROM {poll_vote} pv INNER JOIN {poll_choice} pc ON pv.chid = pc.chid LEFT JOIN {users} u ON pv.uid = u.uid WHERE pv.nid = %d". tablesort_sql($header), 20, 0, NULL, $node->nid); $rows = array(); while ($vote = db_fetch_object($result)) { $rows[] = array( $vote->name ? theme('username', $vote) : check_plain($vote->hostname), - check_plain($node->choice[$vote->chid]['chtext'])); + check_plain($vote->chtext), + format_date($vote->timestamp), + ); } $output .= theme('table', $header, $rows); $output .= theme('pager', NULL, 20, 0); |