HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Button misplaced or result in error (figured half solution out)

Vanilla 2.6.3 / 2.6.4

In default settings(not DropDown) the Kick-button is placed in the upper left corner(of the page not of the profile area) - but it works.
(Using Bootstrap-theme but have tested with +Baseline theme - same thing happens).

If set to DropDown the Message-button is replaced by a Kick-button which when used result in an error:
{"InformMessages":[{"Message":"You've kicked ass!","CssClass":"Dismissable AutoDismiss"}]}

There is also a Kick-option in dropdown which works.

Replacing line 115 in

/plugins/kick/class.kick.plugin.php
$sender->EventArguments['MemberOptions'][] = [

with
$sender->EventArguments['MemberOptions'][Kick] = [

will return the default Message-option, Kick-option is still in the dropdown and works.
Message-option is also in the dropdown and works.

Comments

  • R_JR_J Ex-Fanboy Munich Admin

    Honestly, you really want to use that? :wink:

    Thanks for the detailed feedback! It wasn't as easy to fix as I hoped.

    1. The way profile options can be added has changed "dramatically". While it is more comfortable to add an option to the message button or the profile options button now, there is no clean way to add an extra button. I had to override the view and that is something that I really do not like. It always feels like giving up and using the easiest but not elegant way.

    2a. When overriding the view, I wanted to do it as good as possible by adding some data to the module and simply adding one line to the view. Since I was doing all logic in the event that is fired to be able to extend the profile options, I assumed I would be able to access the module itself to add the data. But the event is fired as the controller and there is no way to access the module at this step.

    2b. Overriding the view wasn't hard and I added the line to add the markup for the new button to this method. But when doing the Gdn_Module->fetchViewLocation call, I had to find out that this doesn't work like the Gdn_Controller->fetchViewLocation.

    1. I changed the request from a GET call t a POST call and I was surprised to find out how easy that is. I guess the way I had implemented the user feedback before has been - well not false but poor. The way it is now is much better. No wonder that you were only seeing this json response...

    4a. When adding an element to the buttonGroup() created drop down button, the custom css class that you like to add to the new entry is give to the entry in the drop down list, but it is not applied to the button if your element is the first one and displayed as default. I had to add some Javascript in order to add the class that I needed here ("Hijack")

    4b. I really would have liked to see "Message" as the default button in this button group, but there is absolutely no way to change the order there. The only way n this case would have been to copy the UI element but I felt like that would have been out of scope... I really whish there would have been a third parameter possible in the buttonGroups $links parameter like "Position" with the options "Last" and "First". That would have been nice.


    You might wonder about the detailed feedback, but I was facing several surprising issues and I hope that if I want to do something with that part of the interface someday in the future I remember about this list :sunglasses:

    The bottom line is that I have overworked it and it should be fully functional now. You should delete the old files and delete /cache/addon.php since I have converted the PluginInfo to the new addon.json format and I've also renamed the plugins file name.

    If you experience a lag after pressing the "Kick" button and the feedback message, I suspect it is the because a mail is sent and it takes some time until that is done.

  • KasparKaspar Moderator

    Thank you for the quick response.

    I am not using it as a Kick =)
    (Have changed the wording, so it is more of a 'Poke')

    I will check out the updated version.

    I actally also wanted to have the button under every comment in discuss and have the notification include a link to the comment it was sent from(klicked at).

  • R_JR_J Ex-Fanboy Munich Admin

    If that poke feature should be some kind of "liked your comment and poked you therefore", you might be better of with YAGA which offers similar things like this Promote, Insightful, Awesome reactions you find here (which are created by a closed source plugin and YAGA aims to offer those features for the OS version.

    But if you still want to use the Kick plugin and you want to ehance it by a "John poked you after reading your comment in Discussion Name" I can give you some hints.

    Look at the quote plugin to see what must be done to add something to the bottom of discussion and comments. You will need to add a reference to the post in the link that you create. You can either start by yourself or take a look at the branch I threw together for that feature on the plugins repo on GitHub.

    After you have made it work from comments, you need to change the notification text. You will see that you can reference each part of the links url in "public function pluginController_kick_create($sender, $args) {" as $args[0], $args[1] and so on.

    You will have to tweak that part:

            $activityID = $activityModel->add(
                Gdn::session()->UserID, // ActivityUserID
                'Kick', // ActivityType
                '', // Story
                $profileUser->UserID, // RegardingUserID
                '', // CommentActivityID
                userUrl($profileUser), // Route
                '' // SendEmail
            );
    

    Based on the post type you will need different texts to send. There are several helper functions you might make use of. Look at functions.render.php where you will find discussionUrl and commentUrl.

    To get a comment object from its ID you need

    $postID = $args[2]; // this might vary based on the link schema you will use
    $commentModel = new CommentModel();
    $comment = $commentModel->getID($postID);
    

    Debugging might become hard since you cannot always echo values. I tend using Gdn::set('debug.WhateverPluginName.'.__LINE__, dbencode($args)); quite often right now. You will have to look into your database at the table UserMeta to find the result of that command after it has been run. If a line is called more than once, you can consider to add a ime stamp so that results get not overwritten. One advantage is that this can easily be cleaned with DELETE GDN_UserMeta WHERE Name LIKE 'debug%'

    Good luck!

  • KasparKaspar Moderator

    I have shortly tested the new version - seems ok.

    @R_J said:

    4b. I really would have liked to see "Message" as the default button in this button group, but there is absolutely no way to change the order there. The only way n this case would have been to copy the UI element but I felt like that would have been out of scope... I really whish there would have been a third parameter possible in the buttonGroups $links parameter like "Position" with the options "Last" and "First". That would have been nice.


    Changing line 107:
    from
    $args['MemberOptions'][] = [
    to
    $args['MemberOptions'][Kick] = [

    makes Message show as the default option, Kick option is in the dropdown.

    I have not had time to look at your other suggestions or YAGA - I did find "Reply" same night I posted this thread.
    Have just found https://open.vanillaforums.com/addon/yasendpm-plugin -

    Regarding YAGA - I assume you mean this
    https://open.vanillaforums.com/addon/yaga-application

    But
    "BrokenThe community says this is broken"

    I'll test it out.

Sign In or Register to comment.