You are here

function commons_wikis_node_update in Drupal Commons 7.3

Implements hook_node_update().

File

modules/commons/commons_wikis/commons_wikis.module, line 150

Code

function commons_wikis_node_update($node) {
  if ($node->type == 'wiki' && module_exists('message')) {
    global $user;
    commons_groups_first_contribution($user, $node);
    $message = message_create('commons_wikis_wiki_updated', array(
      'uid' => $user->uid,
      'timestamp' => REQUEST_TIME,
    ));
    $wrapper = entity_metadata_wrapper('message', $message);

    // Save reference to the node in the node reference field.
    // 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();
  }
}