The access function comment_og_comment_view_alter() seems to overwrite the comment links, which prevents compatibility with other modules that also modify the comment links (ie. ajax_comments adding classes).

Since the function is largely lifted from comment_links, I suggest loading the links in and modifying the values accordingly.

$links = array();

to:

$links = $build['links']['comment']['#links'];

Comments

firewaller created an issue. See original summary.

firewaller’s picture

formatC'vt’s picture

Status: Active » Needs review
firewaller’s picture

StatusFileSize
new3.1 KB

The above patch resulted in the following error when using another module (Authcache) which also modifies the comment links:

Notice: Undefined index: title in theme_links() (line 1828 of /includes/theme.inc).

I rewrote the above patch to check for the existing link key before rebuilding the array values.

shaundychko’s picture

Maybe I'm missing something, but the patches above seem to do too much by removing the title key from each of the links array. That results in the "Undefined index" error mentioned in comment #4.

Attached is a patch which does only one thing: collect existing links into the $links array before adding new ones. This makes compatibility with the Quote module, which adds it's own link to comments.

firewaller’s picture

StatusFileSize
new4.7 KB

@ShaunDychko the overwriting of the keys was what initially prompted me to post this issue. (ie. classes key overwritten: https://www.drupal.org/node/1856350#comment-10606780

However, I do see how in some cases the 'title' and 'html' keys might not exist to begin with and throw errors like the one you're seeing.

Attached is an updated patch which includes the changes from your patch and improves upon my previous patches to check for existing keys before inserting values.

hoang027’s picture

For interacting with ajax_comments module (where ajax classes are overwritten by this or another comment-related module), the easiest solution for me is to set the weight of ajax_comments module bigger in the "system" table (e.g. change from 0 to 99) so that the AJAX always run last to add its own HTML classes.

The ajax_comments module already has some codes to take into account the access/permissions of other modules, but not for comment_og yet. In its ajax_comment_menu() function, I had to add this code (it already checked for modules 'comment_goodness' and 'commentaccess'):

if (module_exists('comment_og')) {
    $items['ajax_comment/%/delete']['access callback'] = 'comment_og_access';
    $items['ajax_comment/%/delete']['access arguments'] = array('delete', 1, 3);
}

Also, when putting variables inside a quoted string, please enclose them with curly braces to avoid potential bug (it's a good practice anyway):
"comment/$comment->cid/delete/$group->gid" should be "comment/{$comment->cid}/delete/{$group->gid}"

And og_context() now returns an array so $group->gid should be $group['gid']