Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

New Widget (Plugin): Most Active Users per Week or Month

+6 votes
2,960 views
asked Jun 11, 2012 in Plugins by q2apro
edited Jun 18, 2012 by q2apro

This is a plugin for Question2Answer that displays the most active users of the current week or the current month in a widget.

screenshot q2a-most-active-users

 

Download & Install instructions:
https://github.com/echteinfachtv/q2a-most-active-users/

 

Important:
You need the event logger plugin enabled. Go to Admin -> Plugins on your q2a install, tick the first checkbox "Log events to qa_eventlog database table". Because the plugin relies on this data, and considers each question/answer/comment logged as +1 activity point.

any feedback appreciated.

 

PS: Thanks @NoahY

commented Jun 17, 2012 by WhyCheese
Just wanted to say thanks ! :)
commented Feb 7, 2013 by q2apro
@everyone: I updated the plugin according to your suggestions, please see http://www.question2answer.org/qa/21240/plugin-update-most-active-users-widget-to-v1-2

4 Answers

0 votes
answered Jun 13, 2012 by bishu
Great Plugin, Thanks for contribution this plugin.

Everything is working find but I would like to have a little changes in the avatar. As when I use this plugin,  the five users avatar are not showing in the same size so it is not looking good. Is there any way to show this avatar in a same size as shown in the top user plugin.
commented Jun 13, 2012 by q2apro
I have no idea how to change the function "qa_get_user_avatar_html" to set a fixed size of the images.

So I would go for CSS:
#mostactiveusers img { width:30px; height:30px; }
commented Feb 7, 2013 by q2apro
I added an option for this in v1.2, please see qa-most-active-users.php line: $avatarSize = qa_opt('avatar_users_size');

Here you can change it to: $avatarSize = 50; // for example
0 votes
answered Jun 18, 2012 by bishu
In this plugin it show as -

Slno - Avatar - Username

As in your coding $val contents the current points, so I have change as follows to show

Slno - Avatar - Username - Current Points

$topusers .=  $avatarImages[$key]." ".qa_get_one_user_html($key, false)." - $val points";

Its working fine and also looking good. Now I want to add the Total Points of the user. Please help me to get the total points of the particular users.

Thanks.
commented Jun 18, 2012 by q2apro
after: $user = qa_db_select_with_pending( qa_db_user_account_selectspec($username, false) );

you should be able to save the value using: $user['points']

* But be aware that activity points (created by eventlog) are not related to total points (qa_userpoints).
0 votes
answered Jun 18, 2012 by bishu

Thanks for your reply. Now I have modify according to my need as

Will this users points display will be correct for my need or not -

My modi code is

  // initiate output string
  $topusers = "<table border='0' width='100%'>";
  // display maximum of maxusers
  $nrUsers = 0;
  foreach ($users as $key => $val) {
   $nrUsers++;
   // $topusers .= "<br />";
   $topusers .= "<tr><td width='25'>".$avatarImages[$key]."</td><td width='0'></td><td>".qa_get_one_user_html($key, false)." - $val"."/".$totalpoints[$key]." points".'</td></tr>';
   // max users to display
   if($nrUsers>=$maxusers) break;
  }
  $topusers .= "</table>";
  
  $themeobject->output('<div id="mostactiveusers"><h2 style="padding-top: 0px; margin-top: 0px;">');
  if($doWeek) {
   $themeobject->output('<div class="qa-nav-cat-list qa-nav-cat-link">'.$langActUsers.'<br />'.$langThisWeek.'</div></h2>'); // todo: qa_lang_html('misc/most_active_users')
  }
  else {
   // get month name
   setlocale (LC_TIME, $localcode);
   // $monthName = strftime("%B %G", strtotime( date('F')) );
   $monthName = strftime("%B %G", strtotime( date('F')) );
   $themeobject->output('<div align=center class="qa-nav-cat-list qa-nav-cat-link">'.$langActUsers.' '.$monthName.'</div></h2>');
  }
  $themeobject->output( $topusers );
  $themeobject->output('</div>');
 

commented Jun 18, 2012 by Question Nut
Hi I would like to have the same functionality for this plugin. Please can you post the full PHP file so I can paste into existing? thanks...
commented Feb 7, 2013 by q2apro
Option has been included in the new version 1.2: https://github.com/echteinfachtv/q2a-most-active-users
0 votes
answered Jun 18, 2012 by bishu

Hello Register user 6 !

I am unable to post all the code as the Q2A support upto 8000 characters only. So I am just providing where I have made the changes. The inserted line and the changes line are mark with red color.

  $users = array();
  $events = array();
  $avatarImages = array();
  $totalpoints = array();

 

  /* get avatar images */
  foreach ($users as $username => $val) {
   $user = qa_db_select_with_pending( qa_db_user_account_selectspec($username, false) );
   $totalpoints[$username] = $user['points'];
   $avatarImages[$username] = qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'], $user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true);
        }

 

  // initiate output string
  $topusers = "<table border='0' width='100%'>";
  // display maximum of maxusers
  $nrUsers = 0;
  foreach ($users as $key => $val) {
   $nrUsers++;
   // $topusers .= "<br />";
   $topusers .= "<tr><td width='25'>".$avatarImages[$key]."</td><td width='0'></td><td>".qa_get_one_user_html($key, false)." - $val"."/".$totalpoints[$key]." points".'</td></tr>';
   // max users to display
   if($nrUsers>=$maxusers) break;
  }
  $topusers .= "</table>";

commented Jun 18, 2012 by Question Nut
But the current X value is not the true monthly score.. I think it associates 1 point per action instead of giving the correct numbers of points set in the Admin/points section. I really need the true number of points for that calendar month
...