You are here

function ad_external_adapi in Advertisement 7

Same name and namespace in other branches
  1. 5.2 external/ad_external.module \ad_external_adapi()
  2. 5 external/ad_external.module \ad_external_adapi()
  3. 6.3 external/ad_external.module \ad_external_adapi()
  4. 6 external/ad_external.module \ad_external_adapi()
  5. 6.2 external/ad_external.module \ad_external_adapi()

Implementation of hook_adapi().

File

external/ad_external.module, line 90
Enhances the ad module to support externally hosted ads, served via IFrames. It is recommended that you configure "Administer >> Content management >> Ads >> Settings >> Global settings >> Display type" to…

Code

function ad_external_adapi($op, $node) {
  switch ($op) {
    case 'load':
      return db_fetch_array(db_query('SELECT * FROM {ad_external} WHERE aid = %d', $node['aid']));
    case 'insert':
      db_query("INSERT INTO {ad_external} (aid, url) VALUES(%d, '%s')", $node->nid, $node->url);
      break;
    case 'update':
      db_query("UPDATE {ad_external} SET url = '%s' WHERE aid = %d", $node->url, $node->nid);
      break;
    case 'delete':
      db_query('DELETE FROM {ad_external} WHERE aid = %d', $node->nid);
      break;
    case 'form':
      return ad_external_node_form($node);
    case 'view':
      return ad_external_node_view($node);
    case 'redirect':

      // TODO: Would it ever make sense to have redirects for this ad type?
      watchdog('ad', 'Unexpected redirect attempt in external ad type.');
      return;
    case 'type':
      return array(
        'external' => array(
          'name' => t('External ad'),
          'module' => 'ad_external',
          'description' => t('An external advertisement, displayed in an IFrame.'),
          'help' => t('An external advertisement, displayed in an IFrame.'),
        ),
      );
  }
}