You are here

function comment_upload_fetch_all in Comment Upload 6

Retrieve all files attached to a given node.

Parameters

$nid: A node ID.

$include_unpublished: If TRUE, return all attached files; if FALSE, only return files attached to published comments.

Return value

resource A database result resource or FALSE if the query fails.

2 calls to comment_upload_fetch_all()
comment_upload_nodeapi in ./comment_upload.module
comment_upload_project_issue_json_alter in ./comment_upload.module

File

./comment_upload.module, line 219
Provides file attachment functionality for comments.

Code

function comment_upload_fetch_all($nid, $include_unpublished = FALSE) {
  $order_by = 'ORDER BY cu.cid ASC, fid ASC';
  $q = "SELECT cu.fid, cu.nid, cu.cid, f.filepath, c.status, c.thread, u.uid, u.name  FROM {comment_upload} cu INNER JOIN {files} f ON cu.fid = f.fid INNER JOIN {comments} c ON cu.cid = c.cid INNER JOIN {users} u ON c.uid = u.uid WHERE cu.nid = %d";
  if ($include_unpublished) {
    return db_query("{$q} {$order_by}", $nid);
  }
  else {
    return db_query("{$q} AND c.status = %d {$order_by}", $nid, COMMENT_PUBLISHED);
  }
}