Commit b20de4c1 authored by Dries's avatar Dries

- Patch #360785 by Dave Reid: add timestamp to {poll_votes}.

parent daf4acf2
......@@ -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;
}
......@@ -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.
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment