The current count of submissions is fetched from wrong table.
To obtain the correct count of submissions you have to change the table where get the count.

Change the line 103 from:

        // Count the current total of submissions in the database
        $count = db_result(db_query('SELECT count(*) FROM {webform_submitted_data} WHERE nid = %d', $node->nid));

to:

        // Count the current total of submissions in the database
        $count = db_result(db_query('SELECT count(*) FROM {webform_submissions} WHERE nid = %d', $node->nid));

Comments

donnycarette’s picture

Assigned: Unassigned » donnycarette

Thanks, i will release a new version soon

donnycarette’s picture

Status: Active » Closed (fixed)

And new release 6.x-1.3 with fix is online

emastyle’s picture

The module close the form when max allowed number of submissions is reached on the next form load, but if two user submit the form at the same time the code not check if form is already close.
So, if you want to stop users submission when effectively max allowed number of submissions is reached, add this function before function webform_limit_submissions_nodeapi:

/**
 * Handle webform's submission on presave op
 */
function webform_limit_submissions_webform_submission_presave($node, &$submission) {
 // Get the value for the limit of submissions
      $max_submissions = _webform_limit_submissions_get_value($node->nid);
      
      // Check if max submissions has been set or isn't equal to zero
      if ($max_submissions > 0) {
        // Count the current total of submissions in the database
        $count = db_result(db_query('SELECT count(*) FROM {webform_submissions} WHERE nid = %d', $node->nid));
        // Check if the current total of submissions is equal or higher than the value we provided
        if ($count >= $max_submissions) {
        	header('Location: /node/' . $node->nid);
        	exit;
        }	
      }
}

This function check if max allowed number of submissions is reached on presave operation (as nodeapi definition http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...). If the limit is reached the node is reloaded without insert the data in the database and the "close message" appears.

donnycarette’s picture

Reopening the issue, new release will soon be added
Thanks emastyle for pointing out

donnycarette’s picture

Status: Closed (fixed) » Needs work
donnycarette’s picture

Status: Needs work » Closed (fixed)

Fixed in the 6.x-1.5 release
Emastyle, thanks for pointing out!