function _node_expire_node_validate in Node expire 7
Same name and namespace in other branches
- 8 node_expire.nodeapi.inc \_node_expire_node_validate()
Implements hook_node_validate().
1 call to _node_expire_node_validate()
- node_expire_node_validate in ./
node_expire.module - Implements hook_node_validate().
File
- ./
node_expire.nodeapi.inc, line 68 - Node API integration.
Code
function _node_expire_node_validate(&$ntype, $node) {
$handle_content_expiry = variable_get('node_expire_handle_content_expiry', 2);
if ($handle_content_expiry != 0) {
if (!isset($ntype['enabled']) || !$ntype['enabled']) {
return;
}
}
// The only restriction we have is that the node can't expire in the past.
if ($node->expire == '') {
if (!empty($ntype['required']) && $ntype['default']) {
form_set_error('expire_date', t('You must choose an expiration date.'));
}
}
elseif (!($expire = strtotime($node->expire)) or $expire <= 0) {
form_set_error('expire_date', t('You have to specify a valid expiration date.'));
}
elseif (variable_get('node_expire_past_date_allowed', 0) == 0 && $expire <= REQUEST_TIME) {
form_set_error('expire_date', t("You can't expire a node in the past!"));
}
elseif (!empty($ntype['max']) and $expire > strtotime($ntype['max'])) {
form_set_error('expire_date', t('It must expire before %date.', array(
'%date' => format_date(strtotime($ntype['max']), 'custom', NODE_EXPIRE_FORMAT),
)));
}
}