function _webform_submission_total_limit_check in Webform 7.3
Same name and namespace in other branches
- 6.3 includes/webform.submissions.inc \_webform_submission_total_limit_check()
Check if the total number of submissions has exceeded the limit on this form.
Parameters
$node: The webform node to be checked.
Return value
Boolean TRUE if the form has exceeded it's limit. FALSE otherwise.
2 calls to _webform_submission_total_limit_check()
- webform_client_form_validate in ./
webform.module - webform_node_view in ./
webform.module - Implements hook_node_view().
File
- includes/
webform.submissions.inc, line 876 - This file is loaded when handling submissions, either submitting new, editing, or viewing. It also contains all CRUD functions for submissions.
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;
}