diff --git a/comment_upload.module b/comment_upload.module
index 4cb9ca0..942d200 100644
--- a/comment_upload.module
+++ b/comment_upload.module
@@ -194,6 +194,35 @@ function comment_upload_file_download($filepath) {
   }
 }
 
+function comment_upload_project_issue_json_alter(&$issue) {
+  $result = comment_upload_fetch_all($issue['id'], FALSE);
+  while ($row = db_fetch_object($result)) {
+    $issue['attachments'][$row->cid]['contributor'] = $row->uid;
+    $issue['attachments'][$row->cid]['comment-id'] = $row->cid;
+    $issue['attachments'][$row->cid]['urls'][$row->fid] = file_create_url($row->filepath);
+  }
+}
+
+/**
+ * Retrieve all files attached to a given node.
+ *
+ * @param $nid
+ *   A node ID.
+ * @param $include_unpublished
+ *   If TRUE, return all nodes; if FALSE, only return nodes where status == COMMENT_PUBLISHED
+ * @return resource
+ *   A database result resource or FALSE if the query fails.
+ */
+function comment_upload_fetch_all($nid, $include_unpublished = TRUE) {
+  $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 cu.cid ASC, fid ASC", $nid);
+  }
+  else {
+    return db_query("$q AND c.status = %d ORDER BY cu.cid ASC, fid ASC", $nid, COMMENT_PUBLISHED);
+  }
+}
+
 /*
  * Listen to node deletion and delete files from comments on that node.
  *
@@ -203,7 +232,7 @@ function comment_upload_file_download($filepath) {
  */
 function comment_upload_nodeapi(&$node, $op, $arg = 0) {
   if ($op == 'delete') {
-    $result = db_query("SELECT cu.fid, cu.nid, f.filepath FROM {comment_upload} cu INNER JOIN {files} f ON cu.fid = f.fid WHERE cu.nid = %d", $node->nid);
+    $result = comment_upload_fetch_all($node->nid);
     while ($row = db_fetch_array($result)) {
       // comment_upload_delete_file just needs a filepath and a fid.
       comment_upload_delete_file($row);
@@ -667,4 +696,4 @@ function template_preprocess_comment_upload_attachments(&$variables) {
       }
     }
   }
-}
\ No newline at end of file
+}
