function ad_owners_nodeapi in Advertisement 6
Same name and namespace in other branches
- 6.3 owners/ad_owners.module \ad_owners_nodeapi()
- 6.2 owners/ad_owners.module \ad_owners_nodeapi()
- 7 owners/ad_owners.module \ad_owners_nodeapi()
Implementation of hook_nodeapi().
File
- owners/
ad_owners.module, line 128 - Enhances the ad module to support ad owners.
Code
function ad_owners_nodeapi(&$node, $op, $teaser, $page) {
global $user;
switch ($op) {
case 'insert':
case 'update':
if (isset($node->adtype)) {
// Be sure ad owner has at least default ad permissions.
ad_owners_add($node, $node->uid);
ad_host_id_create($node->uid);
}
break;
case 'delete':
// Clean up ad_permissions and any other per-ad tables.
$result = db_query('SELECT oid, uid FROM {ad_owners} WHERE aid = %d', $node->nid);
while ($id = db_fetch_object($result)) {
db_query('DELETE FROM {ad_permissions} WHERE oid = %d', $id->oid);
$owner = user_load(array(
'uid' => $id->uid,
));
// Tell plug-in modules to clean up.
module_invoke_all('adowners', 'remove', $id->oid, $owner);
}
db_query('DELETE FROM {ad_owners} WHERE aid = %d', $node->nid);
break;
}
}