You are here

function pmteam_update in Drupal PM (Project Management) 7

Implements hook_update().

File

pmteam/pmteam.module, line 333
Functionality for the Project Management Team module Organized into the following sections:

Code

function pmteam_update($node) {
  _pmteam_beforesave($node);
  if ($node->revision) {
    pmteam_insert($node);
  }
  else {
    if (isset($node->vid) && isset($node->nid) && isset($node->members_array)) {

      // Delete the old members
      db_delete('pmteam')
        ->condition('vid', $node->vid)
        ->execute();

      // Insert entries
      $member = new stdClass();
      $member->nid = $node->nid;
      $member->vid = $node->vid;
      foreach ($node->members_array as $mnid => $member_name) {
        $member->mnid = $mnid;
        drupal_write_record('pmteam', $member);
      }
    }

    // Invokes hook_pmteam_change so that if title has changed, other modules that have cached the title can update it.
    if ($node->title != $node->title_old) {
      module_invoke_all('pmteam_change', $node->nid, $node->title);
    }
  }
}