| 1 |
<?php |
<?php |
| 2 |
// $Id: node_expire.nodeapi.inc,v 1.2 2009/01/29 21:01:33 brmassa Exp $ |
// $Id: node_expire.nodeapi.inc,v 1.3 2009/01/31 00:22:15 brmassa Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 30 |
|
|
| 31 |
case 'validate': |
case 'validate': |
| 32 |
// The only restriction we have is that the node can't expire in the past. |
// The only restriction we have is that the node can't expire in the past. |
| 33 |
if ($node->expire <= 0) { |
if ($node->expire == '') { |
| 34 |
|
if (!empty($ntypes['required'])) { |
| 35 |
|
form_set_error('expire_date', t('You must choose an expiration date.')); |
| 36 |
|
} |
| 37 |
|
} |
| 38 |
|
elseif (!$expire = strtotime($node->expire) or $expire <= 0) { |
| 39 |
form_set_error('expire_date', t('You have to specify a valid date.')); |
form_set_error('expire_date', t('You have to specify a valid date.')); |
| 40 |
} |
} |
| 41 |
elseif (strtotime($node->expire) <= time()) { |
elseif ($expire <= time()) { |
| 42 |
form_set_error('expire_date', t("You can't expire a node in the past!")); |
form_set_error('expire_date', t("You can't expire a node in the past!")); |
| 43 |
} |
} |
| 44 |
elseif (!empty($ntypes['max']) and strtotime($node->expire) > strtotime($ntypes['max'], $node->created)) { |
elseif (!empty($ntypes['max']) and $expire > strtotime($ntypes['max'], $node->created)) { |
| 45 |
form_set_error('expire_date', t('It must expire before %date.', |
form_set_error('expire_date', t('It must expire before %date.', |
| 46 |
array('%date' => format_date(strtotime($ntypes['max']), 'custom', NODE_EXPIRE_FORMAT)))); |
array('%date' => format_date(strtotime($ntypes['max'], $node->created), 'custom', NODE_EXPIRE_FORMAT)))); |
| 47 |
} |
} |
| 48 |
break; |
break; |
| 49 |
|
|
| 80 |
array('%time' => format_date(time(), 'custom', NODE_EXPIRE_FORMAT))), |
array('%time' => format_date(time(), 'custom', NODE_EXPIRE_FORMAT))), |
| 81 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 82 |
'#maxlength' => 25, |
'#maxlength' => 25, |
| 83 |
|
'#required' => $ntypes['required'], |
| 84 |
'#default_value' => $node->expire, |
'#default_value' => $node->expire, |
| 85 |
); |
); |
| 86 |
|
|