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.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 1566794-support-comment_load-9.patch | 2.16 KB | jcisio |
| #8 | hide_comment_onload_1566794-8.patch | 1.21 KB | batje |
| #3 | hide_comment_onload_1566794-3.patch | 1.28 KB | batje |
Comments
Comment #1
batje commentedOK, 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.
Comment #2
jcisio commentedI 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?
Comment #3
batje commentedthis seems to work. not entirely sure if we should touch both value and safe_value.
Comment #4
jcisio commentedI don't think we want to change the comment subject/content on load (information loss). We just need to tell that comment is hidden.
Comment #5
batje commentedIf 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?
Comment #6
batje commentedWe could stick the original content in a separate attribute?
Comment #7
jcisio commentedI 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).
Comment #8
batje commentedLike this?
Comment #9
jcisio commentedPlease test this one. There is also a clean up.
Comment #10
jcisio commented