diff -u b/includes/project_issue.json.inc b/includes/project_issue.json.inc --- b/includes/project_issue.json.inc +++ b/includes/project_issue.json.inc @@ -51,19 +51,6 @@ } $author->url = !empty($author->uid) ? url('user/' . $author->uid, $options) : NULL; - // Retrieve file attachments on the issue node. - // Does not contain attachments on comments. - // @see comment_upload_project_issue_json_alter() - $attachments = array(); - foreach ($issue->files as $fid => $file) { - // Attachments are keyed by comment ID. We treat the original issue node - // as post 0, so as to have all issue attachments in one property that can - // be processed by API consumers. - $attachments[0]['contributorId'] = $author->uid; - $attachments[0]['commentId'] = 0; - $attachments[0]['urls'][$fid] = file_create_url($file->filepath); - } - // Populate basic issue data. $return = array( // Increase minor version when adding information. @@ -92,9 +79,29 @@ 'projectTitle' => $project->title, 'projectUrl' => url('node/' . $project->nid, $options), 'projectName' => $project->project['uri'], - 'attachments' => $attachments, + 'contributors' => array(), + 'attachments' => array(), + ); + + // Add the issue author as contributor. + $return['contributors'][$author->uid] = array( + 'id' => $author->uid, + 'uid' => $author->uid, + 'name' => $author->name, + 'url' => $author->url, ); + // Add file attachments on the issue node (not comments). + // @see comment_upload_project_issue_json_alter() + foreach ($issue->files as $fid => $file) { + // Attachments are keyed by comment ID. We treat the original issue node + // as post 0, so as to have all issue attachments in one property that can + // be processed by API consumers. + $return['attachments'][0]['contributorId'] = $author->uid; + $return['attachments'][0]['commentId'] = 0; + $return['attachments'][0]['urls'][$fid] = file_create_url($file->filepath); + } + // Retrieve and populate comments and contributors (comment authors). $result = db_query("SELECT c.cid, c.pid, c.status, c.timestamp, c.thread, u.name, u.uid FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d AND c.status = %d ORDER BY c.cid ASC", $issue->nid, COMMENT_PUBLISHED); while ($row = db_fetch_object($result)) { @@ -102,12 +109,12 @@ 'id' => $row->uid, 'uid' => $row->uid, 'name' => $row->name, - 'url' => url('user/' . $row->uid, $options), + 'url' => !empty($row->uid) ? url('user/' . $row->uid, $options) : NULL, ); $return['comments'][$row->cid] = array( 'id' => $row->cid, 'contributorId' => $row->uid, - 'url' => url('node/' . $issue->nid, array('absolute' => TRUE, 'fragment' => 'comment-' . $row->cid)), + 'url' => url('node/' . $issue->nid, $options + array('fragment' => 'comment-' . $row->cid)), 'created' => $row->timestamp, 'status' => $row->status, 'parentId' => $row->pid,