You are here

function _ad_channel_save_node in Advertisement 5.2

Same name and namespace in other branches
  1. 6.3 channel/ad_channel.module \_ad_channel_save_node()
  2. 6.2 channel/ad_channel.module \_ad_channel_save_node()
  3. 7 channel/ad_channel.module \_ad_channel_save_node()

Save channels associated with added or updated node.

1 call to _ad_channel_save_node()
ad_channel_nodeapi in channel/ad_channel.module
Implementation of hook_nodeapi().

File

channel/ad_channel.module, line 280
Ad Channel

Code

function _ad_channel_save_node($node) {

  // delete old channel information, then add new
  db_query('DELETE FROM {ad_channel_node} WHERE nid = %d', $node->nid);
  $channels = _ad_channel_get_enabled($node);
  foreach ($channels as $chid) {
    db_query('INSERT INTO {ad_channel_node} (chid, nid) VALUES(%d, %d)', $chid, $node->nid);
  }
  if (user_access('configure ad premiere status')) {
    db_query('UPDATE {ad_priority} SET priority = %d WHERE aid = %d', $node->premiere, $node->nid);
    if (!db_affected_rows()) {
      db_query('INSERT INTO {ad_priority} (aid, priority) VALUES(%d, %d)', $node->nid, $node->premiere);
    }
  }
}