function webform_download_sids in Webform 7.3
Same name and namespace in other branches
- 6.3 includes/webform.report.inc \webform_download_sids()
- 7.4 includes/webform.report.inc \webform_download_sids()
Given a set of range options, retrieve a set of SIDs for a webform node.
2 calls to webform_download_sids()
- webform_results_download_form_submit in includes/
webform.report.inc - Validate handler for webform_results_download_form().
- webform_results_download_range_after_build in includes/
webform.report.inc - FormAPI after build function for the download range fieldset.
File
- includes/
webform.report.inc, line 949 - This file includes helper functions for creating reports for webform.module.
Code
function webform_download_sids($nid, $range_options, $uid = NULL) {
$query = db_select('webform_submissions', 'ws')
->fields('ws', array(
'sid',
))
->condition('nid', $nid);
switch ($range_options['range_type']) {
case 'all':
// All Submissions.
$query
->orderBy('sid', 'ASC');
break;
case 'new':
// All Since Last Download.
$download_info = webform_download_last_download_info($nid, $uid);
$last_sid = $download_info ? $download_info['sid'] : 0;
$query
->condition('sid', $last_sid, '>')
->orderBy('sid', 'ASC');
break;
case 'latest':
// Last x Submissions.
$query
->orderBy('sid', 'DESC')
->range(0, $range_options['latest']);
break;
case 'range':
// Submissions Start-End.
$query
->condition('sid', $range_options['start'], '>=');
if ($range_options['end']) {
$query
->condition('sid', $range_options['end'], '<=');
}
$query
->orderBy('sid', 'ASC');
break;
}
$sids = $query
->execute()
->fetchCol();
// The last x submissions option has SIDs that are in reverse order.
if ($range_options['range_type'] == 'latest') {
$sids = array_reverse($sids);
}
return $sids;
}