function ad_embed_nodeapi in Advertisement 6.2
Same name and namespace in other branches
- 5.2 embed/ad_embed.module \ad_embed_nodeapi()
- 5 embed/ad_embed.module \ad_embed_nodeapi()
- 6.3 embed/ad_embed.module \ad_embed_nodeapi()
- 6 embed/ad_embed.module \ad_embed_nodeapi()
- 7 embed/ad_embed.module \ad_embed_nodeapi()
Implementation of hook_nodeapi().
File
- embed/
ad_embed.module, line 74 - Embed ads in content.
Code
function ad_embed_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {
case 'view':
$node = (object) $node;
// Only replace tags if content creator has 'embed' permission
if (user_access('embed ads in content', user_load(array(
'uid' => $node->uid,
)))) {
if (isset($node->content['teaser']['#value'])) {
$node->content['teaser']['#value'] = ad_embed_replace($node->content['teaser']['#value']);
}
if (isset($node->content['body']['#value'])) {
$node->content['body']['#value'] = ad_embed_replace($node->content['body']['#value']);
}
}
if (!$teaser && variable_get("embed-ad-{$node->type}", 0)) {
$ad = ad(variable_get("embed-ad-{$node->type}" . '-group', array()), variable_get("embed-ad-{$node->type}" . '-quantity', 1));
$node->content['body']['#value'] = ad_embed_auto($node->content['body']['#value'], $ad, variable_get("embed-ad-{$node->type}" . '-count', 3), variable_get("embed-ad-{$node->type}" . '-force', 0));
}
}
}