Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

In this Discussion

Would it be possible to send a notification when an answer has been Accepted or Rejected?

edited August 2012 in Feedback
This discussion is related to the Q&A addon.

As per subject, my client would like Users to receive a notification when their answers are accepted or rejected. I had a look at the plugin, and I see that it calls AddActivity when an answer is accepted. Would it be possible to do the same when an answer is rejected?

Also, would it be possible to make these notifications optional, the same way it's done with others (e.g Notify me when people write on my wall) ?

UnderDog

Comments

  • Update: after making some experiments, I think I achieved what I wanted. It was simpler than I thought, just a handful of lines of code.

    May I submit the changes for review, and eventually have them added to the main plugin? They don't interfere with main logic, and I believe other people could use them. Thanks.

    UnderDogphreak
  • mcu_hqmcu_hq ✭✭
    edited August 2012

    I don't see why not...try issuing a pull request here and see if they accept it.

    https://github.com/vanillaforums/Addons/tree/master/plugins/QnA

  • @mcu_hq Thanks, I was looking for that! Time to refresh mi Git skills.

  • ToddTodd Chief Product Officer vanilla

    We do love accepting pull requests. Sending an email upon answer rejection is something that would need a config option since most people aren't supposed to know their answer has been rejected.

    UnderDog
  • @Todd Thanks, I'm issuing a Pull Request right now. I haven't thought about a global configuration setting for notifications, therefore my update only allows Users to choose if they want to receive the notification.

    UnderDog
  • How can I remove all notifications related to this plugin (i.e. when an answer is accepted - don't send any email). I've looked through the https://github.com/vanillaforums/Addons/tree/master/plugins/QnA but couldn't find anything related to this.

    Also, would it be possible to make these notifications optional, the same way it's done with others (e.g Notify me when people write on my wall) ?

    My screenshot below doesn't list these as available options, not sure if I'm just doing something wrong. I'm hoping this could be as easy as just writing a $Configuration string.

    Q& A prefs

  • How can I remove all notifications related to this plugin (i.e. when an answer is accepted - don't send any email). I've looked through the https://github.com/vanillaforums/Addons/tree/master/plugins/QnA but couldn't find anything related to this.

    you would have to change the plugin

    comment out

    $Sender->InformMessage


    factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!

    Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant

    UnderDogkirkpa31
  • Thank You! I just didn't know where to look.

  • Unfortunately the two related code strings I can find with what you've mentioned are:

    static $InformMessage = TRUE; if ($InformMessage && Gdn::Session()->UserID == GetValue('InsertUserID', $Discussion) && in_array(GetValue('QnA', $Discussion), array('', 'Answered'))) { $Sender->InformMessage(T('Click accept or reject beside an answer.'), 'Dismissable'); $InformMessage = FALSE;

    and

    $Count = Gdn::SQL()->GetCount('Discussion', array('Type' => 'Question', 'InsertUserID' => Gdn::Session()->UserID, 'QnA' => 'Answered')); if ($Count > 0) { $Sender->InformMessage(FormatString(T("You've asked questions that have now been answered", "<a href=\"{/discussions/mine?qna=Answered,url}\">You've asked questions that now have answers</a>. Make sure you accept/reject the answers.")), 'Dismissable'); } }

    When altering these (i.e. changing from TRUE to FALSE, this only disables the popups that this command prompts. I'll keep looking around the plugin to see where to disable this email notification.

  • peregrineperegrine MVP
    edited March 30

    I thought thats what you wanted notification messages. You probably have to block email when it gets written to activity. I'll see if I can find it.


    factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!

    Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant

    kirkpa31
  • kirkpa31kirkpa31 ✭✭
    edited March 30

    well changing

    // Record the activity. if ($QnA == 'Accepted') { AddActivity( Gdn::Session()->UserID, 'AnswerAccepted', Anchor(Gdn_Format::Text($Discussion['Name']), "/discussion/{$Discussion['DiscussionID']}/".Gdn_Format::Url($Discussion['Name'])), $Comment['InsertUserID'], "/discussion/comment/{$Comment['CommentID']}/#Comment_{$Comment['CommentID']}", TRUE ); } }

    from TRUE to FALSE disables email notifications while not disabling the popups on the page, but it also disables non-email notifications within the forum itself. No activity is recorded on the profile page of the user, but that appears to be the only way to disable email that I can see. Thank you @peregrine your comment about blocking it while it gets written to activity helped me find this.

    peregrinehgtonight
  • peregrineperegrine MVP
    edited March 30

    @kirkpa31 said: well changing

    // Record the activity. if ($QnA == 'Accepted') { AddActivity( Gdn::Session()->UserID, 'AnswerAccepted', Anchor(Gdn_Format::Text($Discussion['Name']), "/discussion/{$Discussion['DiscussionID']}/".Gdn_Format::Url($Discussion['Name'])), $Comment['InsertUserID'], "/discussion/comment/{$Comment['CommentID']}/#Comment_{$Comment['CommentID']}", TRUE ); } }

    from TRUE to FALSE disables email notifications while not disabling the popups on the page, but it also disables non-email notifications within the forum itself. No activity is recorded on the profile page of the user, but that appears to be the only way to disable email that I can see. Thank you peregrine your comment about blocking it while it gets written to activity helped me find this.

    glad you found it, saved me time looking :)


    factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!

    Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant

    kirkpa31
  • edited April 9

    from TRUE to FALSE disables email notifications while not disabling the popups on the page, but it also disables non-email notifications within the forum itself. No activity is recorded on the profile page of the user, but that appears to be the only way to disable email that I can see

    Ok - I see the logic - But it has to be possible to be able to disable EMAIL notifications while not disabling Notifications WITHIN the forum (i.e. still have them show up under the "Notifications" tab in the profile page)

    This method prevents the acceptance from being recorded to activity - therefore disabling any notification associated w/ it.

  • edited April 9

    May I submit the changes for review, and eventually have them added to the main plugin? They don't interfere with main logic, and I believe other people could use them. Thanks.

    Thanks, I'm issuing a Pull Request right now. I haven't thought about a global configuration setting for notifications, therefore my update only allows Users to choose if they want to receive the notification.

    @businessdad - I know this was awhile ago but this current plugin does not give this option. Do you know what happened? How to give users the option to receive notifications for accepted answers?

  • @chrisk22985 said: businessdad - I know this was awhile ago but this current plugin does not give this option. Do you know what happened? How to give users the option to receive notifications for accepted answers?

    I don't think that my changes were ever pulled into the main repository. You can have a look at my forked repository to see the changes. Just keep in mind that they were not made against the latest master, but against the latest version which was still compatible with Vanilla 2.0 (branch name is Working_with_Vanilla_2.0.18.x).

    kirkpa31
  • kirkpa31kirkpa31 ✭✭
    edited April 9

    Well I suppose my solution did just remove the notification altogether.

    I think there is something overall buggy with notifications. I might just hide them in css for my forum.

  • kirkpa31kirkpa31 ✭✭
    edited April 14

    @chrisk22985

    I'm assuming that you could achieve a solution to your email problem by adding a string within your config.php file

    something along the lines of:

    $Configuration['Preferences']['Email']['BookmarkComment']       = '1';
    $Configuration['Preferences']['Email']['WallComment']           = '0';
    $Configuration['Preferences']['Email']['ActivityComment']       = '0';
    $Configuration['Preferences']['Email']['DiscussionComment']     = '0';
    

    only for your Q&A plugin, so maybe,

    $Configuration['Preferences']['Email']['Q&A Accepted'] = '0';

    I can look into this, probably just by playing around with different combinations of words until something works - may take awhile - I suggest you keep playing with it too.

    EDIT

    And I see you've been active on this page as well

    http://vanillaforums.org/discussion/23411/email-notifications-going-crazy#latest

    so if you decide to work on this yourself instead of contracting out, I wish you well!

  • Having no luck taking the config.php route. Every test the user still receives an email notification.

  • @kirkpa31 You could search the source code for 'Preferences.Email' and it will list out all the different configurations used.

    No need to guess

    Search first.
    React to insightful, awesome, funny, and off-topic posts.
    Check out the Wiki for lots of information about common stumbling blocks.

  • @hgtonight

    @vrijvlinder made a list of everything that sends notifications in this post: http://vanillaforums.org/discussion/comment/179988/#Comment_179988 but the Q&A plugin is not referenced here, hence my need to guess.

  • @kirkpa31

    I just mean that you can quickly find all the configurations referenced by searching the source code files. Configurations are checked in code by C('FirstBox.SecondBox.ThirdBox.Etc', 'Default Value');

    Search first.
    React to insightful, awesome, funny, and off-topic posts.
    Check out the Wiki for lots of information about common stumbling blocks.

    kirkpa31
  • Ahhh thank you! I will use your advice to change my attempt.

  • peregrineperegrine MVP
    edited April 14

    @kirkpa31

    You can either join the "cargo cult guessing game school of red herrings" by guessing configs, definitions, and events or you can do what @hgtonight said (which is the correct way to go imo, and hgtonight will put your train back on the proper track.). It will keep you from trying non-existent configs and nonsensical suggestions.

    @hgtonight said

    @kirkpa31 You could search the source code for 'Preferences.Email' and it will list out all the different configurations used.

    No need to guess

    some configs can't be found by searching for C( but the link below shows other options for finding all configs.

    @kirkpa31

    this will get you on the path to enlightenment and away from the dark side of mysticism, crystal ball and red herrings.

    http://vanillaforums.org/discussion/comment/171978/#Comment_171978


    factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!

    Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant

    kirkpa31
  • If I don't reply back in the next couple of days, know that it is b/c I've drowned in the source code. But at least now I know what direction land is in, so I will use your advice and start a new trek.

    Thanks guys!

  • kirkpa31kirkpa31 ✭✭
    edited April 15

    !!! I think I solved it !!! - in all my tests this works - i.e. other notifications are still emailed to the user when they select that particular preference - but if anyone sees something that may cause this to mess up other notifications that I'm currently overseeing, please chime in.

    could not get a config.php solution

    within /applications/dashboard/models/class.activitymodel.php

    EDIT

    Changed the word 'Force' in the first part of the if else statement to '' around line 477:

          // Send a notification to the user.
          if ($Notify) {
             if ($QueueEmail)
                $this->QueueNotification($ActivityID, $Story, 'last', $SendEmail == 'Force');
             else
                $this->SendNotification($ActivityID, $Story, $SendEmail == 'Force');
          }
    
          return $ActivityID;
       }
    

    to:

          // Send a notification to the user.
          if ($Notify) {
             if ($QueueEmail)
                $this->QueueNotification($ActivityID, $Story, 'last', $SendEmail == '');
             else
                $this->SendNotification($ActivityID, $Story, $SendEmail == 'Force');
          }
    
          return $ActivityID;
       }
    

    @peregrine I tried to employ a half educated-guessing and half red-herring methodology for this - my specialty

    Utilizing Vanilla V. 2.0.18.8

    peregrinechrisk22985UnderDogvrijvlinder
  • kirkpa31

    It's not a red herring if you tested and it works. nice work! I don't use the plugin, but I'm sure this may help others if it works as you say it does.


    factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!

    Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant

    kirkpa31
  • Oh I'm happy I signed on this morning to see this! Thank you @kirkpa31!!!!

    UnderDog
  • This is what I like to see, people asking for help but still try to do it themselves, makes me proud! @kirkpa31 Congratulations

    UnderDogkirkpa31
Sign In or Register to comment.