From 89e6e0dfe62c390677f6ea51437164498d3fffe2 Mon Sep 17 00:00:00 2001 From: Andrew Boag Date: Thu, 29 Apr 2010 17:16:02 +1000 Subject: [PATCH] These changes are so that the default sorting of the results was descending submission time, we also added an ORDER BY clause to the webforms function so that we ALWAYS get the same results from the database, otherwise a page refresh can cause strange data changes, very strange. This might be only a pg symptom but by nature DB does not guarantee row order unless an order by is specified --- sites/all/modules/webform/webform_report.inc | 8 ++++---- sites/all/modules/webform/webform_submissions.inc | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sites/all/modules/webform/webform_report.inc b/sites/all/modules/webform/webform_report.inc index e8a1132..4f537da 100644 --- a/sites/all/modules/webform/webform_report.inc +++ b/sites/all/modules/webform/webform_report.inc @@ -89,8 +89,8 @@ function theme_webform_results_per_page($total_count, $pager_count) { */ function theme_webform_results_submissions_header($node) { $columns = array( - array('data' => t('#'), 'field' => 'sid', 'sort' => 'asc'), - array('data' => t('Submitted'), 'field' => 'submitted'), + array('data' => t('#'), 'field' => 'sid'), + array('data' => t('Submitted'), 'field' => 'submitted', 'sort' => 'desc'), ); if (user_access('access webform results')) { $columns[] = array('data' => t('User'), 'field' => 'name'); @@ -184,8 +184,8 @@ function webform_results_table($node, $pager_count = 0) { function theme_webform_results_table_header($node) { return array( - array('data' => t('#'), 'field' => 'sid', 'sort' => 'asc'), - array('data' => t('Submitted'), 'field' => 'submitted'), + array('data' => t('#'), 'field' => 'sid'), + array('data' => t('Submitted'), 'field' => 'submitted', 'sort' => 'desc'), array('data' => t('User'), 'field' => 'name'), array('data' => t('IP Address'), 'field' => 'remote_addr'), ); diff --git a/sites/all/modules/webform/webform_submissions.inc b/sites/all/modules/webform/webform_submissions.inc index 5dfb799..27c3872 100644 --- a/sites/all/modules/webform/webform_submissions.inc +++ b/sites/all/modules/webform/webform_submissions.inc @@ -132,6 +132,8 @@ function webform_get_submissions($nid, $header = NULL, $uid = NULL, $pager_count if ($uid) { $pager_query .= ' AND uid = %d'; } + $pager_query .= " ORDER BY sid DESC "; + $res = pager_query($pager_query, $pager_count, 0, NULL, $nid, $uid); $sids = array(); while ($row = db_fetch_object($res)) { -- 1.6.5