commit | author | age
|
fcc698
|
1 |
<?php |
W |
2 |
/* |
|
3 |
Copyright (c) 2009, Scott Barr <gsbarr@gmail.com> |
|
4 |
All rights reserved. |
|
5 |
|
|
6 |
Redistribution and use in source and binary forms, with or without modification, |
|
7 |
are permitted provided that the following conditions are met: |
|
8 |
|
|
9 |
* Redistributions of source code must retain the above copyright notice, |
|
10 |
this list of conditions and the following disclaimer. |
|
11 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
12 |
this list of conditions and the following disclaimer in the documentation |
|
13 |
and/or other materials provided with the distribution. |
|
14 |
* Neither the name of ISPConfig nor the names of its contributors |
|
15 |
may be used to endorse or promote products derived from this software without |
|
16 |
specific prior written permission. |
|
17 |
|
|
18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
20 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
21 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
22 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
23 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
24 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
26 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
27 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
b1a6a5
|
30 |
include_once 'validate_datetime.inc.php'; |
fcc698
|
31 |
|
b1a6a5
|
32 |
class validate_autoresponder extends validate_datetime |
fcc698
|
33 |
{ |
W |
34 |
function start_date($field_name, $field_value, $validator) |
|
35 |
{ |
96ae77
|
36 |
global $app; |
TB |
37 |
|
b1a6a5
|
38 |
// save field value for later use in end_date() |
bfcdef
|
39 |
$this->start_date = $field_value; |
b1a6a5
|
40 |
|
96ae77
|
41 |
if($_POST['autoresponder'] == 'y' && $field_value == '') { |
TB |
42 |
// we need a start date when autoresponder is on |
|
43 |
return $app->tform->lng($validator['errmsg']).'<br />'; |
fcc698
|
44 |
} |
W |
45 |
} |
b1a6a5
|
46 |
|
fcc698
|
47 |
function end_date($field_name, $field_value, $validator) |
W |
48 |
{ |
|
49 |
global $app; |
b1a6a5
|
50 |
|
bfcdef
|
51 |
$start_date = $this->start_date; |
T |
52 |
//$start_date = $app->tform_actions->dataRecord['autoresponder_start_date']; |
96ae77
|
53 |
|
TB |
54 |
// Parse date |
|
55 |
$start_date_array = date_parse_from_format($app->lng('conf_format_datetime'),$start_date); |
|
56 |
$end_date_array = date_parse_from_format($app->lng('conf_format_datetime'),$field_value); |
|
57 |
|
|
58 |
//calculate timestamps |
|
59 |
$start_date_tstamp = mktime($start_date_array['hour'], $start_date_array['minute'], $start_date_array['second'], $start_date_array['month'], $start_date_array['day'], $start_date_array['year']); |
|
60 |
$end_date_tstamp = mktime($end_date_array['hour'], $end_date_array['minute'], $end_date_array['second'], $end_date_array['month'], $end_date_array['day'], $end_date_array['year']); |
|
61 |
|
|
62 |
// End date has to be > start date |
1d46a3
|
63 |
if($end_date_tstamp <= $start_date_tstamp && ($start_date || $field_value)) { |
96ae77
|
64 |
return $app->tform->lng($validator['errmsg']).'<br />'; |
fcc698
|
65 |
} |
W |
66 |
} |
b1a6a5
|
67 |
|
MC |
68 |
} |