function webform_get_submission_count in Webform 6.3
Same name and namespace in other branches
- 5.2 webform_submissions.inc \webform_get_submission_count()
- 6.2 webform_submissions.inc \webform_get_submission_count()
- 7.4 includes/webform.submissions.inc \webform_get_submission_count()
- 7.3 includes/webform.submissions.inc \webform_get_submission_count()
Return a count of the total number of submissions for a node.
Parameters
$nid: The node ID for which submissions are being fetched.
$uid: Optional; the user ID to filter the submissions by.
Return value
An integer value of the number of submissions.
5 calls to webform_get_submission_count()
- webform_handler_field_submission_count::render in views/
webform_handler_field_submission_count.inc - webform_node_view in ./
webform.module - Implements hook_node_view().
- webform_results_download_range_after_build in includes/
webform.report.inc - FormAPI after build function for the download range fieldset.
- webform_results_submissions in includes/
webform.report.inc - Retrieve lists of submissions for a given webform.
- webform_results_table in includes/
webform.report.inc - Create a table containing all submitted values for a webform node.
File
- includes/
webform.submissions.inc, line 710 - This file is loaded when handling submissions, either submitting new, editing, or viewing. It also contains all CRUD functions for submissions.
Code
function webform_get_submission_count($nid, $uid = NULL, $reset = FALSE) {
static $counts;
if (!isset($counts[$nid][$uid]) || $reset) {
$query = 'SELECT count(*) FROM {webform_submissions} WHERE nid = %d AND is_draft = 0';
$arguments = array(
$nid,
);
if ($uid !== NULL) {
$query .= ' AND uid = %d';
$arguments[] = $uid;
}
if ($uid === 0) {
$submissions = isset($_SESSION['webform_submission']) ? $_SESSION['webform_submission'] : array();
$query .= count($submissions) ? ' AND sid IN (' . db_placeholders($submissions) . ')' : ' AND sid = 0';
$arguments = array_merge($arguments, array_keys($submissions));
}
$counts[$nid][$uid] = db_result(db_query($query, $arguments));
}
return $counts[$nid][$uid];
}