Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Adding an option to comments

judgejjudgej
edited September 2010 in Vanilla 2.0 - 2.8
Each discussion and comment has list of options above it, provided by the helper function WriteOptionList() in applications/vanilla/views/discussion/helper_functions.php

Right at the end of that function, an event "CommentOptions" is fired to allow plugins to add their own options. That is hooked into using the custom method DiscussionController_CommentOptions_Handler(&$Sender) in your plugin.

Now, the helper function is called up once to display the discussion and once for each displayed comment. Each time, the function is passed the discussion or comment object. The problem is, the even that is fired does not get passed this information - it just gets passed the Sender object. This object contains everything, but does not identify which comment is being displayed, so the option echoed in the event handler can not set the option displayed relevant to the individual comments.

So, is there something I am missing, or is this really the way it is set up? Can or should helper functions be passed Sender by reference so that they can store their context in it (e.g. the current comment ID that they are processing)?

Or do I have to resort to replacing the helper function in my plugin? That would not be ideal, as the helper in the plugin can easily get left behind as the core helper is upgraded with Vanilla updates.

Any ideas of the best way to handle this, assuming I have been clear in trying to explain the problem?

Comments

  • Having posted that, I noticed the quotes module installed here and checked out how that identifies the comment for each option. It looks like the comment details are in $Sender->EventArguments each time the event is fired. I don't know how the comment details get in there, but they seem to.
Sign In or Register to comment.