You are here

function oa_export_file in Open Atrium Export 7.2

Helper function to export the object representing the file and a copy of the actual file to our exports directory.

Parameters

object $file:

2 calls to oa_export_file()
oa_export_file_field in fields/oa_export.fields.export.inc
Helper function to export file fields along with the file.
oa_export_oa_export_entity_file in entity/oa_export.entity.export.inc
Implements hook_oa_export_entity_ENTITY_TYPE().

File

./oa_export.module, line 192

Code

function oa_export_file($file) {

  // This is the actual path to the file.
  $file_source = drupal_realpath($file->uri);

  // We only copy the file if it doesn't exist.
  if (!file_exists($_SESSION['oa_export']['files_directory'] . '/' . $file->filename)) {

    // Make sure the directory is the one we created.
    if (oa_export_validate_directory()) {

      // Copy the file to our export directory.
      $new_file = file_unmanaged_copy($file_source, $_SESSION['oa_export']['files_directory']);
      if (!$new_file) {

        // @todo: Throw error here.
      }
    }
  }
}