function node_expire_default_settings_form in Node expire 5
Same name and namespace in other branches
- 6 node_expire.admin.inc \node_expire_default_settings_form()
Configuration form for default expirations for node_expire
1 string reference to 'node_expire_default_settings_form'
- node_expire_menu in ./
node_expire.module - Implementation of hook_menu().
File
- ./
node_expire.module, line 389 - Alerts administrators of possibly outdated materials and optionally unpublishes them.
Code
function node_expire_default_settings_form() {
// Get current settings
$curdefaults = variable_get('node-expire-node-visibility', array());
$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'),
);
// Make the options available for each node type.
$types = node_get_types();
foreach ($types as $node) {
// If we don't already have defaults for this node set, use our own.
if (!$curdefaults[$node->type]) {
$curdefaults[$node->type] = array(
'enabled' => false,
'expiration_type' => 'none',
'expire_timefrom' => '+3 months',
'expire' => '+3 months',
'isroot' => false,
);
}
$form[$node->type] = array(
'#type' => 'fieldset',
'#title' => $node->name,
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => $curdefaults[$node->type]['enabled'] == false,
'#description' => $node->module == 'book' ? t('These defaults will only be used when no inheritance is available.') : '',
);
$form[$node->type]['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable expiration for this node type.'),
'#default_value' => $curdefaults[$node->type]['enabled'],
);
$form[$node->type]['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' => $curdefaults[$node->type]['expiration_type'],
);
$form[$node->type]['expire_timefrom'] = array(
'#title' => t('Expiration Time'),
'#description' => t('Time after last update to consider the node expired.'),
'#type' => 'select',
'#options' => $period,
'#default_value' => $curdefaults[$node->type]['expire_timefrom'],
);
$form[$node->type]['expire'] = array(
'#title' => t('Expiration Date'),
'#description' => t('Time/date to consider the node expired. Format: %time or PHP <a href="http://www.php.net/strtotime" ' . 'target="_blank">strtotime format</a>. Note that if the default date entered is in the past at the node post time, and ' . 'the end-user doesn\'t have access to edit it, the expiration settings for that node will be removed.', array(
'%time' => format_date(time(), 'large'),
)),
'#type' => 'textfield',
'#default_value' => $curdefaults[$node->type]['expire'],
'#attributes' => array(
'class' => 'jscalendar',
),
);
// As book page is the only node type that allows inheritance, only show it there.
if ($node->module == 'book' && variable_get('node-expire-book-props', 1) == 1) {
$form[$node->type]['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' => $curdefaults[$node->type]['isroot'],
);
}
}
return system_settings_form($form);
}