You are here

function _flashnode_file_move in Flash Node 6.3

Same name and namespace in other branches
  1. 6.2 flashnode.module \_flashnode_file_move()

Helper function: Move a new flash file flash directory Called by flashnode_insert and flashnode_update

2 calls to _flashnode_file_move()
flashnode_insert in ./flashnode.module
Implementation of hook_insert
flashnode_update in ./flashnode.module
Implementation of hook_update

File

./flashnode.module, line 431

Code

function _flashnode_file_move(&$node) {

  // Space can cause problems, so replace them with underscores
  $filename = str_replace(' ', '_', $node->flashnode['filename']);

  // Create the destination path and filename from the filename
  $destination = variable_get('flashnode_default_path', FLASHNODE_DEFAULT_PATH) . '/' . $filename;

  // Try to move the flash file to the flash directory, auto renames if it already exists
  file_move($node->flashnode['filepath'], $destination, FILE_EXISTS_RENAME);

  // Update {files} with new filepath and set status to permanent
  db_query("UPDATE {files} SET status = %d, filepath = '%s' WHERE fid = %d", FILE_STATUS_PERMANENT, $node->flashnode['filepath'], $node->flashnode['fid']);
}