function feeds_imagegrabber_nodeapi in Feeds Image Grabber 6
Implementation of hook_nodeapi().
File
- ./
feeds_imagegrabber.module, line 94 - Grabs image for each feed-item from their respective web pages and stores it in an image field. Requires Feeds module.
Code
function feeds_imagegrabber_nodeapi(&$node, $op, $form) {
switch ($op) {
case 'insert':
case 'update':
if ($importer_id = feeds_get_importer_id($node->type)) {
if ($node->feeds_imagegrabber['enabled']) {
$settings = array(
'feed_nid' => $node->nid,
'enabled' => $node->feeds_imagegrabber['enabled'],
'id_class' => $node->feeds_imagegrabber['id_class'],
'id_class_desc' => $node->feeds_imagegrabber['id_class_desc'],
'exec_time' => $node->feeds_imagegrabber['exec_time'],
'feeling_lucky' => $node->feeds_imagegrabber['feeling_lucky'],
);
// Make sure a source record is present at all time, try to update first,
// then insert.
drupal_write_record('feeds_imagegrabber', $settings, array(
'feed_nid',
));
if (!db_affected_rows()) {
drupal_write_record('feeds_imagegrabber', $settings);
}
}
else {
db_query("UPDATE {feeds_imagegrabber} SET enabled = %d WHERE feed_nid = %d", 0, $node->nid);
}
}
break;
case 'delete':
@db_query("DELETE FROM {feeds_imagegrabber} where feed_nid = %d", $node->nid);
break;
}
}