function flashnode_update in Flash Node 6.3
Same name and namespace in other branches
- 5.6 flashnode.module \flashnode_update()
- 5.2 flashnode.module \flashnode_update()
- 5.3 flashnode.module \flashnode_update()
- 6.2 flashnode.module \flashnode_update()
Implementation of hook_update
File
- ./
flashnode.module, line 451
Code
function flashnode_update($node) {
// Get original vid, but vid to use is different depending if this is a revision or not
if ($node->revision) {
$vid = $node->old_vid;
}
else {
$vid = $node->vid;
}
// Get the fid and filepath of the original Flash file for this node
$old_fid = db_result(db_query("SELECT {flashnode}.fid FROM {flashnode} INNER JOIN {files} ON {flashnode}.fid = {files}.fid WHERE {flashnode}.vid = %d", $vid));
// If the current fid and existing fid don't match then we have a new file so move it
if ($old_fid != $node->flashnode['fid']) {
$new_file = TRUE;
_flashnode_file_move($node);
}
// If creating a new revision call flashnode_insert, otherwise process update
if ($node->revision) {
flashnode_insert($node);
}
else {
// If a new file was uploaded remove the old file if no longer needed
if ($new_file) {
_flashnode_delete_file_if_no_longer_needed($old_fid);
}
// Update {flashnode} and {files} with new data
db_query("UPDATE {flashnode} SET nid = %d, height = %d, width = %d, display = %d, substitution = '%s', flashvars = '%s', base = '%s', fid = %d, params = '%s' WHERE vid = %d", $node->nid, $node->flashnode['height'], $node->flashnode['width'], $node->flashnode['display'], $node->flashnode['substitution'], $node->flashnode['flashvars'], $node->flashnode['base'], $node->flashnode['fid'], $node->flashnode['params'], $node->vid);
db_query("UPDATE {files} SET status = %d, filepath = '%s' WHERE fid = %d", FILE_STATUS_PERMANENT, $node->flashnode['filepath'], $node->flashnode['fid']);
}
}