function simpleads_node_presave in SimpleAds 7
Same name and namespace in other branches
- 7.2 includes/node.inc \simpleads_node_presave()
Implements hook_node_presave().
File
- ./
simpleads.module, line 160
Code
function simpleads_node_presave($node) {
if ($node->type == 'simpleads') {
$start_time = 0;
$end_time = 0;
if (isset($node->field_ad_start_date[$node->language]) && !empty($node->field_ad_start_date[$node->language][0]['value'])) {
$start_time = $node->field_ad_start_date[$node->language][0]['value'];
}
if (isset($node->field_ad_end_date[$node->language]) && !empty($node->field_ad_end_date[$node->language][0]['value'])) {
$end_time = $node->field_ad_end_date[$node->language][0]['value'];
}
$start_time = strtotime($start_time);
$end_time = strtotime($end_time);
if ($start_time != 0) {
$node->field_ad_start_date[$node->language][0]['value'] = format_date($start_time, 'custom', 'm/d/Y h:i a');
}
if ($end_time != 0) {
$node->field_ad_end_date[$node->language][0]['value'] = format_date($end_time, 'custom', 'm/d/Y h:i a');
}
_simpleads_activate_deactive_ad($node, 'presave');
}
}