You are here

function ad_html_adapi in Advertisement 5.2

Same name and namespace in other branches
  1. 5 html/ad_html.module \ad_html_adapi()
  2. 6.3 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 37
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 * FROM {ad_html} WHERE aid = %d', $node['aid']));
      $return['ad'] = $return['html'];
      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 'html';
    case 'permissions':
      if (!isset($node->adtype) || $node->adtype == 'html') {
        return array(
          'manage ad html' => TRUE,
        );
      }
  }
}