function merci_inventory_operations_update in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.2
Same name and namespace in other branches
- 6.2 modules/merci_inventory/merci_inventory.module \merci_inventory_operations_update()
Callback function for adding items to new merci_inventory node.
File
- modules/
merci_inventory/ merci_inventory.module, line 68 - Hooks and functions for MERCI Inventory
Code
function merci_inventory_operations_update($objects, $context = array()) {
global $user;
// Construct the new node object.
$node = new stdClass();
$node->title = 'Inventory - ' . format_date(time(), $type = 'small');
$node->type = 'merci_inventory';
$node->language = 'und';
$node->uid = $user->uid;
foreach (array_keys($objects) as $nid) {
$target = array(
'target_id' => $nid,
);
$node->field_merci_inventory_item[$node->language][] = $target;
}
$node = node_submit($node);
node_save($node);
$node_link = l($node->title, 'node/' . $node->nid);
$watchdog_args = array(
'@type' => $node->type,
'!title' => $node_link,
);
$t_args = array(
'@type' => node_type_get_name($node),
'!title' => $node_link,
);
if ($node->nid) {
watchdog('content', '@type: added !title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
drupal_set_message(t('@type !title has been created.', $t_args));
}
}