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.
Options

Skipping the edit button in a comment

edited August 2006 in Vanilla 1.0 Help
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?

Comments

  • Options
    I havn't look at it but if there no other way, you can extend the class and rewrite the function. http://lussumo.com/docs/doku.php?id=vanilla:development:objectfactory
  • Options
    The problem is that this delegation and the code that includes the 'edit' button are in the comments.php file of the default theme (included from the CommentGrid class).

    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?
  • Options
    Yep, and if you extend the render fonction (and so "comments.php"), you will break themes that have a custom "comments.php".

    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.
  • Options
    It doesn't sound nice.

    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!
This discussion has been closed.