| 1 |
<?php |
<?php |
| 2 |
// $Id: node_expire.module,v 1.6 2009/01/28 12:57:52 brmassa Exp $ |
// $Id: node_expire.module,v 1.7 2009/01/29 19:58:01 brmassa Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 35 |
if (isset($form['type']) |
if (isset($form['type']) |
| 36 |
and $form['type']['#value'] .'_node_form' == $form_id |
and $form['type']['#value'] .'_node_form' == $form_id |
| 37 |
and $ntypes = variable_get('node_expire_ntypes', array()) |
and $ntypes = variable_get('node_expire_ntypes', array()) |
| 38 |
and !empty($ntypes[$form['type']['#value']])) { |
and $ntypes = $ntypes[$form['type']['#value']]) { |
| 39 |
|
|
| 40 |
// Check if the Node Expire feature is enabled for the node type |
module_load_include('nodeapi.inc', 'node_expire'); |
| 41 |
$node = isset($form['#node']) ? $form['#node'] : NULL; |
_node_expire_form_alter_nodeform($ntypes, $form, $form_state, $form_id); |
|
|
|
|
// Convert the timestamp into a human readable date |
|
|
if (is_numeric($node->expire)) { |
|
|
$node->expire = format_date($node->expire, 'custom', NODE_EXPIRE_FORMAT); |
|
|
} |
|
|
|
|
|
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, |
|
|
'#default_value' => $node->expire, |
|
|
); |
|
|
|
|
|
// In case jQuery UI module is enabled, use it to |
|
|
// get the DatePicker widget. |
|
|
if (module_exists('jquery_ui')) { |
|
|
jquery_ui_add('ui.datepicker'); |
|
|
drupal_add_js(drupal_get_path('module', 'node_expire') .'/node_expire.js'); |
|
|
drupal_add_js(array('dateFormat' => NODE_EXPIRE_FORMAT_JS), 'setting'); |
|
|
} |
|
|
} |
|
|
else { |
|
|
$expire_field = array( |
|
|
'#type' => 'value', |
|
|
'#value' => $node->expire |
|
|
); |
|
|
} |
|
|
|
|
|
// Put the expire field into 'Publising options' if possible |
|
|
if (user_access('administer nodes')) { |
|
|
$form['options']['expire'] = &$expire_field; |
|
|
} |
|
|
else { |
|
|
$form['expire'] = &$expire_field; |
|
|
} |
|
|
|
|
|
if (isset($node->expired)) { |
|
|
$form['node_expire'] = array( |
|
|
'#type' => 'value', |
|
|
'#value' => TRUE, |
|
|
); |
|
|
} |
|
| 42 |
} |
} |
| 43 |
} |
} |
| 44 |
|
|
| 53 |
$ntype = $form['#node_type']->type; |
$ntype = $form['#node_type']->type; |
| 54 |
$form['workflow']['node_expire'] = array( |
$form['workflow']['node_expire'] = array( |
| 55 |
'#title' => t('Expiration Date'), |
'#title' => t('Expiration Date'), |
| 56 |
'#description' => t('Time/date to consider the node expired. Format: PHP <a href="http://www.php.net/strtotime" target="_blank">strtotime format</a>. Leave it blank if this content type never expires.'), |
'#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.'), |
| 57 |
|
'#type' => 'textfield', |
| 58 |
|
'#default_value' => empty($ntypes[$ntype]['default']) ? '' : $ntypes[$ntype]['default'], |
| 59 |
|
); |
| 60 |
|
$form['workflow']['node_expire_max'] = array( |
| 61 |
|
'#title' => t('Expiration Date Limit'), |
| 62 |
|
'#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.'), |
| 63 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 64 |
'#default_value' => empty($ntypes[$ntype]) ? '' : $ntypes[$ntype], |
'#default_value' => empty($ntypes[$ntype]['max']) ? '' : $ntypes[$ntype]['max'], |
|
'#attributes' => array('class' => 'jscalendar'), |
|
| 65 |
); |
); |
| 66 |
|
|
| 67 |
// Add special validate/submit functions |
// Add special validate/submit functions |
| 82 |
} |
} |
| 83 |
|
|
| 84 |
module_load_include('nodeapi.inc', 'node_expire'); |
module_load_include('nodeapi.inc', 'node_expire'); |
| 85 |
_node_expire_nodeapi($ntypes, $node, $op, $a3, $a4 ); |
_node_expire_nodeapi($ntypes, $node, $op, $a3, $a4); |
| 86 |
} |
} |
| 87 |
|
|
| 88 |
/** |
/** |