function _webform_submission_total_limit_check in Webform 6.3
Same name and namespace in other branches
- 7.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 825 - 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') {
return FALSE;
// No check enabled.
}
// Retrieve submission data from the database.
$query = 'SELECT count(*) ' . 'FROM {webform_submissions} ' . 'WHERE submitted > %d AND nid = %d AND is_draft = 0';
// Fetch all the entries from the database within the submit interval.
$num_submissions_database = db_result(db_query($query, $node->webform['total_submit_interval'] != -1 ? time() - $node->webform['total_submit_interval'] : $node->webform['total_submit_interval'], $node->nid));
if ($num_submissions_database >= $node->webform['total_submit_limit']) {
// Limit exceeded.
return TRUE;
}
// Limit not exceeded.
return FALSE;
}