function merci_token_values in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6.2
Same name and namespace in other branches
- 6 merci.module \merci_token_values()
Implementation of hook_token_values().
See also
{merci_token_list}
File
- ./
merci.module, line 671 - MERCI - Managed Equipment Reservation Checkout and Inventory
Code
function merci_token_values($type, $object = NULL, $options = array()) {
switch ($type) {
case 'node':
$node = merci_load($object);
if ($node) {
$values['merci_resources'] = '';
// We want these timestamps generated in UTC.
$old_timezone = date_default_timezone_get();
date_default_timezone_set('UTC');
$starthour = strtotime($node->field_merci_date[0]['value']);
$endhour = strtotime($node->field_merci_date[0]['value2']);
date_default_timezone_set($old_timezone);
$hours = round(($endhour - $starthour) / 3600, 2);
$titles = array();
foreach ($node->merci_reservation_items as $item) {
$item_node = node_load($item['merci_placeholder_nid']);
if ($item['item_title'] != '') {
$titles[] = $item['item_title'];
}
else {
$titles[] = $item['merci_placeholder_title'];
}
}
$values['merci_resources'] = check_plain(implode(", ", $titles));
return $values;
}
}
}