. // It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise. // You can get copies of the licenses here: // http://www.affero.org/oagpl.html // AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING". include_once('Smarty.class.php'); $main_smarty = new Smarty; include('config.php'); include(mnminclude.'html1.php'); include(mnminclude.'ts.php'); include(mnminclude.'link.php'); include(mnminclude.'tags.php'); include(mnminclude.'user.php'); include(mnminclude.'smartyvariables.php'); // ------------------------------------------------------------------------------------- // breadcrumbs and page titles $navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_TopUsers'); $navwhere['link1'] = getmyurl('topusers', ''); $main_smarty->assign('navbar_where', $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_TopUsers')); // figure out what "page" of the results we're on $offset=(get_current_page()-1)*$top_users_size; // put the table headers in an array for the top users tpl file $items = array($main_smarty->get_config_vars('PLIGG_Visual_TopUsers_TH_User'), $main_smarty->get_config_vars('PLIGG_Visual_TopUsers_TH_News'), $main_smarty->get_config_vars('PLIGG_Visual_TopUsers_TH_PublishedNews'), $main_smarty->get_config_vars('PLIGG_Visual_TopUsers_TH_Comments'), $main_smarty->get_config_vars('PLIGG_Visual_TopUsers_TH_TotalVotes'), $main_smarty->get_config_vars('PLIGG_Visual_TopUsers_TH_PublishedVotes')); // 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 . " "; $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 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 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 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 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 GROUP BY user_id"; $order_by = " ORDER BY count DESC "; break; } // pagename define('pagename', 'topusers'); $main_smarty->assign('pagename', pagename); // sidebar $main_smarty = do_sidebar($main_smarty); // show the template $main_smarty->assign('tpl_center', $the_template . '/topusers_center'); $main_smarty->display($the_template . '/pligg.tpl'); ?>