You are here

function ad_html_adapi in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 html/ad_html.module \ad_html_adapi()
  2. 5 html/ad_html.module \ad_html_adapi()
  3. 6 html/ad_html.module \ad_html_adapi()
  4. 6.2 html/ad_html.module \ad_html_adapi()
  5. 7 html/ad_html.module \ad_html_adapi()

Implementation of the ad module's _adapi hook.

File

html/ad_html.module, line 75
Enhances the ad module to support html ads.

Code

function ad_html_adapi($op, $node) {
  switch ($op) {
    case 'load':
      $return = db_fetch_array(db_query('SELECT html FROM {ad_html} WHERE aid = %d', $node['aid']));
      $return['ad'] = check_markup($return['html'], $node['format'], FALSE);
      return $return;
    case 'insert':
      db_query("INSERT INTO {ad_html} (aid, html) VALUES(%d, '%s')", $node->nid, $node->html);
      break;
    case 'update':
      db_query("UPDATE {ad_html} SET html = '%s' WHERE aid = %d", $node->html, $node->nid);
      break;
    case 'delete':
      db_query('DELETE FROM {ad_html} WHERE aid = %d', $node->nid);
      break;
    case 'form':
      return ad_html_node_form($node);
    case 'view':
      return ad_html_node_view($node);
    case 'type':
      return array(
        'html' => array(
          'name' => t('HTML ad'),
          'module' => 'ad_html',
          'description' => t('A html advertisement.'),
          'help' => t('A html advertisement.'),
        ),
      );
    case 'permissions':
      if (!isset($node->adtype) || $node->adtype == 'html') {
        return array(
          'manage ad html' => TRUE,
        );
      }
  }
}