Would it be an idea to move these lines of code from the comment_view hook to the comment_load hook?

    $comment->subject = t('Comment was hidden');
    $comment->content['comment_body'][0]['#markup'] = '<em>' . $reason . '</em>';
    $comment->hidden_comment = TRUE;

at least the last line would be good. We noticed, when using the services API there is no way to tell wether an comment is hidden or not.

Comments

batje’s picture

Status: Active » Closed (won't fix)

OK, got it. comment_load is not a hook, and the services module does not call comment_view (the only function that alters comments) because they want to support only core, as described in this issue.

jcisio’s picture

Status: Closed (won't fix) » Active

I do think it's a good idea to put $comment->hidden_comment = TRUE; in hook_comment_load() in D7 version. It causes overhead, however we don't care, for the flexibility. And it'll work with Services.

Could you test then submit a patch?

batje’s picture

Status: Active » Needs review
StatusFileSize
new1.28 KB

this seems to work. not entirely sure if we should touch both value and safe_value.

jcisio’s picture

Status: Needs review » Needs work

I don't think we want to change the comment subject/content on load (information loss). We just need to tell that comment is hidden.

batje’s picture

If we dont, then you leave a lot of responsibility to the display layer. Its not gone, you just have to unhide the comment to see the values again, not so?

batje’s picture

We could stick the original content in a separate attribute?

jcisio’s picture

I mean, if someone uses comment_load($cid) he can't get the origin content. It's not the expected behavior.

- When loading, we *ADD* content to the entity.
- When viewing, we use the content to *DISPLAY* what we want.

So, I think in comment_load, we add $comment->hidden_comment (TRUE | FALSE) and $comment->hidden_comment_attributes (if comment is hidden).

batje’s picture

StatusFileSize
new1.21 KB

Like this?

jcisio’s picture

Status: Needs work » Needs review
StatusFileSize
new2.16 KB

Please test this one. There is also a clean up.

jcisio’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.