1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Up Down Voting 1.0

Discussion in 'Plugins' started by Nick, Mar 2, 2010.

  1. scopolamine

    scopolamine New Member

    There is no point of this feature. It should be "number of hours" instead of "number of days".
     
    Last edited: Nov 8, 2011
  2. yudhis97

    yudhis97 New Member

    So I was wondering if there is any update for this plugin ?
     
  3. skorpyo

    skorpyo Well-Known Member

    okay...so I've changed the style of my vote widget but every time I vote up or down, I think the java clears the vote count css style I applied...is that possible? how can I make this work, please help!
     
  4. PuckRobin

    PuckRobin New Member

    Did you try to clear the server side css cache and also your browser cache?
     
  5. skorpyo

    skorpyo Well-Known Member

    I'm not that new to Hotaru as you probably think...so yeah, I did that long before this happened. Something just clears the css style I applied to the vote counts and don't know what or where...
     
  6. PuckRobin

    PuckRobin New Member

    Then, using chrome's "inspect element" feature, check which css classes are active before and after the click. Search for this class the codes and make necessary changes.
     
  7. skorpyo

    skorpyo Well-Known Member

    that doesn't help at all...because I already know what class is in cause and just disappears after I vote either up or down...although its present on template
     
  8. PuckRobin

    PuckRobin New Member

    Do you mean you have already changed updown_voting.css and those styles disappear?
     
  9. skorpyo

    skorpyo Well-Known Member

    Actually I applied css style from the styles.css file of my custom theme to it, and cleared the updown_voting.css located in the css folder of the same custome theme...and I think maybe I should do the same for the updown_voting.css located at the css plugin folder...

    Edit: or put the custom css code on the updown_voting.css located on the custom theme...
    A bit later edit: you can check out the dev site and see it for your selfs.
     
    Last edited: Nov 8, 2011
  10. skorpyo

    skorpyo Well-Known Member

    This is the custom code that resets after voting either up or down:
    Code:
    <div id='votes_<?php echo $h->post->id; ?>' class='vote_button_count'><a href="#" class="disabled"><span><em><?php echo $h->vars['votesUp']; ?></em></span></a></div>
    and this is after voting:
    Code:
    <div id='votes_<?php echo $h->post->id; ?>' class='vote_button_count'><?php echo $h->vars['votesUp']; ?></div>
    that means the "a", "span" and "em" tags disappear...after voting, but WHY? I just can't figure this out...this is insane! Please someone help me.
     
  11. UsupNew

    UsupNew Active Member

    Thanks i need this.....
     
  12. valMETNG

    valMETNG Administrator Staff Member Admin

    Potential bug in Up Down Voting

    Granted, I'm still learning the Hotaru code base, but I think I might have found a bug in this plugin. The potential offending line is 110 within the function updown_voting_remove_vote of updown_voting_functions.php:

    Code:
    function updown_voting_remove_vote($h, $post_id, $user_id, $voted, $vote_rating)
    {
        // Update Postvotes table
        $sql = "DELETE FROM  " . TABLE_POSTVOTES . " WHERE vote_post_id = %d AND vote_user_id = %d AND vote_rating = %d";
        $h->db->query($h->db->prepare($sql, $post_id, $user_id, $voted, $vote_rating));
        
        // Update Posts table
        if ($vote_rating > 0) {
            $sql = "UPDATE " . TABLE_POSTS . " SET post_votes_up = post_votes_up + 1 WHERE post_id = %d";
            $h->db->query($h->db->prepare($sql, $post_id));
        } else {
            $sql = "UPDATE " . TABLE_POSTS . " SET post_votes_up = post_votes_up - 1 WHERE post_id = %d";
            $h->db->query($h->db->prepare($sql, $post_id));
        }
    }
    I haven't fully traced the implications, but the code $h->db->query($h->db->prepare($sql, $post_id, $user_id, $voted, $vote_rating)); seems to be wrong as it's passing four variables to a WHERE that only wants three. Seems like $voted shouldn't be there. Or am I missing something?
     
    Last edited: Apr 13, 2012
  13. PuckRobin

    PuckRobin New Member

    Well, it depends on the definition of "bug" :) When a post is voted, $voted=$vote_rating, so there will be no implications of this.
     
  14. valMETNG

    valMETNG Administrator Staff Member Admin

    Never a bug unless a user sees it, eh? ;)
     
  15. valMETNG

    valMETNG Administrator Staff Member Admin

    I just installed this plugin and it appears somewhat odd in the updated themes:

    updown voting.png

    Any plans to update this plugin?
     
  16. valMETNG

    valMETNG Administrator Staff Member Admin

    As a follow-up, it appears the voting isn't working on this at all. When I click down, it places "err" in the other vote count box:
    vote err.png

    Additionally, un-vote doesn't do anything.
     
  17. valMETNG

    valMETNG Administrator Staff Member Admin

    It appears part of the voting problem itself is coming from these beginning lines in updown_voting_functions.php:

    Code:
    require_once('../../../hotaru_settings.php');
    require_once('../../../Hotaru.php');	// Not the cleanest way of getting to the root...
    
    $h = new Hotaru();
    
    $h->start();
    
    $h->includeLanguage('updown_voting', 'updown_voting');
    It's interesting that this approach is using the same method I was struggling with on Paypal - almost as if it's coming in via the backend. To fix it, I replaced the first 2 lines with:

    Code:
    $dir = '../../../';
    if (file_exists($dir.'config/settings.php'))
    	{
    	require_once($dir.'config/settings.php');
    	require_once($dir.'Hotaru.php');
    }
    Not sure if this is the approach that makes sense given the upgrades, but it does get the voting working... sometimes. I can now click the up and down and get the numbers to change in the left-most vote count box (i.e., not the one between the up and down). However, it appears that sometimes I click on the up or down and the vote count doesn't change. So there must be more to the problem.
     
  18. valMETNG

    valMETNG Administrator Staff Member Admin

    Update: I noticed that there's a json2.min.js file in the javascript directory. When I deleted that, the up and down now always works. Probably was redundant with what the new release is already bringing in.
     
    shibuya246 likes this.
  19. valMETNG

    valMETNG Administrator Staff Member Admin

    (face palm)

    Perhaps if I had paid closer to Nick's post, I would have realized that the double vote counter is because the Vote plugin was also installed and shouldn't be.

    This is one of the reasons I have problems coding... "Directions? We don't need no stinkin' directions..." >.>
     
  20. shibuya246

    shibuya246 Hotaru Developer Staff Member Admin

    thanks, yes it had not been updated
    The backdoor approach is not preferred so I have now updated this plugin and used theme_index_top plugin hook
     

Share This Page