: Looking for the best tools and techniques to improve your rankings? Click Here!
Powered by MaxBlogPress Close 
A A
RSS

Topusers function

Social Web CMS
Advertise Here

Posted on Wed, Jun 11, 2008 by User ImageGeoserv

Hacks

The top users function built in to Pligg has been something I have neglected since installing Pligg. For the most part because it seemed to just display a list of all members alphabetically.

Today I took a look at the file topusers.php to see what it was using as a query, I wanted to change the output so it showed “top users” as the title suggests.

Sometimes it pays to browse the files of Pligg, the topusers.php files has 6 options for the output:

  • sort users alphabetically
  • sort users by number of submitted links
  • sort users by number of published links
  • sort users by number of comments
  • sort users by number of votes
  • sort users by number of published votes

By default, it is set to the first option, most Pligg installs you visit will have this set for the output. The first option really isn’t something that should be in the topusers.php file, as it only list all of your members.

I would set the option to either #1 or #5, this will show a more accurate picture of your top members.

In your root folder open topusers.php, find this section:

// determine how to sort users
if(isset($_GET['sortby'])){
        $sortby = $_GET['sortby'];}
else{
        $sortby = "0";}
       
// make sure sorting option is between 0 and 5 
if(intval($sortby) < 0 || intval($sortby) > 5)
        $sortby = 0;
else $sortby = intval($sortby);

switch ($sortby) {
        case 0: // sort users alphabetically
                $select = "SELECT user_id";
                $from_where = " FROM " . table_users . " where user_level<>’god’";
                $order_by = " ORDER BY user_login ";
                break;
        case 1: // sort users by number of submitted linkd
                $select = "SELECT user_id, count(*) as count ";
                $from_where = " FROM " . table_links . ", " . table_users . " WHERE  link_status != ‘discard’ AND link_author=user_id AND user_level<>’god’ GROUP BY link_author";
                $order_by = " ORDER BY count DESC ";
                break;
        case 2: // sort users by number of published links
                $select = "SELECT user_id, count(*) as count ";
                $from_where = " FROM " . table_links . ", " . table_users . " WHERE  link_status = ‘published’ AND link_author=user_id AND user_level<>’god’ GROUP BY link_author";
                $order_by = " ORDER BY count DESC ";
                break;
        case 3: //sort users by number of comments
                $select = "SELECT user_id, count(*) as count ";
                $from_where = " FROM " . table_comments . ", " . table_users . " WHERE comment_user_id=user_id AND user_level<>’god’ GROUP BY comment_user_id";
                $order_by = " ORDER BY count DESC ";
                break;
        case 4: //sort users by number of votes
                $select = "SELECT user_id, count(*) as count ";
                $from_where = " FROM " . table_votes . ", " . table_users . " WHERE vote_user_id=user_id AND user_level<>’god’ GROUP BY vote_user_id";
                $order_by = " ORDER BY count DESC ";
                break;
        case 5: // sort users by number of published votes
                $select = "SELECT user_id, count(*) as count ";
                $from_where = " FROM " . table_votes . ", " . table_users . ", " . table_links . " WHERE vote_user_id=user_id AND link_id=vote_link_id AND link_status=’published’ AND vote_date < link_published_date AND user_level<>’god’ GROUP BY user_id";
                $order_by = " ORDER BY count DESC ";
                break;
}
 

I have changed my to #5, so mine now looks like:

// determine how to sort users
if(isset($_GET['5'])){
        $sortby = $_GET['5'];}
else{
        $sortby = "5";}
       
// make sure sorting option is between 0 and 5 
if(intval($sortby) < 0 || intval($sortby) > 5)
        $sortby = 5;
else $sortby = intval($sortby);

