function cloneimagefield_nodeapi in Node clone 5.2
Same name and namespace in other branches
- 5 cloneimagefield.module \cloneimagefield_nodeapi()
Implementation of hook_nodeapi().
Take advantage of the fact that imagefield.module does not use the 'submit' $op to copy files at the 'submit' phase before the node is actually saved. Only relevant when the "prepopulate" method is being used.
File
- ./
cloneimagefield.module, line 82
Code
function cloneimagefield_nodeapi(&$node, $op) {
if ($op == 'submit' && isset($node->node_clone_imagefield)) {
// The data was serialized so it could be passed as a hidden form field.
$image_fields = unserialize($node->node_clone_imagefield);
foreach (array_keys($image_fields) as $key) {
foreach ($node->{$key} as $delta => $file) {
// Check whether this file was attached to the original node, and that
// it is not slated for removal.
if ($file['filepath'] == $image_fields[$key][$delta]['filepath'] && empty($file['flags']['delete'])) {
_cloneimagefield_copy_file($node, $key, $delta);
}
}
}
}
}