Howdy, Stranger!

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

Try Vanilla Forums Cloud product
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

Who Liked...

This discussion is related to the I Like This ( Plugin ) addon.

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?

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.

    businessdadhgtonight
  • 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?

    UnderDog
  • 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 . ', ';
                            }
                           
    hgtonight
  • phreakphreak VanillaAPP - White label iOS and Android App MVP

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

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

    vrijvlinder
  • peregrineperegrine MVP
    edited June 2013

    or in 2.1

    </p> <pre> 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 '<span class="URWrap">'; if($photo) { echo $photo; } else { echo UserAnchor($Reactor); } echo '<span class="RSprite"></span>'; echo '</span>'; } } </pre> <p>

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

    vrijvlinderphreak
  • 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 VanillaAPP - White label iOS and Android App 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. :/

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

    phreak
  • 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.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

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

    You misunderstood, I never said to fork it and upload it as a new plugin, I meant it as personal use. Not to distribute. I have never recommended to anyone to clone something without permission and upload it. I do resent the accusation .
    My comments to phreak about this plugin were tongue in cheek . I see no harm in modifying something for personal use. Is modifying a plugin for personal use wrong, is it forbidden ?
    I was under the impression that one could do this for oneself. Not to distribute but for personal use.

    I think I have been rather supportive of your plugins and your forum hbf . And I think I would be that last person here to recommend cloning and uploading the same plugin .

  • $Configuration['Plugin']['LikeThis']['DisplayPhotoName'] = 'N'; //switch off display of individual photos and names

    setup for vanilla 2.0 and 2.1 and above

        public function DiscussionController_AfterCommentBody_Handler($Sender)
            {
             if (substr(APPLICATION_VERSION,0,3) < 2.1) {
                     $this->LikeThisDisplayPhotoName($Sender);
            }
    
            }
    
    
        public function DiscussionController_AfterReactions_Handler($Sender)
            {   
                   if (substr(APPLICATION_VERSION,0,3) > 2.0) {  
                     $this->LikeThisDisplayPhotoName($Sender);     
              }
    
            }
    
    
        public function  LikeThisDisplayPhotoName($Sender)
    
            {
             if (C(Plugins.LikeThis.DisplayPhotoName) == "N")   return; 
    
                  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.

    vrijvlinderhgtonight
  • peregrineperegrine MVP
    edited June 2013

    @hbf said:

    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.

    I'm thinking of finishing my reactions plugin, if I can get pledged donations, I gathered ideas from your plugin, kudos, and thankful people, and 200 other plugins on this forum, as well as from 1000 discussions. It will most likely have the ability for 3 types of reactions (none of them named like). Would you consider that a fork?? and would you be offended?

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

    UnderDogTama
  • hbfhbf wiki guy? MVP

    @peregrine said:
    I'm thinking of finishing my reactions plugin, if I can get pledged donations, I gathered ideas >from your plugin, kudos, and thankful people, and 200 other plugins on this forum, as well as >from 1000 discussions. It will most likely have the ability for 3 types of reactions (none of them >named like). Would you consider that a fork?? and would you be offended?

    if you think it is closely enough related to the software i created to ask honestly, then send me a PM and we can discuss. I never said i would not condone a fork. I just said if someone were to fork my code without permission and post it in the add-ons section i would take offense.

  • hbfhbf wiki guy? MVP

    @peregrine said:
    $Configuration['Plugin']['LikeThis']['DisplayPhotoName'] = 'N'; //switch off display of individual photos and names

    setup for vanilla 2.0 and 2.1 and above

        public function DiscussionController_AfterCommentBody_Handler($Sender)
          {
           if (substr(APPLICATION_VERSION,0,3) < 2.1) {
                   $this->LikeThisDisplayPhotoName($Sender);
          }
          
          }
          
          
        public function DiscussionController_AfterReactions_Handler($Sender)
          {   
                 if (substr(APPLICATION_VERSION,0,3) > 2.0) {  
                   $this->LikeThisDisplayPhotoName($Sender);     
            }
        
          }
          
          
        public function    LikeThisDisplayPhotoName($Sender)
           
          {
           if (C(Plugins.LikeThis.DisplayPhotoName) == "N")   return; 
    
                  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>';
                      }
          
          }
    

    very cool. thank you.

  • hbfhbf wiki guy? MVP

    @vrijvlinder said:

    You misunderstood, I never said to fork it and upload it as a new plugin, I meant it as personal use. Not to distribute. I have never recommended to anyone to clone something without permission and upload it. I do resent the accusation . My comments to phreak about this plugin were tongue in cheek . I see no harm in modifying something for personal use. Is modifying a plugin for personal use wrong, is it forbidden ? I was under the impression that one could do this for oneself. Not to distribute but for personal use.

    I think I have been rather supportive of your plugins and your forum hbf . And I think I would be that last person here to recommend cloning and uploading the same plugin .

    I wasn't referring to forking for personal use, as that is the name of the game. Almost every plugin I've downloaded from the addons repository has been modified for my own use.

    I misunderstood your intent, probably due to working 36 hrs in two days and then reading your post. My mistake.

    vrijvlinder
  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Thanks I appreciate it, remember also that we made a fuss over the blatant clone from your kudos plugin and got it removed from the depo here. I would never condone doing that specially not without permission from someone.

    Cloning to me means copying the entire thing as is no mods and then changing all the names correspondingly. That would be the same plugin with another name. That would be useless to create why have two of the same right?

    However if one takes useful parts from the plugin i.e. generic code that exists in every other plugin , like senders and handlers etc. user models, to create another different plugin , that to me is not a clone is it? maybe a son is more like it...

    How much of the garden vanilla code is even ours in any event ? Doesn't all the basis for every plugin already exist in the core in the library etc? even blank controllers and plugin startups for people to learn how to make them?

    So possibly the real authors of this code are the designers of Vanilla and how it works. We are mere masons that use the rocks they carved out of the mountain for us to build with. Possibly our attribution is crafty logic and the creation of something unexpected from this source. Maybe that is what authorship means in this case, not owner of the code but an engineer who used it to make something else with it.

    Ultimately every idea has been thought of in multiple ways. To make it real there should not be restrictions based on my code your code, all this code is the same when you break it down and it does not originate from us. It originated by Vanilla devs and gardeners, and on and on , we are the end user of this pre made drawer of tools.

    Now this is far from saying that people should clone and claim, just incase it gets taken that way .

    I just think that code is like music and it should be shared. I could use those drums on my tune can I use them, come jam with me ? Kind of like that....

    I like that code can I use it for my experiment ? The end result will be something much different and you would get credit for sharing that small part that was used.

    Maybe I am a dreamer but I'm not the only one ..... right? :)

  • peregrineperegrine MVP
    edited June 2013

    @hbf said:
    very cool. thank you.

    my pleasure...

    @hbf said:

    @peregrine said: I'm thinking of finishing my reactions plugin, if I can get pledged donations, I gathered ideas >from your plugin, kudos, and thankful people, and 200 other plugins on this forum, as well as >from 1000 discussions. It will most likely have the ability for 3 types of reactions (none of them >named like). Would you consider that a fork?? and would you be offended?

    if you think it is closely enough related to the software i created to ask honestly, then send me a PM and we can discuss. I never said i would not condone a fork. I just said if someone were to fork my code without permission and post it in the add-ons section i would take offense.

    What I am working on, is more like the vanilla reactions (probably with 3 or 4 reactions best, wow, scholarly, brilliant, and lol) its not really a fork of your plugin, but it is yet another type of reactions plugin (likethis, thankful people, and kudos, etc). However I will be using a portion of the code below to display the photos, vanillicons, names etc. assuming I can get any pledges of financial support to finish it.

     foreach($PeregrineReactions 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.

Sign In or Register to comment.