function _auto_expire_expiry in Auto Expire 7
Same name and namespace in other branches
- 5 auto_expire.module \_auto_expire_expiry()
Implements expiry form.
_state
Parameters
$form:
$nid:
Return value
mixed
1 string reference to '_auto_expire_expiry'
- auto_expire_menu in ./
auto_expire.module - Implements hook_menu().
File
- ./
auto_expire.module, line 119
Code
function _auto_expire_expiry($form, &$form_state, $nid) {
$node = node_load($nid);
drupal_set_title($node->title);
$expire = _auto_expire_get_expire($node->nid);
$code = AUTO_EXPIRE_NODE_TYPE . $node->type;
$warn = variable_get($code . '_w', AUTO_EXPIRE_WARN);
$form['nid'] = array(
'#type' => 'value',
'#value' => $nid,
);
$form['expire'] = array(
'#type' => 'value',
'#value' => $expire,
);
// Check if there is a expire date. There may not be one if the node was
// created before the module was installed.
if ($expire) {
if (REQUEST_TIME < $expire) {
$form['expireson'] = array(
'#markup' => '<p>' . t('@title will expire on !date<br />that is in !daysleft.', array(
'@title' => $node->title,
'!date' => format_date($expire),
'!daysleft' => format_interval($expire - REQUEST_TIME),
)) . '</p>',
);
}
else {
$form['expireson'] = array(
'#markup' => '<p>' . t('@title has expired on !date.', array(
'@title' => $node->title,
'!date' => format_date($expire),
)) . '</p>',
);
}
if (REQUEST_TIME > $expire - $warn * 24 * 60 * 60) {
$days = variable_get($code . '_d', AUTO_EXPIRE_DAYS);
$form['extendby'] = array(
'#markup' => '<p>' . format_plural($days, 'You can extend it with 1 day.', 'You can extend it with @count days.') . '</p>',
);
$form['extend'] = array(
'#type' => 'submit',
'#value' => t('Extend'),
'#submit' => array(
'_auto_expire_expiry_submit',
),
);
}
else {
$form['extendwhen'] = array(
'#markup' => '<p>' . format_plural($warn, 'You will be able to extend this 24 hours before the expiry time.', 'You will be able to extend this @count days before the expiry time.') . ' ' . t('You will receive an email notification at that time.') . '</p>',
);
}
}
else {
$form['no_expire'] = array(
'#markup' => '<p>' . t('"@title" does not have an expiration date.', array(
'@title' => $node->title,
)),
);
drupal_set_message(t('Auto Expire. "@title" does not have an expiration date. This may have been caused because the "@title" was created before you installed Auto Expire.', array(
'@title' => $node->title,
)), 'warning');
}
return $form;
}