Index: modules/node_expire/node_expire.module
===================================================================
--- modules/node_expire/node_expire.module (revision 1140)
+++ modules/node_expire/node_expire.module (working copy)
@@ -51,21 +51,24 @@
if (user_access('administer node expire')) {
$ntypes = variable_get('node_expire_ntypes', array());
$ntype = $form['#node_type']->type;
- $form['workflow']['node_expire'] = array(
- '#title' => t('Expiration Date'),
- '#description' => t('Default date to consider the node expired.') .' '. t('Format: PHP strtotime format.') .' '. t('Leave it blank if this content type never expires.'),
- '#type' => 'textfield',
- '#default_value' => empty($ntypes[$ntype]['default']) ? '' : $ntypes[$ntype]['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 strtotime format.') .' '. t('Leave it blank if this there is no limit date.'),
- '#type' => 'textfield',
- '#default_value' => empty($ntypes[$ntype]['max']) ? '' : $ntypes[$ntype]['max'],
- );
- $form['workflow']['node_expire_required'] = array(
- '#title' => t('Expiration Date Required'),
- '#type' => 'checkbox',
- '#default_value' => !empty($ntypes[$ntype]['required']),
- );
+ $form['workflow']['node_expire_settings'] = array(
+ '#type' => 'radios',
+ '#title' => t('Node Expire'),
+ '#default_value' => variable_get('node_expire_settings_'. $form['#node_type']->type, 0),
+ '#options' => array(t('Disabled'), t('Enabled'), t('Required')),
+ );
+ if($form['workflow']['node_expire_settings']['#default_value'] > 0) {
+ $form['workflow']['node_expire'] = array(
+ '#title' => t('Expiration Date'),
+ '#description' => t('Default date to consider the node expired.') .' '. t('Format: PHP strtotime format.') .' '. t('Leave it blank if this content type never expires.'),
+ '#type' => 'textfield',
+ '#default_value' => empty($ntypes[$ntype]['default']) ? '' : $ntypes[$ntype]['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 strtotime format.') .' '. t('Leave it blank if this there is no limit date.'),
+ '#type' => 'textfield',
+ '#default_value' => empty($ntypes[$ntype]['max']) ? '' : $ntypes[$ntype]['max'],
+ );
+ }
// Add special validate/submit functions
Index: modules/node_expire/node_expire.ntype.inc
===================================================================
--- modules/node_expire/node_expire.ntype.inc (revision 1140)
+++ modules/node_expire/node_expire.ntype.inc (working copy)
@@ -15,7 +15,7 @@
- form_set_error('node_expire', 'This values should be in PHP strtotime format.');
+ form_set_error('node_expire', 'This value should be in PHP strtotime format.');
}
$node_expire_max = &$form_state['values']['node_expire_max'];
if (!empty($node_expire_max)) {
if (!strtotime($node_expire_max)) {
- form_set_error('node_expire_max', 'This values should be in PHP strtotime format.');
+ form_set_error('node_expire_max', 'This value should be in PHP strtotime format.');
Index: modules/node_expire/node_expire.ntype.inc
===================================================================
--- modules/node_expire/node_expire.ntype.inc (revision 1140)
+++ modules/node_expire/node_expire.ntype.inc (working copy)
@@ -33,7 +33,11 @@
function _node_expire_form_node_type_form_alter_submit(&$form, &$form_state) {
$ntypes = variable_get('node_expire_ntypes', array());
- $ntypes[$form_state['values']['type']]['default'] = $form_state['values']['node_expire'];
- $ntypes[$form_state['values']['type']]['max'] = $form_state['values']['node_expire_max'];
- $ntypes[$form_state['values']['type']]['required'] = $form_state['values']['node_expire_required'];
+ if($form_state['values']['type']['settings']) {
+ $ntypes[$form_state['values']['type']]['default'] = $form_state['values']['node_expire'];
+ $ntypes[$form_state['values']['type']]['max'] = $form_state['values']['node_expire_max'];
+ $ntypes[$form_state['values']['type']]['settings'] = $form_state['values']['node_expire_settings'];
+ } else {
+ unset($ntypes[$form_state['values']['type']]);
+ }
variable_set('node_expire_ntypes', $ntypes);
}
Index: modules/node_expire/node_expire.nodeapi.inc
===================================================================
--- modules/node_expire/node_expire.nodeapi.inc (revision 1140)
+++ modules/node_expire/node_expire.nodeapi.inc (working copy)
@@ -20,18 +20,24 @@
$node->expire = $row->expire;
$node->expired = $row->expired;
}
+ // My solution is to make it behave like it does on node creation...
+ if ($node->expire == '0' && !user_access('edit node expire') )
+ {
+ unset($node->expire);
+ }
break;
case 'prepare':
- if (!isset($node->expire)) {
- $node->expire = format_date(strtotime($ntypes['default']), 'custom', NODE_EXPIRE_FORMAT);
- }
+ //patch code begins, make sure we don't pass an empty variable to the format date function.
+ if(!empty($ntypes['default'])){
+ $node->expire = format_date(strtotime($ntypes['default']), 'custom', NODE_EXPIRE_FORMAT);
+ }
break;
case 'validate':
// The only restriction we have is that the node can't expire in the past.
if ($node->expire == '') {
- if (!empty($ntypes['required'])) {
+ if ($ntypes['settings'] > 1) {
form_set_error('expire_date', t('You must choose an expiration date.'));
}
}
Index: modules/node_expire/node_expire.nodeapi.inc
===================================================================
--- modules/node_expire/node_expire.nodeapi.inc (revision 1140)
+++ modules/node_expire/node_expire.nodeapi.inc (working copy)
@@ -76,12 +82,23 @@
if (user_access('edit node expire')) {
- $expire_field = array(
- '#title' => t('Expiration Date'),
- '#description' => t('Time date to consider the node expired. Format: %time.',
- array('%time' => format_date(time(), 'custom', NODE_EXPIRE_FORMAT))),
- '#type' => 'textfield',
- '#maxlength' => 25,
- '#required' => $ntypes['required'],
- '#default_value' => $node->expire,
- );
+ if ($ntypes['settings'] > 0 ) {
+ if ($ntypes['settings'] == 2) {$required = 1;}
+ else {$required = 0;}
+ if ($ntypes['max']) {
+ $description = t('Time date to consider the node expired. Format: %time. It must expire before %max.',
+ array('%time' => format_date(time(), 'custom', NODE_EXPIRE_FORMAT), '%max' => format_date(strtotime($ntypes['max'], $node->created), 'custom', NODE_EXPIRE_FORMAT)));
+ }
+ else {
+ $description = t('Time date to consider the node expired. Format: %time.',
+ array('%time' => format_date(time(), 'custom', NODE_EXPIRE_FORMAT)));
+ }
+ $expire_field = array(
+ '#title' => t('Expiration Date'),
+ '#type' => 'textfield',
+ '#description' => $description,
+ '#maxlength' => 25,
+ '#required' => $required,
+ '#default_value' => $node->expire,
+ );
+ }
// In case jQuery UI module is enabled, use it to