function node_expire_form_node_type_form_alter in Node expire 7
Same name and namespace in other branches
- 8 node_expire.module \node_expire_form_node_type_form_alter()
- 6.2 node_expire.module \node_expire_form_node_type_form_alter()
- 7.2 node_expire.module \node_expire_form_node_type_form_alter()
Implements hook_form_alter().
Enable/Disable expiration feature on node types
File
- ./
node_expire.module, line 81 - Set a timer into your content, allowing you to perform customized actions.
Code
function node_expire_form_node_type_form_alter(&$form, &$form_state) {
if (user_access('administer node expire')) {
$ntypes = variable_get('node_expire_ntypes', array());
$node_type = $form['#node_type']->type;
$handle_content_expiry = variable_get('node_expire_handle_content_expiry', 2);
if ($handle_content_expiry != 0) {
$form['workflow']['node_expire_enabled'] = array(
'#title' => t('Enable Node Expiry'),
'#description' => t('Allow nodes to expire after a certain amount of time.'),
'#type' => 'checkbox',
'#default_value' => empty($ntypes[$node_type]['enabled']) ? '' : $ntypes[$node_type]['enabled'],
);
// Visibility.
$states = array(
'visible' => array(
':input[name="node_expire_enabled"]' => array(
'checked' => TRUE,
),
),
);
$form['workflow']['node_expire_container'] = array(
'#type' => 'fieldset',
'#title' => t('Node Expire'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#states' => $states,
);
// Text fields.
$form['workflow']['node_expire_container']['node_expire'] = array(
'#title' => t('Default expiration date'),
'#description' => t('Default date to consider the node expired.') . ' ' . t('Format: PHP <a href="http://www.php.net/strtotime" target="_blank">strtotime format</a>.'),
'#type' => 'textfield',
'#default_value' => empty($ntypes[$node_type]['default']) ? '' : $ntypes[$node_type]['default'],
'#states' => $states,
);
$form['workflow']['node_expire_container']['node_expire_max'] = array(
'#title' => t('Expiration date limit'),
'#description' => t('The max date to consider the node expired.') . ' ' . t('Format: PHP <a href="http://www.php.net/strtotime" target="_blank">strtotime format</a>.') . ' ' . t('Leave it blank if this there is no limit date.'),
'#type' => 'textfield',
'#default_value' => empty($ntypes[$node_type]['max']) ? '' : $ntypes[$node_type]['max'],
'#states' => $states,
);
$form['workflow']['node_expire_container']['node_expire_required'] = array(
'#title' => t('Expiration date required'),
'#type' => 'checkbox',
'#default_value' => !empty($ntypes[$node_type]['required']),
'#states' => $states,
);
}
else {
$form['workflow']['node_expire'] = array(
'#title' => t('Default expiration date'),
'#description' => t('Default date to consider the node expired.') . ' ' . t('Format: PHP <a href="http://www.php.net/strtotime" target="_blank">strtotime format</a>.') . ' ' . t('Leave it blank if this content type never expires.'),
'#type' => 'textfield',
'#default_value' => empty($ntypes[$node_type]['default']) ? '' : $ntypes[$node_type]['default'],
);
$form['workflow']['node_expire_max'] = array(
'#title' => t('Expiration date limit'),
'#description' => t('The max date to consider the node expired.') . ' ' . t('Format: PHP <a href="http://www.php.net/strtotime" target="_blank">strtotime format</a>.') . ' ' . t('Leave it blank if this there is no limit date.'),
'#type' => 'textfield',
'#default_value' => empty($ntypes[$node_type]['max']) ? '' : $ntypes[$node_type]['max'],
);
$form['workflow']['node_expire_required'] = array(
'#title' => t('Expiration date required'),
'#type' => 'checkbox',
'#default_value' => !empty($ntypes[$node_type]['required']),
);
}
// Add special validate/submit functions.
module_load_include('ntype.inc', 'node_expire');
$form['#validate'][] = '_node_expire_form_node_type_form_alter_validate';
$form['#submit'][] = '_node_expire_form_node_type_form_alter_submit';
}
}