You are here

function ad_html_adapi in Advertisement 7

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.3 html/ad_html.module \ad_html_adapi()
  4. 6 html/ad_html.module \ad_html_adapi()
  5. 6.2 html/ad_html.module \ad_html_adapi()

Implementation of the ad module's _adapi hook.

File

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

Code

function ad_html_adapi($op, $node) {
  switch ($op) {
    case 'load':
      $return = db_query('SELECT html FROM {ad_html} WHERE aid = :aid', array(
        ':aid' => $node->aid,
      ))
        ->fetchAssoc();
      $return['ad'] = check_markup($return['html'], 'full_html');
      return $return;
    case 'insert':
      db_query("INSERT INTO {ad_html} (aid, html) VALUES(:aid, :html)", array(
        ':aid' => $node->nid,
        ':html' => $node->html,
      ));
      break;
    case 'update':
      db_query("UPDATE {ad_html} SET html = :html WHERE aid = :aid", array(
        ':html' => $node->html,
        ':aid' => $node->nid,
      ));
      break;
    case 'delete':
      db_query('DELETE FROM {ad_html} WHERE aid = :aid', array(
        ':aid' => $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,
        );
      }
  }
}