| 1 |
<?php |
<?php |
| 2 |
// $Id: node_expire.module,v 1.5 2009/01/26 23:56:49 brmassa Exp $ |
// $Id: node_expire.module,v 1.6 2009/01/28 12:57:52 brmassa Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 40 |
// Check if the Node Expire feature is enabled for the node type |
// Check if the Node Expire feature is enabled for the node type |
| 41 |
$node = isset($form['#node']) ? $form['#node'] : NULL; |
$node = isset($form['#node']) ? $form['#node'] : NULL; |
| 42 |
|
|
| 43 |
|
// Convert the timestamp into a human readable date |
| 44 |
|
if (is_numeric($node->expire)) { |
| 45 |
|
$node->expire = format_date($node->expire, 'custom', NODE_EXPIRE_FORMAT); |
| 46 |
|
} |
| 47 |
|
|
| 48 |
if (user_access('edit node expire')) { |
if (user_access('edit node expire')) { |
| 49 |
if (is_numeric($node->expire)) { |
$expire_field = array( |
|
$node->expire = format_date($node->expire, 'custom', NODE_EXPIRE_FORMAT); |
|
|
} |
|
|
$form['expire'] = array( |
|
| 50 |
'#title' => t('Expiration Date'), |
'#title' => t('Expiration Date'), |
| 51 |
'#description' => t('Time date to consider the node expired. Format: %time.', |
'#description' => t('Time date to consider the node expired. Format: %time.', |
| 52 |
array('%time' => format_date(time(), 'custom', NODE_EXPIRE_FORMAT))), |
array('%time' => format_date(time(), 'custom', NODE_EXPIRE_FORMAT))), |
| 55 |
'#default_value' => $node->expire, |
'#default_value' => $node->expire, |
| 56 |
); |
); |
| 57 |
|
|
| 58 |
|
// In case jQuery UI module is enabled, use it to |
| 59 |
|
// get the DatePicker widget. |
| 60 |
if (module_exists('jquery_ui')) { |
if (module_exists('jquery_ui')) { |
| 61 |
jquery_ui_add('ui.datepicker'); |
jquery_ui_add('ui.datepicker'); |
| 62 |
drupal_add_js(drupal_get_path('module', 'node_expire') .'/node_expire.js'); |
drupal_add_js(drupal_get_path('module', 'node_expire') .'/node_expire.js'); |
| 64 |
} |
} |
| 65 |
} |
} |
| 66 |
else { |
else { |
| 67 |
$form['expire'] = array( |
$expire_field = array( |
| 68 |
'#type' => 'value', |
'#type' => 'value', |
| 69 |
'#value' => $node->expire |
'#value' => $node->expire |
| 70 |
); |
); |
| 71 |
} |
} |
| 72 |
|
|
| 73 |
|
// Put the expire field into 'Publising options' if possible |
| 74 |
|
if (user_access('administer nodes')) { |
| 75 |
|
$form['options']['expire'] = &$expire_field; |
| 76 |
|
} |
| 77 |
|
else { |
| 78 |
|
$form['expire'] = &$expire_field; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
if (isset($node->expired)) { |
if (isset($node->expired)) { |
| 82 |
$form['node_expire'] = array( |
$form['node_expire'] = array( |
| 83 |
'#type' => 'value', |
'#type' => 'value', |