function webform_submission_total_limit_check in Webform 7.4
Check if the total number of submissions has exceeded the limit on this form.
Parameters
$node: The webform node to be checked.
Return value
bool Boolean TRUE if the form has exceeded it's limit. FALSE otherwise.
2 calls to webform_submission_total_limit_check()
- webform_client_form_prevalidate in ./
webform.module - Validates that the form can still be submitted, saved as draft, or edited.
- webform_node_view in ./
webform.module - Implements hook_node_view().
File
- includes/
webform.submissions.inc, line 1111 - Submission handling functions.
Code
function webform_submission_total_limit_check($node) {
// Check if submission limiting is enabled.
if ($node->webform['total_submit_limit'] == '-1') {
// No check enabled.
return FALSE;
}
// Retrieve submission data from the database.
$query = db_select('webform_submissions')
->addTag('webform_submission_total_limit_check')
->condition('nid', $node->nid)
->condition('is_draft', 0);
if ($node->webform['total_submit_interval'] != -1) {
$query
->condition('submitted', REQUEST_TIME - $node->webform['total_submit_interval'], '>');
}
// Fetch all the entries from the database within the submit interval.
$num_submissions_database = $query
->countQuery()
->execute()
->fetchField();
if ($num_submissions_database >= $node->webform['total_submit_limit']) {
// Limit exceeded.
return TRUE;
}
// Limit not exceeded.
return FALSE;
}