You are here

function filefield_paths_node_presave in File (Field) Paths 6

Implements hook_node_presave().

File

./filefield_paths.module, line 350
Contains core functions for the FileField Paths module.

Code

function filefield_paths_node_presave(&$node) {
  if (module_exists('content')) {
    $content_type = content_types($node->type);
    foreach ($content_type['fields'] as $field) {
      if ($field['type'] == 'filefield' && is_array($node->{$field}['field_name'])) {
        foreach ($node->{$field}['field_name'] as $count => &$file) {
          if (!is_array($file) || empty($file['filepath'])) {
            continue;
          }

          // If file is newly uploaded, flag to be processed
          if ($file['status'] == 0) {
            $file['data']['process'] = TRUE;
          }
        }
      }
    }
  }
}