function simplenews_insert in Simplenews 5
Implementation of hook_insert(). Saves extra node content to module database table.
File
- ./
simplenews.module, line 412
Code
function simplenews_insert($node) {
$term = simplenews_validate_taxonomy($node->taxonomy);
$tid = is_array($term) ? array_values($term) : FALSE;
$node->simplenews_tid = $tid ? $tid[0] : 0;
//tid is also saved in this table since it is needed by _simplenews_send(), and the term_node table is
//only updated after the execution of simplenews_insert(). It cannot be passed by a variable
//since simplenews_cron() also calls _simplenews_send().
$s_status = $node->send == 1 && user_access('send newsletter') ? 1 : 0;
db_query("INSERT INTO {simplenews_newsletters} (nid, vid, tid, s_status, s_format, priority, receipt)\n\t\t VALUES (%d, %d, %d, %d, '%s', %d, %d)", $node->nid, $node->vid, $node->simplenews_tid, $s_status, $node->s_format, $node->priority, $node->receipt);
}