Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
6.1k views
in Plugins by
edited by

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

by
how can i translate it into another language
by
open file qa-most-active-users.php go to line 131 and 137.
There change: Aktivste Benutzer<br />diese Woche:
To e.g. English: Most active Users<br />this week:

and: Aktivste Benutzer<br />
to: Most active Users<br />
by
Good work on the plugin! Suggestion for the language issue: use class variables outside of functions, e.g.

class qa_most_active_users {
private $langActUsers = "Aktivste Mitglieder";   
private $langThisWeek = "diese Woche";
[functions here]
}

Then use $this->langActUsers where you output the variables. This way they are separated and easy to spot in the file.
by
Could you do the changes and commit in github?

I am new to github, so it would be interesting to see how I can "accept" new "branches" :)

PS: I saw NoahY doing an extra language file for each plugin.
by
Just wanted to say thanks ! :)
by
@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
by
How to get most active users in last month/previous month?
 Or
How to get all months log in a page?
How to make most active to most answered?

4 Answers

0 votes
by
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.
by
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; }
by
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
by
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.
by
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
by

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>');
 

by
then it seems to be correct :)

Tip: check your server, your root folder of your q2a installation. if there is any error_log file you should read its content to see where errors are in your scripts.
by
Thanks for your help
by
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...
by
Option has been included in the new version 1.2: https://github.com/echteinfachtv/q2a-most-active-users
0 votes
by

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>";

by
Can you clarify what "X" represents in "X / Total points"?

I really need total "points for current month / Total points"
by
edited by
"X" is the current month Activity count.
and after the slash "/" is the total points score.
by
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
...