You are here

function simplenews_update in Simplenews 5

Implementation of hook_update().

File

./simplenews.module, line 427

Code

function simplenews_update($node) {
  $term = simplenews_validate_taxonomy($node->taxonomy);
  $tid = is_array($term) ? array_values($term) : FALSE;
  $node->simplenews_tid = $tid ? $tid[0] : 0;
  if ($node->send == 1 && user_access('send newsletter')) {
    db_query("UPDATE {simplenews_newsletters} SET vid = %d, tid = %d, s_status = %d, s_format = '%s', priority = %d, receipt = %d\n    WHERE nid = %d", $node->vid, $node->simplenews_tid, 1, $node->s_format, $node->priority, $node->receipt, $node->nid);
  }
  else {
    db_query("UPDATE {simplenews_newsletters} SET tid = %d, s_format = '%s', priority = %d, receipt = %d\n    WHERE nid = %d", $node->simplenews_tid, $node->s_format, $node->priority, $node->receipt, $node->nid);
  }
}