Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Skipping the edit button in a comment
Hello to everybody!
I'm working on an add-on which needs to eliminate the possibility of editing your own comments if they contain some given strings in the body (except for administrators as usual).
I have already added a funtion to the DiscussionForm-PostLoadData delagation to prevent editing when the blocking condition is true. It adds a warning and sets FatalError to 1, and it works.
But now, I think it would be nice to eliminate the "edit" button for those selected comments. I have done a dirty trick: I have added a function to the CommentGrid-PreCommentOptionRender delegation which tests the condition and, if it is true, it changes the AuthorID to -1. This produces a fail in the permissions check and the edit button dissapears.
Question: Is there a cleaner way to achieve this?
I'm working on an add-on which needs to eliminate the possibility of editing your own comments if they contain some given strings in the body (except for administrators as usual).
I have already added a funtion to the DiscussionForm-PostLoadData delagation to prevent editing when the blocking condition is true. It adds a warning and sets FatalError to 1, and it works.
But now, I think it would be nice to eliminate the "edit" button for those selected comments. I have done a dirty trick: I have added a function to the CommentGrid-PreCommentOptionRender delegation which tests the condition and, if it is true, it changes the AuthorID to -1. This produces a fail in the permissions check and the edit button dissapears.
Question: Is there a cleaner way to achieve this?
0
This discussion has been closed.
Comments
If I would rewrite the class I would need to include the content of the whole comments.php file into my code to make the small change, wouldn't I?
If you need to change something in a template and that a new delegation can't help... well... you still can add a new comments.php to put in the theme folder of the user.
I think I will keep with the dirty trick. As far as I know changing the AuthorID in the comment data during the PreCommentOptionRender delegation does not have side effects. In the worst case, if something arises, I could restore the original value in the PostCommentOptionRender delegation.
Thanks!