You are here

function comment_upload_filefield_paths_update in File (Field) Paths 5

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

Implementation of hook_filefield_paths_batch_update().

File

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

Code

function comment_upload_filefield_paths_update($field_name, $type_name) {
  if (empty($field_name)) {
    $result = db_query("SELECT DISTINCT(cu.cid) FROM {comment_upload_files} cu LEFT JOIN {node} n\n      ON cu.nid = n.nid WHERE n.type = '%s'", $type_name);
    while ($data = db_fetch_object($result)) {
      $comment = _comment_load($data->cid);
      comment_invoke_comment($comment, 'view');

      // Flag files for update.
      if (isset($comment->files)) {
        foreach ($comment->files as $id => &$file) {
          $file = (array) $file;
          $file['fid'] = 'upload_' . $id;
        }
      }

      // Set Form ID.
      $comment->form_id = 'comment_form';

      // Process Comment.
      filefield_paths_comment((array) $comment, 'update');
    }
  }
}