You are here

function filefield_paths_comment in File (Field) Paths 5

Same name and namespace in other branches
  1. 6 modules/comment_upload.inc \filefield_paths_comment()

Implementation of hook_comment().

1 call to filefield_paths_comment()
comment_upload_filefield_paths_update in modules/comment_upload.inc
Implementation of hook_filefield_paths_batch_update().

File

modules/comment_upload.inc, line 106
Provides FileField Paths integration with the Comment Upload module.

Code

function filefield_paths_comment($a1, $op) {
  switch ($op) {
    case 'insert':
    case 'update':
      $update = new stdClass();
      $update->node = FALSE;
      $node = node_load($a1['nid']);
      $object = new stdClass();
      $object->form_id = $a1['form_id'];
      $object->type = $node->type;
      $object->files = $a1['files'];
      $object->processed_files = _comment_upload_load_files($a1['cid']);
      $object->cid = $a1['cid'];
      if (($ffp = filefield_paths_get_fields($object)) == FALSE) {
        break;
      }

      // Process files
      foreach ($ffp['#files'] as &$file) {
        module_invoke_all('filefield_paths_process_file', $file['new'], $file, $ffp['#settings'][$file['name']], $node, $update);
        if ($file['new'] == TRUE) {
          db_query("UPDATE {comment_upload_files} SET filename = '%s', filepath = '%s' WHERE fid = %d", $file['field']['filename'], $file['field']['filepath'], $file['field']['fid']);
        }
      }
      break;
  }
}