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.

Who Liked...

Thanks for this plugin. I was trying to see if I could modify it so that it would add the names of all who liked it, like the Thankful People plugin. I haven't looked too much into it yet, but any advice where to start?

«1

Comments

  • hbfhbf wiki guy? MVP

    who liked what post is in the AllLikes table, listed by discussion, comment and userID

    a little bit of fun with joins and you have your information.

  • It's close, but it's still missing the like button vs just a like link & the total number of likes on each discussion.

  • modification wise @ElatedMonk i think zlike is nearest. if you purchase that plugin you can write an email to the developer and he might help. @Aolee

  • @hbf We added this function to the plugin on our site.

    If your interested:

    http://pastebin.com/NYZg6L7D

  • Somebody didn't see the expiration on put on the pastebin I sent them :)

    http://pastebin.com/8HDE0vxs

    The important parts are the functions at lines 73, and 275

  • hbfhbf wiki guy? MVP

    sorry, i dont have time to run a diff right now. what function did you add?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I think this is what they added

    // This method gets called before the Render method gets called on the DiscussionsController object.
                    $Discussion = $Args['Discussion'];
                    $ID = $Discussion->DiscussionID;
                    $Likes = $this->LikeModel->GetTotalDiscussionLikes($ID);
                    $CountLikes =  count($Likes);
                    if($CountLikes){
                            $Userlist = '';
                            foreach ($Likes as $value) {
                                    $UserModel = new UserModel();
                                    $User = $UserModel->GetID($value);
                                    $Userlist .= $User->Name . ', ';
                            }
                            $Src .= '' .$CountLikes. sprintf($CountLikes>1?T(' Likes'):T(' Like')).' ';
                            echo $Src;
                    }
        }
    

    and

     public function FormatLikes($Likes, $Url, $UID, $Self)
            {
            $CountLikes = count($Likes);
            $Src = '';
                    $Userlist = '';
                    if($CountLikes) {
                            foreach ($Likes as $value) {
                                    $UserModel = new UserModel();
                                    $User = $UserModel->GetID($value);
                                    $Userlist .= $User->Name . ', ';
                            }
                           
  • hbfhbf wiki guy? MVP

    ok, i'll test it out and determine if it's ready to go.

  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP

    If it's getting implemented On/Off option would be great to have i the backend. :)

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited June 2013

    @phreak said:
    If it's getting implemented On/Off option would be great to have i the backend. :)

    Or you could also clone the plugin rename it Who Liked and then enable or disable either one from the dashboard when you want to. one version would have the who done it, and the other not.

  • peregrineperegrine MVP
    edited June 2013

    you could add this to default.php for photos of who liked in comments and discussions
    kind of like the user reactions here. you could add a sprite overlay if you wanted.

    public function DiscussionController_AfterCommentBody_Handler($Sender)
        {
            if ($Sender->EventArguments['Type'] == 'Discussion') 
            {
                $DiscussionID = $Sender->EventArguments['Discussion']->DiscussionID;
                if ($Sender->Data['Comments'] instanceof Gdn_DataSet)
                    $this->LikeModel->PreloadLikes($Sender->Data['Comments']);
                $ID = $DiscussionID;
                $Model = new DiscussionModel();
                $Data = $Model->GetID($ID);
                $Likes = $this->LikeModel->GetDiscussionLikes($ID);
            }
            else
            {
                $DiscussionID = $Sender->EventArguments['Object']->DiscussionID;
                $ID = $Sender->EventArguments['Object']->CommentID;
                $Model = new CommentModel();
                $Data = $Model->GetID($ID);
                $Likes = $this->LikeModel->GetCommentLikes($ID);
                $Url = $DiscussionID . '/comment/' . $ID;
            }   
    
          foreach($Likes as $val) {
                $Reactor = Gdn::UserModel()->GetID($val);
                $photo = UserPhoto($Reactor,array('ImageClass' => 'ProfilePhotoSmall'));
                 echo '<span class="URWrap">';
                if($photo) {
                    echo $photo;
                   } else {
                   echo UserAnchor($Reactor);
                } 
                echo '<span class="RSprite"></span>';
                 echo '</span>';
                }
    
        }
    

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

  • peregrineperegrine MVP
    edited June 2013

    or in 2.1

    
    public function DiscussionController_AfterReactions_Handler($Sender)
        
                {
            if ($Sender->EventArguments['Type'] == 'Discussion') 
            {
                $DiscussionID = $Sender->EventArguments['Discussion']->DiscussionID;
                if ($Sender->Data['Comments'] instanceof Gdn_DataSet)
                    $this->LikeModel->PreloadLikes($Sender->Data['Comments']);
                $ID = $DiscussionID;
                $Model = new DiscussionModel();
                $Data = $Model->GetID($ID);
                $Likes = $this->LikeModel->GetDiscussionLikes($ID);
            }
            else
            {
                $DiscussionID = $Sender->EventArguments['Object']->DiscussionID;
                $ID = $Sender->EventArguments['Object']->CommentID;
                $Model = new CommentModel();
                $Data = $Model->GetID($ID);
                $Likes = $this->LikeModel->GetCommentLikes($ID);
                $Url = $DiscussionID . '/comment/' . $ID;
            }   
                
          foreach($Likes as $val) {
                $Reactor = Gdn::UserModel()->GetID($val);
                $photo = UserPhoto($Reactor,array('ImageClass' => 'ProfilePhotoSmall'));
                 echo '';
                if($photo) {
                    echo $photo;
                   } else {
                   echo UserAnchor($Reactor);
                } 
                echo '';
                 echo '';
                }
        
        }
    
    

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

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Super Coder P Strikes Again!!!

    That is great @peregrine

  • hbfhbf wiki guy? MVP

    @phreak said:
    If it's getting implemented On/Off option would be great to have i the backend. :)

    yes, having a setting would be the right way to go.

  • hbfhbf wiki guy? MVP

    @vrijvlinder said:
    Or you could also clone the plugin rename it Who Liked and then enable or disable either one > from the dashboard when you want to. one version would have the who done it, and the other > not

    the day i find one of my plugins forked without my express permission will be the last day you ever see me here.

  • hbfhbf wiki guy? MVP

    @peregrine said:
    or in 2.1

    any idea how to make the plugin selectively choose the method depending on what version of the framework it's running in? I'd hate to maintain two separate branches.

  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP

    "the day i find one of my plugins forked without my express permission will be the last day you ever see me here."

    Naah, i hope you don't mean that serious. Remember my stolen plugins of VanillaSkins and the stupid situation they were in the official repository. This damn thing can happen in this situation here. :/

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • hbfhbf wiki guy? MVP

    @phreak said:
    Naah, i hope you don't mean that serious. Remember my stolen plugins of VanillaSkins and the stupid situation they were in the official repository. This damn thing can happen in this situation here. :/

    yes, i remember reading that discussion. I also remember V getting on a soap box in there on the subject. yet, i've seen her recommend forking my plugins or other such nonsense a couple times now.

    i have a zero tolerance for that sort of thing. so if i believed this community supported that behavior, i'd be gone.

  • hgtonighthgtonight ∞ · New Moderator

    @hbf said:
    any idea how to make the plugin selectively choose the method depending on what version of the framework it's running in? I'd hate to maintain two separate branches.

    You could compare against the APPLICATION_VERSION.

    You could also just use both hooks and don't execute in the thing has been executed once.

    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.

Sign In or Register to comment.