Posted by KyleBalderson on October 28, 2008 at 5:47pm
3 followers
Jump to:
| Project: | Webform |
| Version: | 5.x-2.2 |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
I needed to get the webform to let a user submit the form each day, no matter what time of day they were submitting it.
The way it works now, the user has to wait 24 hours from their last submission.
I remedied this by declaring a variable like this:
<?php
$offset = (date("H") * 60 * 60);
$offset += (date("i") * 60);
?>then replacing:
<?php
$result = db_query($query, $user->uid, $_SERVER['REMOTE_ADDR'], $user->uid, ($node->webform['submit_interval'] != -1) ? time() - $node->webform['submit_interval'] : $node->webform['submit_interval'], $node->nid);
?>with:
<?php
$result = db_query($query, $user->uid, $_SERVER['REMOTE_ADDR'], $user->uid, ($node->webform['submit_interval'] != -1) ? time() - $node->webform['submit_interval'] + $offset : $node->webform['submit_interval'] + $offset, $node->nid);
?>and :
<?php
if ($timestamp <= time() - $node->webform['submit_interval']) {
?>with:
<?php
if ($timestamp <= time() - $node->webform['submit_interval'] + $offset) {
?>Not sure if this is the best way, but it seems to work.
Comments
#1
Thanks for the changes! I'd really like to add this as the default functionality of Webform, but working from the descriptions provided is a bit troublesome. Could you create a patch (http://drupal.org/patch/create) and I'll review it for inclusion in Webform?
#2
i need this also, but for d6.
I will have a look for it
#3
looks like everything changed since then.
This code is not applicable
#4
Let's follow the patch posted in #597438: Limit submission by Calendar Week and Month.