function uuid_nodeapi in Universally Unique IDentifier 5
Same name and namespace in other branches
- 6 uuid.module \uuid_nodeapi()
Implementation of hook_nodeapi().
File
- ./
uuid.module, line 6
Code
function uuid_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {
case 'load':
return array(
'uuid' => db_result(db_query('SELECT uuid FROM {uuid_node} WHERE nid = %d', $node->nid)),
'revision_uuid' => db_result(db_query('SELECT uuid FROM {uuid_node_revisions} WHERE vid = %d', $node->vid)),
);
case 'insert':
db_query('INSERT INTO {uuid_node} (nid, uuid) VALUES (%d, UUID())', $node->nid);
db_query('INSERT INTO {uuid_node_revisions} (vid, uuid) VALUES (%d, UUID())', $node->vid);
break;
case 'update':
if ($node->revision) {
db_query('INSERT INTO {uuid_node_revisions} (vid, uuid) VALUES (%d, UUID())', $node->vid);
}
break;
case 'delete':
db_query('DELETE FROM {uuid_node} WHERE nid = %d', $node->nid);
break;
case 'delete revision':
db_query('DELETE FROM {uuid_node_revisions} WHERE vid = %d', $node->vid);
break;
}
}