function commons_activity_streams_node_insert in Drupal Commons 7.3
Implements hook_node_insert().
File
- modules/
commons/ commons_activity_streams/ commons_activity_streams.module, line 34
Code
function commons_activity_streams_node_insert($node) {
// Create a message when a user creates a new node.
$account = user_load($node->uid);
// Allow other modules to change the message type used for this event.
$hook = 'node_insert';
$message_type = 'commons_activity_streams_node_created';
drupal_alter('commons_activity_streams_message_selection', $message_type, $hook, $node);
$message = message_create($message_type, array(
'uid' => $account->uid,
'timestamp' => $node->created,
));
// Save reference to the node in the node reference field, and the
$wrapper = entity_metadata_wrapper('message', $message);
// We use a multiple value field in case we wish to use the same
// field for grouping messages in the future
// (eg http://drupal.org/node/1757060).
$wrapper->field_target_nodes[] = $node;
$wrapper
->save();
}