function ad_text_adapi in Advertisement 5.2
Same name and namespace in other branches
- 5 text/ad_text.module \ad_text_adapi()
- 6.3 text/ad_text.module \ad_text_adapi()
- 6 text/ad_text.module \ad_text_adapi()
- 6.2 text/ad_text.module \ad_text_adapi()
- 7 text/ad_text.module \ad_text_adapi()
File
- text/
ad_text.module, line 121 - 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 * 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':
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':
return ad_text_node_validate($node);
case 'type':
return 'text';
case 'permissions':
if (!isset($node->adtype) || $node->adtype == 'text') {
return array(
'manage ad text' => TRUE,
);
}
}
}