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

Not PM on first discussion?

How do show "PM" on first discussion and hide "PM" to user login

Comments

  • Options
    hgtonighthgtonight ∞ · New Moderator

    What version of Vanilla are you running?

    Do you only want the link to show up in the first post in a discussion?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    my version: 2.1b1
    Yeah! I want show up to all discussion and comment but except to myself

  • Options
    hgtonighthgtonight ∞ · New Moderator

    Don't show a link to PM the logged in user. Got that

    Do you still want a PM link on every post? Or just the first post in each thread?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    Yes. Don't show a link to PM the logged in user. But I still want a PM link on every post

  • Options
    hgtonighthgtonight ∞ · New Moderator

    In /plugins/PM/class.pm.plugin.php add:

    $Session = Gdn::Session();
    if($Session->UserID == $Sender->EventArguments['Author']->UserID) {
      return;
    }
    

    right after public function DiscussionController_CommentInfo_Handler($Sender) {.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    Every thing allright! But don't show on first post.

  • Options
    peregrineperegrine MVP
    edited May 2013

    you have to add it to another event for the first discussion since the event it uses is not in the the first discussion, unfortunately! (nor is there a comparable one in the same position.

    e.g.

    you could add this to the plugin and pm should show up on first discussion.

    public function DiscussionController_DiscussionInfo_Handler($Sender) {
           $this->DiscussionController_CommentInfo_Handler($Sender);
        }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    peregrineperegrine MVP
    edited May 2013

    or if you don't like that.

    you could skip the above option and make this change andwould consistently be near authors name.

    public function DiscussionController_CommentInfo_Handler($Sender) {
    
    to
     // public function DiscussionController_CommentInfo_Handler($Sender) {
          
         public function DiscussionController_AuthorInfo_Handler($Sender) { 
    
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    @peregrine said:
    you have to add it to another event for the first discussion since the event it uses is not in the the first discussion, unfortunately! (nor is there a comparable one in the same position.

    e.g.

    you could add this to the plugin and pm should show up on first discussion.

    public function DiscussionController_DiscussionInfo_Handler($Sender) {
           $this->DiscussionController_CommentInfo_Handler($Sender);
        }
    

    Do put that code position?

  • Options
    peregrineperegrine MVP
    edited May 2013

    Do put that code position?

    does not compute???

    Do you mean where to put the code.

    you could put it above public function PluginController_PM_Create($Sender) {

    like so:

      public function DiscussionController_AuthorInfo_Handler($Sender) {
          $this->DiscussionController_CommentInfo_Handler($Sender);
        }
    
    
    
    
        public function PluginController_PM_Create($Sender) {
    

    I recommend just making the change below and not doing above (since PM would be consistently in the same place in both first discussion and the following comments. But either will work.

    public function DiscussionController_CommentInfo_Handler($Sender) {
    
    to
    // public function DiscussionController_CommentInfo_Handler($Sender) {
    public function DiscussionController_AuthorInfo_Handler($Sender) {
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    You can check to see if the event arguments are a discussion or not.

    In /plugins/PM/class.pm.plugin.php add:

    $Session = Gdn::Session();
    if($Session->UserID == $Sender->EventArguments['Author']->UserID || $Sender->EventArguments['Type'] == 'Discussion') {
      return;
    }
    

    right after public function DiscussionController_CommentInfo_Handler($Sender) {.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    peregrineperegrine MVP
    edited May 2013

    @hgtonight said:
    You can check to see if the event arguments are a discussion or not.

    In /plugins/PM/class.pm.plugin.php add:

    $Session = Gdn::Session();
    if($Session->UserID == $Sender->EventArguments['Author']->UserID || $Sender->EventArguments['Type'] == 'Discussion') {
      return;
    }
    

    right after public function DiscussionController_CommentInfo_Handler($Sender) {.

    How do show "PM" on first discussion and hide "PM" to user login

    @hgtonight

    You provided the solution hide "PM" to user login and mine solve the "How do show "PM" on first discussion".

    From what I gather he wants the PM to show in the Discussion (first item in thread).
    not prevent it.

    since
    public function DiscussionController_CommentInfo_Handler($Sender)
    will never be a discussion only a comment the only way to show PM in the discussion is with a different event as I indicated above AFAICT (as far as I can tell). but I'm open to proof of concept that proves me wrong :).

    He just needs to choose between changing the event for both and getting a consistent position or adding another event that calls the comment info handler.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    IF You want the PM link to only be on the first post and only if the first post author is not yourself, you can modify it to be:

    $Session = Gdn::Session();
    if($Session->UserID == $Sender->EventArguments['Author']->UserID || $Sender->EventArguments['Type'] == 'Comment') {
      return;
    }
    

    @peregrine It is important to note that a discussion starts with a single post of type Discussion and every post after that is of type Comment. Since the discussion controller deals with a discussion model, and discussion models can contain comments, you are able to filter based on the type.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    peregrineperegrine MVP
    edited May 2013

    He wants the PM on the first discussion and all comments - just not too show up when he is the author of comment or discussion. The way i interpret it.

    I think we have to agree to disagree - unless you make a change to the event - you will never see PM in the OP of the discussion thread. Because "DiscussionController_CommentInfo_Handler" does not exist as an event to fireupon in the first item of thread in Vanilla 2.1

    The model has nothing to do with it nor does the existence or lack of existence of the EventArguments, but it does matter upon the existence of the event to fire upon (which is not in the first item in thread"discussion" only in the comments (everything but first item in thread.).

    • Do you see a PM on the first discussion with your changes in vanilla 2.1b1?

    for me the answer is "No"

    • Do you see a PM on the first discussion with my changes in vanilla 2.1b1?

    for me the answer is "Yes"

    :) I think we have to agree to disagree on this one.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    @peregrine Honestly? I am confused. XD

    I am sure your setup works. :D

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    Yes, it doesn't help much that @onlyonelove hasn't responded since if it was resolved and which path he took or clearly explained what is desired. I went by "what was said" in the first item in the thread, but because @onlyonelove appears to be a non-native speaker of english the replies interspersed seem quite cryptic.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    AaronWebsteyAaronWebstey Headband Afficionado Cole Harbour, NS ✭✭✭
    edited February 2015

    FYI, I'm using this plugin now and it's killer with @hgtonight 's and @peregrine 's edits, combined with @vrijvlinder 's Custom ToolTip plugin. Attached image shows end result.

    Summary of my edits to class.pm.plugin.php:

    First I had to change Vanilla.Settings.Manage to Garden.Settings.Manageso I could access the plugin's settings. Then I deleted the line:

            $Text = 'Send {user} a Message';
    

    so that it would actually use the user-configured string.

    Finally, I changed the line

            echo Wrap(Anchor(T($Text), '/messages/add/' . $UserName), 'span', array('class' => 'PM'));
    

    to

            echo Anchor(Wrap(' ', 'span', array('class' => 'Sprite SpMessage', 'title' => T($Text))), '/messages/add/' . $UserName);
    

    so that it would show the PM link as an envelope icon.

    Then to make the links NOT show up for the logged-in user, and YES show up for the OP's message, I used @hgtonight 's and @peregrine 's suggestions as below.

    @hgtonight said:
    In /plugins/PM/class.pm.plugin.php add:

    $Session = Gdn::Session();
    if($Session->UserID == $Sender->EventArguments['Author']->UserID) {
      return;
    }
    

    right after public function DiscussionController_CommentInfo_Handler($Sender) {.

    @peregrine said:
    you could skip the above option and make this change andwould consistently be near authors name.

    public function DiscussionController_CommentInfo_Handler($Sender) {
    
    to
     // public function DiscussionController_CommentInfo_Handler($Sender) {
          
         public function DiscussionController_AuthorInfo_Handler($Sender) { 
    
    

Sign In or Register to comment.