function ad_text_adapi in Advertisement 6
Same name and namespace in other branches
- 5.2 text/ad_text.module \ad_text_adapi()
- 5 text/ad_text.module \ad_text_adapi()
- 6.3 text/ad_text.module \ad_text_adapi()
- 6.2 text/ad_text.module \ad_text_adapi()
- 7 text/ad_text.module \ad_text_adapi()
Implementation of hook_adapi().
File
- text/
ad_text.module, line 189 - Enhances the ad module to support static text ads.
Code
function ad_text_adapi($op, &$node) {
switch ($op) {
case 'load':
$return = db_fetch_array(db_query('SELECT aid, url, adheader, adbody FROM {ad_text} WHERE aid = %d', $node['aid']));
$return['ad'] = ad_text_display_prepare($return['adheader'], $node['format']) . '<br />' . ad_text_display_prepare($return['adbody'], $node['format']);
return $return;
case 'insert':
db_query("INSERT INTO {ad_text} (aid, url, adheader, adbody) VALUES(%d, '%s', '%s', '%s')", $node->nid, $node->url, $node->adheader, $node->adbody);
break;
case 'update':
if (ad_adaccess($node, 'manage ad text')) {
db_query("UPDATE {ad_text} SET url = '%s', adheader = '%s', adbody = '%s' WHERE aid = %d", $node->url, $node->adheader, $node->adbody, $node->nid);
}
break;
case 'delete':
db_query('DELETE FROM {ad_text} WHERE aid = %d', $node->nid);
break;
case 'form':
return ad_text_node_form($node);
case 'view':
return ad_text_node_view($node);
case 'redirect':
return db_result(db_query('SELECT url FROM {ad_text} WHERE aid = %d', $node->nid));
case 'validate':
$todo = array();
return ad_text_node_validate($node, $todo);
case 'type':
return array(
'text' => array(
'name' => t('Text ad'),
'module' => 'ad_text',
'description' => t('A text advertisement.'),
'help' => t('A text advertisement.'),
),
);
case 'permissions':
if (!isset($node->adtype) || $node->adtype == 'text') {
return array(
'manage ad text',
);
}
}
}