function node_expire_form_alter in Node expire 5
Same name and namespace in other branches
- 8 node_expire.module \node_expire_form_alter()
- 6.2 node_expire.module \node_expire_form_alter()
- 6 node_expire.module \node_expire_form_alter()
- 7.2 node_expire.module \node_expire_form_alter()
- 7 node_expire.module \node_expire_form_alter()
Add expiration options to the node entry forms
File
- ./
node_expire.module, line 633 - Alerts administrators of possibly outdated materials and optionally unpublishes them.
Code
function node_expire_form_alter($form_id, &$form) {
$node = $form['#node'];
if (isset($form['type']) && $form['type']['#value'] . '_node_form' == $form_id && !isset($node->expire_disabled)) {
$form['expiration'] = array(
'#title' => t('Expiration'),
'#type' => 'fieldset',
'#tree' => FALSE,
'#collapsible' => TRUE,
'#collapsed' => $node->expiration_type == 'none',
);
$form['expiration']['expiration_type'] = array(
'#title' => t('Expiration Type'),
'#description' => t('What type of node expiration should this node have?'),
'#type' => 'select',
'#options' => array(
'none' => t('Doesn\'t Expire'),
'date' => t('Expire on Date'),
'onupdate' => t('Expire After Last Update'),
),
'#default_value' => $node->expiration_type,
);
$period = array(
'+1 day' => t('1 Day'),
'+2 days' => t('2 Days'),
'+3 days' => t('3 Days'),
'+4 days' => t('4 Days'),
'+5 days' => t('5 Days'),
'+6 days' => t('6 Days'),
'+1 week' => t('1 Week'),
'+2 weeks' => t('2 Weeks'),
'+3 weeks' => t('3 Weeks'),
'+1 month' => t('1 Month'),
'+2 months' => t('2 Months'),
'+3 months' => t('3 Months'),
'+4 months' => t('4 Months'),
'+5 months' => t('5 Months'),
'+6 months' => t('6 Months'),
'+7 months' => t('7 Months'),
'+8 months' => t('8 Months'),
'+9 months' => t('9 Months'),
'+10 months' => t('10 Months'),
'+11 months' => t('11 Months'),
'+1 Year' => t('1 Year'),
);
$form['expiration']['expire_timefrom'] = array(
'#title' => t('Expiration Time'),
'#description' => t('Time after last update to consider the node expired.'),
'#type' => 'select',
'#options' => $period,
'#default_value' => $node->expire_timefrom,
);
$form['expiration']['expire'] = array(
'#title' => t('Expiration Date'),
'#description' => t('Time date to consider the node expired. Format: %time.', array(
'%time' => $node->expire,
)),
'#type' => 'textfield',
'#maxlength' => 25,
'#default_value' => $node->expire,
'#attributes' => array(
'class' => 'jscalendar',
),
);
// As book pages is the only node type that allows inheritance, only show it there.
if ($form['type']['#value'] == 'book' && variable_get('node-expire-book-props', 1) == 1) {
$form['expiration']['isroot'] = array(
'#title' => t('Block Inheritance'),
'#description' => t('Whether or not to block inheritance of the above settings from parent nodes.'),
'#type' => 'checkbox',
'#default_value' => $node->isroot,
);
}
}
}