You are here

function hosting_task_update in Hosting 7.3

Same name and namespace in other branches
  1. 5 task/hosting_task.module \hosting_task_update()
  2. 6.2 task/hosting_task.module \hosting_task_update()
  3. 7.4 task/hosting_task.module \hosting_task_update()

Implements hook_update().

As an existing node is being updated in the database, we need to do our own database updates.

File

task/hosting_task.module, line 964
Web server node type is defined here.

Code

function hosting_task_update($node) {

  // If this is a new node or we're adding a new revision.
  if (!empty($node->revision)) {
    hosting_task_insert($node);
  }
  else {
    hosting_task_set_title($node);
    db_update('hosting_task')
      ->fields(array(
      'nid' => $node->nid,
      'task_type' => $node->task_type,
      'task_status' => $node->task_status,
      'rid' => $node->rid,
      'executed' => $node->executed,
      'delta' => $node->delta,
    ))
      ->condition('vid', $node->vid)
      ->execute();
    if (isset($node->task_args) && is_array($node->task_args)) {

      // Wipe out old arguments first, since arguments could theoretically be removed.
      db_delete('hosting_task_arguments')
        ->condition('vid', $node->vid)
        ->execute();
      foreach ($node->task_args as $key => $value) {
        $id = db_insert('hosting_task_arguments')
          ->fields(array(
          'vid' => $node->vid,
          'nid' => $node->nid,
          'name' => $key,
          'value' => $value,
        ))
          ->execute();
      }
    }
    module_invoke_all('hosting_task_update_status', $node, $node->task_status);
  }
}