switch ($sortby) {
        case 0: // sort users alphabetically
                $select = "SELECT user_id";
                $from_where = " FROM " . table_users . " where user_level<>’god’";
                $order_by = " ORDER BY user_login ";
                break;
        case 1: // sort users by number of submitted linkd
                $select = "SELECT user_id, count(*) as count ";
                $from_where = " FROM " . table_links . ", " . table_users . " WHERE  link_status != ‘discard’ AND

link_author=user_id AND user_level<>’god’ GROUP BY link_author";
                $order_by = " ORDER BY count DESC ";
                break;
        case 2: // sort users by number of published links
                $select = "SELECT user_id, count(*) as count ";
                $from_where = " FROM " . table_links . ", " . table_users . " WHERE  link_status = ‘published’ AND

link_author=user_id AND user_level<>’god’ GROUP BY link_author";
                $order_by = " ORDER BY count DESC ";
                break;
        case 3: //sort users by number of comments
                $select = "SELECT user_id, count(*) as count ";
                $from_where = " FROM " . table_comments . ", " . table_users . " WHERE comment_user_id=user_id AND

user_level<>’god’ GROUP BY comment_user_id";
                $order_by = " ORDER BY count DESC ";
                break;
        case 4: //sort users by number of votes
                $select = "SELECT user_id, count(*) as count ";
                $from_where = " FROM " . table_votes . ", " . table_users . " WHERE vote_user_id=user_id AND user_level<>’god’

GROUP BY vote_user_id";
                $order_by = " ORDER BY count DESC ";
                break;
        case 5: // sort users by number of published votes
                $select = "SELECT user_id, count(*) as count ";
                $from_where = " FROM " . table_votes . ", " . table_users . ", " . table_links . " WHERE vote_user_id=user_id AND

link_id=vote_link_id AND link_status=’published’ AND vote_date < link_published_date AND user_level<>’god’ GROUP BY user_id";
                $order_by = " ORDER BY count DESC ";
                break;
}

Example: News Dots Topusers

Something to play around with until you find the right one for you.

Which one are you using?

Popularity: 63% [?]

Rate this:
2.5

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!


Add to BlogEngage

RSS feed for comments on this post. TrackBack URL

RELATED POSTS

No related topics found

RELATED ADS

1 Comments For This Post

  1. no imageDavid (Check me out!) (1 comments.) Says:

    You wrote:

    if(isset($_GET[‘5′])){
    $sortby = $_GET[‘5′];}
    else{
    $sortby = “5″;}

    in my test this broke the ability to sort by other criteria such as ‘Published’. Instead I believe the right modification would be this

    if(isset($_GET[‘sortby′])){
    $sortby = $_GET[‘sortby′];}
    else{
    $sortby = “5″;}

    This will default to Published votes but allow sorting by other criteria.

    Rate this:
    3.0

Leave a Reply

SimplyWP   My Blogging Experience



  RevResponse

Make money selling links!
Free Webmasters Resources
VPS Hosting
Advertise Here

Recent Droppers

  • FreeTheMac.com

    FreeTheMac.com is a vast collection of freeware programs for Mac OS X. We have several hundred completely free programs and are adding new programs every day.

  • Apeture.Net

    Latest Gadget, Computer and Otherwise News, Reviews, and Technical Specifications.

  • Money Online

    just wanting to get my fair share of online money

  • Technically Easy

    Provides useful and helpful advice to understanding various technologies in use today. Topics discussed include computers, networking (wired and wireless), security, Web sites, and digital cameras. Free reviews of personal blogs and Web sites are offered.

  • Celebrity Today!

    Celebrity Today! has all the latest news in celebrity and movie news from Hollywood! Check here daily for all the scoop.

  • Powered by EntreDroppers

Publicity

Get in on the buzz

My site was nominated for Best Blog About Stuff! 

Advertise Here

fly.co.uk cheap flights from the uk to the whole world
Visit Now Find Deals
Qatar Flights Cheap Flight

Popularity: 100% [?]

Rate this:
2.5

Popularity: unranked [?]

Rate this:
2.5

Popularity: unranked [?]

Rate this:
2.5

Popularity: unranked [?]

Rate this:
2.5

Popularity: unranked [?]

Rate this:
2.4 (1 person)

Categories

Archives