function webform_get_submission_count in Webform 7.3
Same name and namespace in other branches
- 5.2 webform_submissions.inc \webform_get_submission_count()
- 6.3 includes/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()
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 - Render the field.
- 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 734 - 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 = db_select('webform_submissions', 'ws')
->addTag('webform_get_submission_count')
->condition('ws.nid', $nid)
->condition('ws.is_draft', 0);
$arguments = array(
$nid,
);
if ($uid !== NULL) {
$query
->condition('ws.uid', $uid);
}
if ($uid === 0) {
$submissions = isset($_SESSION['webform_submission']) ? $_SESSION['webform_submission'] : NULL;
if ($submissions) {
$query
->condition('ws.sid', $submissions, 'IN');
}
else {
// Intentionally never match anything if the anonymous user has no
// submissions.
$query
->condition('ws.sid', 0);
}
}
$counts[$nid][$uid] = $query
->countQuery()
->execute()
->fetchField();
}
return $counts[$nid][$uid];
}