function ad_text_adapi in Advertisement 7
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 text/ad_text.module \ad_text_adapi()
- 6.2 text/ad_text.module \ad_text_adapi()
Implementation of hook_adapi().
File
- text/
ad_text.module, line 195 - Enhances the ad module to support static text ads.
Code
function ad_text_adapi($op, $node) {
switch ($op) {
case 'load':
$result = db_query('SELECT aid, url, adheader, adbody FROM {ad_text} WHERE aid = :aid', array(
':aid' => $node->nid,
))
->fetchAssoc();
$result['ad'] = ad_text_display_prepare($result['adheader'], filter_default_format()) . '<br />' . ad_text_display_prepare($result['adbody'], filter_default_format());
return $result;
case 'insert':
db_insert('ad_text')
->fields(array(
'aid' => $node->nid,
'url' => $node->url,
'adheader' => $node->adheader,
'adbody' => $node->adbody,
))
->execute();
break;
case 'update':
if (ad_permission($node->nid, 'manage ad text')) {
db_query("UPDATE {ad_text} SET url = :url, adheader = :adheader, adbody = :adbody WHERE aid = :aid", array(
':url' => $node->url,
':adheader' => $node->adheader,
':adbody' => $node->adbody,
':aid' => $node->nid,
));
}
break;
case 'delete':
db_query('DELETE FROM {ad_text} WHERE aid = :aid', array(
':aid' => $node->nid,
));
break;
case 'form':
return _ad_text_node_form($node);
case 'view':
return _ad_text_node_view($node);
case 'redirect':
return db_query('SELECT url FROM {ad_text} WHERE aid = :aid', array(
':aid' => $node->nid,
))
->fetchField();
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' => TRUE,
);
}
}
}