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

User Rankings 0.2

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

  1. Nick

    Nick Well-Known Member

    User Rankings
    Version: 0.2
    Author: Nick Ramsay
    Created:
    2010/03/10
    Last Updated: 2010/06/13
    Tested on: Hotaru 1.1.2 ~ 1.3.0
    Plugins Required: Activity
    Plug & Play: Yes
    Supported: Yes

    Description
    A Widget and Page that ranks users by activity over the last X days. Comes with a settings page so you can customize the number of points to award for each post, comment or vote, and a cache duration to set how often points are updated.

    Instructions
    1. Upload the "user_rankings" folder to your plugins folder.
    2. Install it from Plugin Management in Admin.
    3. Configure in Admin -> Plugin Settings -> User Rankings
    4. Enable the User Rankings widget in Admin -> Plugin Settings -> Widgets

    Notes
    Both the widget and page use the HTML cache so if you change a setting you will probably need to clear the HTML cache from Admin -> Maintenance.

    Revision History
    v.0.2 2010/06/13 - Alan - rewritten SQL query to take workload off PHP
    added admin setting for truncating long usernames, added admin setting for selecting excluded users
    fixed heading to display title for x days instead of static 30 days, fix saving of settings check boxes
    v.0.1 2010/03/14 - Nick - Released first version

    Please click "Rate Thread" and give this plugin a rating. Thank you.

     

    Attached Files:

  2. williamd

    williamd New Member

    I love it. Can't wait to try it out!
     
  3. Nick

    Nick Well-Known Member

    I've updated the .zip to include a plugin hook for other plugins (e.g. Custom Rankings). Since only one person had downloaded it, I didn't bother updating the version number. If you are that person, you can see the changes here.
     
  4. Gunaxin

    Gunaxin Well-Known Member

    Plugin Suggestion : An option to select a user level (and above) that will be excluded from the rankings. For example, it probably doesn't make much sense to have the Admin (or his staff) listed in the rankings. I personally would only want Members (and below I suppose) listed in my rankings. I can probably figure out how to modify this plugin to do that, however I figure others may want this option as well.
     
  5. nothingman

    nothingman Active Member

    Hi Nick, are the 'scores' of the users stored in the database? If so, I see a way of extending it as what Digg calls "Power Users" or in Reddit parlance "Karma"
    For example, a user with a high score will need, say only 4 votes for his/her story to hit the front page, while a user below a certain score would need a certain score for his/her story to hit the front page.
    OR
    A user with a high XYZ rank is 'so' powerful that the user's comment cannot be hidden easily etc etc

    Also, I remember in meneame, a user who has just signed up cannot submit a new story unless the user has earned a certain score. And to earn 'that' score, the user needs to be active in the community first, by way of voting comments/stories, or posting comments etc. - a great way to deal with Spammers! :)
     
    Last edited: Mar 26, 2010
  6. Nick

    Nick Well-Known Member

    Sorry, the scores aren't saved in the database. The plugin is actually very basic. It just assigns points for actions over the last 30 days and lists the users by most points. You'd need something more advanced if you want to enable or disable features based on user scores.
     
    nothingman likes this.
  7. nothingman

    nothingman Active Member

    Oh ok, thanks! BTW, if we deselect Show user's name in the User Rankings Settings page, the widget looks quite awry.

    [​IMG]
     
  8. apfind

    apfind New Member

    Truncating a user name to preserve formating of the top user list.

    Really low priority project here... One of my users picked a huge name. I don't mind that users do that, but he is completely messing up the formating of my Top Users list. Was trying to quickly fix this by truncating the name to 15 characters.

    Not sure about the variables... but from what Nick has posted in the past this is the structure of the truncate function...
    $short_name = truncate($h->$user->name, 15, false);

    I opened up user_rankings.php

    And am trying to find a way to insert the truncate function within the following code block.
    PHP:
    // get all users with activity in the last X days, ordered by points
            
    $users $this->generateUserRankings($h);
            if (!
    $users) { return false; }
            
            
    $output '';
            
    $i 0;
            foreach (
    $users as $id => $points)
            {
                
    $user = new UserAuth();
                
    $user->getUserBasic($h$id);

                if (!
    $user->id) { continue; } // i.e. if this user doesn't exist anymore, skip to the next one
                
                
    $i++;
                
    $output .= "<li class='user_rankings_" $css "_item user_rankings_clearfix'>\n";
                
                if (
    $ur_settings['show_avatar'] && $h->isActive('avatar')) {
                    
    $size 'avatar_size_' $css;
                    
    $h->setAvatar($user->id$ur_settings[$size]);
                    
    $output .= "<div class='user_rankings_" $css "_avatar'>\n";
                    
    $output .= $h->linkAvatar();
                    
    $output .= "</div> \n";
                }
                
                if (
    $ur_settings['show_name']) {
                    
    $output .= "<a class='user_rankings_" $css "_name' href='" $h->url(array('user' => $user->name)) . "'>" $user->name "</a> \n";
                }
                
                
    $h->vars['user_rankings_output'] = "";
                
    $h->pluginHook('user_rankings_item''', array('points' => $points'css' => $css));
                
    $output .= $h->vars['user_rankings_output'];
                
                
    $output .= "<div class='user_rankings_" $css "_points'>" $points "</div>\n";
                
    $output .= "</li>\n\n";

                if (
    $i >= $ur_settings[$limit]) { break; }
            }
            
            if (
    $need_cache) {
                
    $h->cacheHTML($ur_settings['cache_duration'], $output$label); // make or rewrite the cache file
            
    }
            
            return 
    $output;
        }

    Not really sure where it would go exactly... maybe ill start tinkering with this:
    PHP:
    if ($ur_settings['show_name']) {
                    
    $output .= "<a class='user_rankings_" $css "_name' href='" $h->url(array('user' => $user->name)) . "'>" $user->name "</a> \n";
                }
     
  9. skorpyo

    skorpyo Well-Known Member

    I relly need this...can someone do it...please?!
     
    Last edited: Jun 12, 2010
  10. shibuya246

    shibuya246 Hotaru Developer Staff Member Admin

    ok, I have made an update to the plugin to accommodate this. I have also rewritten the SQL query to take some of the workload off the PHP script. I am just adding the suggestion for excluding certain levels of users. e.g. admin levels, and then will release this as version 0.2

    Should have it out tonight :)

    Nick and I put all new plugins and Hotaru code on http://bloggertools.net for testing. It would be nice to see a few more people signing up there and submitting some articles. That way we can see whether any errors are coming up and try to fix them before burdening everyone with releases that are not 100%

    http://bloggertools.net
     
    skorpyo likes this.
  11. shibuya246

    shibuya246 Hotaru Developer Staff Member Admin

    Made a series of updates to this plugin which I hope helps fix the recent requests

    v.0.2 2010/06/13 - Alan - rewritten SQL query to take workload off PHP
    added admin setting for truncating long usernames, added admin setting for selecting excluded users
    fixed heading to display title for x days instead of static 30 days, fix saving of settings check boxes
     
    Nick and skorpyo like this.
  12. angolanmade

    angolanmade Well-Known Member

  13. BakedGoods

    BakedGoods New Member

    Yes, it would be fantastic if this information could be stored in the database.

    Also points awarded based on total views would be interesting too. Time for me to learn PHP!
     
  14. Moset

    Moset New Member

    Suggestion!

    Get points for votes on submited post.
    So if i submit 1 post and get 10 votes i get 20 points each = 200 points and change the score for posting to 180 cuz u wote 1 time yourself :)
     
  15. munddr

    munddr New Member

    Can the user score/karma be displayed with the user name in a submission or a comment?
     
  16. Nick

    Nick Well-Known Member

    No, because the user's score is not stored anywhere. The scores are calculated as a batch and shown in the widget or Rankings page together.
     
  17. nikar

    nikar New Member

    install this plugin
    I have error:
    Warning: Table './cwitterru/hotaru_pluginsettings' is marked as crashed and last (automatic?) repair failed in /home/c/cwitterru/public_html/libs/extensions/ezSQL/mysql/ez_sql_mysql.php on line 264
     
  18. Nick

    Nick Well-Known Member

    I think that's just coincidence, not anything specifically to do with this plugin. Go into phpMyAdmin, click the pluginsettings table, then the "Operations" tab and "Repair table".
     
  19. nikar

    nikar New Member

    "Repair table" does not help. I checked. The problem only occurs when i install this plugin. I tried to put on a clean cms, only this plugin.
     
    Last edited: Sep 28, 2010
  20. Nick

    Nick Well-Known Member

    I don't know how to help you, nikar. This plugin has been downloaded 100 times and this is the first time I've heard of such a problem. Sorry.
     

Share This Page