diff -u b/project_issue.module b/project_issue.module --- b/project_issue.module +++ b/project_issue.module @@ -1517,9 +1517,8 @@ if (!module_exists('comment_easy_reply')) { $uri = entity_uri('comment', $comment); $uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark')); - - // Use the thread as the link text for comment number. Replace the permalink. - $thread = implode('.', array_map('vancode2int', explode('.', substr($comment->thread, 0, -1)))); + // Use the thread as the link text for comment number. + $thread = project_issue_get_comment_thread_id($comment); $variables['permalink'] = l('#' . $thread, $uri['path'], $uri['options']); } @@ -1531,6 +1530,21 @@ } /** + * Return the thread identifier for a given comment. + * + * @param stdObj $comment + * A fully-loaded comment entity object, as returned by comment_load(). + * + * @return string + * The sequential thread ID for the comment in a given issue. This is the + * per-issue human-readable sequential comment number, starting from 1, not + * the site-wide unique comment ID. + */ +function project_issue_get_comment_thread_id($comment) { + return implode('.', array_map('vancode2int', explode('.', substr($comment->thread, 0, -1)))); +} + +/** * @defgroup project_issue_solr Project Issue ApacheSolr integration * @{ */ @@ -1823,7 +1837,7 @@ 'cid' => array( 'title' => t('Comment ID'), 'sort' => 'numeric', - 'formatter' => 'project_issue_generate_cid_jumplink', + 'formatter' => 'project_issue_generate_file_jumplink', ), ); } @@ -1984,20 +1998,23 @@ * the instance definition. Notable keys include the name of the formatter * (in 'type') and the array of formatter settings (in 'settings'). * - * @return array or string - * A render array defining the table cell contents for this file/metadata - * combination, or alternatively an html string defining the actual rendered - * output. + * @return string + * The HTML string for a "jumplink" to the place where a given file was + * attached to an issue. Generally, this will link to the comment that was + * auto-generated when an issue was attached, although for files attached to + * the initial revision of an issue this will just link to the node body. */ -function project_issue_generate_cid_jumplink($item, $context) { +function project_issue_generate_file_jumplink($file, $context) { // Generate formatted 'Comment ID' jumplinks for a file, based on the 'cid' // metadata property. $entity = $context['entity']; - if (empty($item['cid'])) { + if (empty($file['cid'])) { $data = l('none', 'node/' . $entity->nid, array('fragment' => 'content')); } else { - $data = l('#' . comment_get_display_ordinal($item['cid'], $entity->type), 'node/' . $entity->nid, array('fragment' => 'comment-' . $item['cid'])); + $comment = comment_load($file['cid']); + $thread = project_issue_get_comment_thread_id($comment); + $data = l('#' . $thread, 'node/' . $entity->nid, array('fragment' => 'comment-' . $file['cid'])); } return $data; }