function flashnode_update in Flash Node 5.2
Same name and namespace in other branches
- 5.6 flashnode.module \flashnode_update()
- 5.3 flashnode.module \flashnode_update()
- 6.3 flashnode.module \flashnode_update()
- 6.2 flashnode.module \flashnode_update()
Implementation of hook_update
File
- ./
flashnode.module, line 399
Code
function flashnode_update($node) {
// Get the path of the old file
$old_path = db_result(db_query("SELECT filepath FROM {files} WHERE filename='%s' AND nid=%d", '_flashnode', $node->nid));
// This is a new file if the old path and the current path differ...
if ($old_path != $node->flashnode['_flashnode']) {
// ...so delete the old path
file_delete(file_create_path($old_path));
// Delete the entries for the old file from the database
db_query("DELETE FROM {files} WHERE filename='%s' AND nid=%d", '_flashnode', $node->nid);
db_query("DELETE FROM {flashnode} WHERE nid=%d", $node->nid);
// Call flashnode_insert to create the new entry
flashnode_insert($node);
}
else {
// We still have the same file, but we have some new settings to update in the database
db_query("UPDATE {flashnode} SET height=%d, width=%d, display=%d, substitution='%s', flashvars='%s', base='%s' WHERE nid=%d", $node->flashnode['height'], $node->flashnode['width'], $node->flashnode['display'], $node->flashnode['substitution'], $node->flashnode['flashvars'], $node->flashnode['base'], $node->nid);
}
// Reset the cache to ensure any pages using filters are updated
cache_clear_all('*', 'cache_filter', true);
}