You are here

function simplenews_newsletter_update in Simplenews 6.2

Update {simplenews_newsletter} table

Parameters

node $node the current node (or translation) that should be updated:

array $param the values which to update the newsletter with:

2 calls to simplenews_newsletter_update()
simplenews_nodeapi in ./simplenews.module
Implementation of hook_nodeapi().
simplenews_node_tab_send_form_submit in ./simplenews.module
Simplenews tab form submit callback

File

./simplenews.module, line 530
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_newsletter_update($node, $param = array()) {

  // Is there already a corresponding newsletter ?
  $sn_nid = db_result(db_query("\n    SELECT nid\n    FROM {simplenews_newsletters}\n    WHERE nid = %d", $node->nid));
  if (!is_numeric($sn_nid)) {

    // No newsletter => we create it
    db_query("\n      INSERT INTO {simplenews_newsletters}\n      (nid, vid, tid, s_status, s_format, priority, receipt)\n      VALUES (%d, %d, %d, %d, '%s', %d, %d)", $node->nid, $node->vid, $param['tid'], $param['s_status'], $param['advanced']['s_format'], $param['advanced']['priority'], $param['advanced']['receipt']);
  }
  else {

    // Already existing => we update it
    db_query("\n      UPDATE {simplenews_newsletters}\n      SET vid = %d,\n      tid = %d,\n      s_status = %d,\n      s_format = '%s',\n      priority = %d,\n      receipt = %d\n      WHERE nid = %d", $node->vid, $param['tid'], $param['s_status'], $param['advanced']['s_format'], $param['advanced']['priority'], $param['advanced']['receipt'], $node->nid);
  }
}