Top Contributors excluding admin groups and IPs
From Another Web Company
Viewed 453 times, With a total of 4 Posts
| Have a suggestion, improvement, change or non-beta Forum Entension bug ? Please add them to the todo list
|
|
|
|
Just Got Here
Wiki Edits: 0
Threads 1
Posts 3
|
|
| 5:17:33 AM - Wednesday 12th, September 2007 |
|
Hey there.
We've got the top 10 contributors thing working on our MediaWiki site, but we want to exclude all users that are in the 'sysop' group from showing in the lists.
I found something on here that lets you exclude specific usernames, but 1- we couldnt get this to work, and 2- we need to be able to exclude a whole usergroup, so that when we add new users to this group, we dont have to edit the config file and add them to it.
Also - We want it to display the First and Last name of the user, and not the actual user's username 
Thanks heaps in advance!
|
|
|
|
|
|
Just Got Here
Wiki Edits: 0
Threads 1
Posts 3
|
|
| 9:17:16 PM - Wednesday 12th, September 2007 |
|
|
Ok so I thought I'd try and have a look at it and make some sense of this, (this is also my first time with PHP, im an ASP guy haha...
Found this line...
if (strlen($name) > name_cut ) $name = substr($name,0,name_cut) ."...";
And commented it out, and then the full names worked on the side menu 
I'm presuming that line of code is saying if the name is there, then display it, if not, then display three dots? For the likes of IP entries that don't have a name 
So if that's any help trying to solve the above problem, thats where the problem lies 
Cheers Again!!
|
|
|
|
|
|
Just Got Here
Wiki Edits: 0
Threads 1
Posts 3
|
|
| 9:17:38 PM - Wednesday 12th, September 2007 |
|
|
Hey thanks firstly heaps in advance for your help! We're working on this for a Uni Project, and it's great to get your help as this is our first experience with mediawiki, and this extension too.
I made the changes you told to above (and then also tried it with the file you attached to your message)...
However, these are the problems with it:
- The contributions in the menu show up as "..." Not the full name, and for "anonymous" edits, (where before it showed a IP address) now have nothing written there. Are you able to make it with some "if firstname is null then display "Anonymous", if is not null then display the actual name (not three dots)
- The same thing happens in the contributions page (Special:AWCTopTen) the users that have written their full name when signing up, works PERFECTLY, shows their first and last name, as well as a link to their contributions... However the IP address ones now show up with no "link" to their contributions, and just show:
3: [[Special:Contributions/222.154.244.205|]] (6)
rather than
1: Brady Dyer (38)
I think this is because its showing the information about where it should link, but as there is no value to display the href tags around, its getting confused... so could you just make it say "Anonymous " with their link to their page.
The links to the Anonymous pages on the menu do work however...
Thanks HEAPS in advance for your help!!
|
|
|
|
|
|
|
| 10:17:53 PM - Wednesday 12th, September 2007 |
|
|
Quote:Brady.Dyer Hey thanks firstly heaps in advance for your help! We're working on this for a Uni Project, and it's great to get your help as this is our first experience with mediawiki, and this extension too No problem. The following forum might be of great help if you havnt already been there:
[URL="http://www.mwusers.com/"]http://www.mwusers.com/[/URL]
<|quote_wikiwords|1|h,o,l,d,e,r,|t,a,g,/>
For PHP these might be of help:
[URL="http://www.php.net/"]http://www.php.net/[/URL]
[URL="http://vbforums.com/forumdisplay.php?f=27"]http://vbforums.com/forumdisplay.php?f=27[/URL] (might be familure from ASP)
The code behind MediaWIki is kind of advanced. They use alot of 'Classess' and it functions like OO (Object Oriented) programing.
Quote:Brady.Dyer Are you able to make it with some "if firstname is null then display "Anonymous", if is not null then display the actual name (not three dots) Sure... anything is possable
Im laying in bed right now, ill take a stab at it tommow.... would be something like... if ($name == "") $name = "Anonymous" You would fill the $name varable before the IF Statment, then the IF Statment will check the $name var, if its empty it will fill it with 'Anonymous' if $name has info in it the IF Statment will just ignore it.
or another way of writing that would be if ($name == ""){
$name = "Anonymous"
} and if you wanted to have 'else' in there you would if (what == whatever){
' Single quote will comment out...
} else {
# pound is another what to comment out stuff...
} With php you have to use a double = when you compiar in IF Statments.
Sorry if this is stuff you already know, figured i would toss it out there just incase you didnt. Wish i could rember some of the ASP stuff i learned, might have been able ot make easyer compairsons.
Quote:Brady.Dyer if (strlen($name) > name_cut ) $name = substr($name,0,name_cut) ."...";
I'm presuming that line of code is saying if the name is there, then display it, if not, then display three dots? Not quite.
[URL="http://www.php.net/manual/en/function.strlen.php"]strlen()[/URL] is a function built into php, String Lenth.
name_cut is defined in the /top_ten/config.file to restrick how many chr's of the name shuold be displayed.
So the IF Statmentif (strlen($name) > name_cut ) compairs the lenth of the "name" to the name_cut and if the name is longer then what the config file says it will chop the name downsubstr($name,0,name_cut) with the [URL="http://www.php.net/manual/en/function.substr.php"]substr()[/URL] (another built in php function) then add the three dots ot the end.
Strange that commenting that out made a difference.
Have fun... and good luck.
_
|
|
~ What was once an opinion, became a fact, to be later proven wrong ~
|
|
|
|
|
| 8:17:40 AM - Thursday 13th, September 2007 |
|
|
Quote:Brady.Dyer Also - We want it to display the First and Last name of the user, and not the actual user's username 
OK... the following will display users Real Names:
Edit the /top_ten/config.php file, add the following to the top:
# Display Full names rather then Nick-Names
define(fullnames, true);
Now to the /top_ten/top_ten.php file.
Search for: $res = $dbw->query("SELECT rev_user, rev_user_text, COUNT(rev_user_text) AS num FROM $table_1 GROUP BY rev_user_text ORDER BY num DESC, rev_user_text LIMIT $s,$e");
while ($row = $dbw->fetchObject( $res )) {
if(strtolower($row->rev_user_text) != "mediawiki default"){
$i ++;
$html .= $wgOut->parse( $i . ": [[Special:Contributions/". $row->rev_user_text . "|". $row->rev_user_text ."]]" ) . "(" . $row->num . ")<br>" ;
}
}
and replace that with:if(fullnames){
$table_2 = $dbw->tableName( 'user' );
$t1 = str_replace("`", "", $table_1);
$t2 = str_replace("`", "", $table_2);
$SQL = "SELECT $t1.rev_user, $t1.rev_user_text, $t2.user_real_name, ";
$SQL .= "COUNT($t1.rev_user_text) AS num ";
$SQL .= "FROM $table_1 LEFT OUTER JOIN $table_2 ";
$SQL .= "ON $t1.rev_user_text=$t2.user_name ";
$SQL .= "GROUP BY $t1.rev_user_text ";
$SQL .= "ORDER BY num DESC, $t1.rev_user_text ";
$SQL .= "LIMIT $s,$e";
$res = $dbw->query($SQL);
} else {
$res = $dbw->query("SELECT rev_user, rev_user_text, COUNT(rev_user_text) AS num FROM $table_1 GROUP BY rev_user_text ORDER BY num DESC, rev_user_text LIMIT $s,$e");
}
while ($row = $dbw->fetchObject( $res )) {
if(strtolower($row->rev_user_text) != "mediawiki default"){
$i ++;
$html .= $wgOut->parse( $i . ": [[Special:Contributions/". $row->rev_user_text . "|". $row->user_real_name ."]]" ) . "(" . $row->num . ")<br>" ;
}
}
In the same file seach for:$res = $dbw->query("SELECT rev_user_text, COUNT(rev_user_text) AS num FROM $table_1 GROUP BY rev_user_text ORDER BY num DESC, rev_user_text LIMIT 0,".num);
while ($row = $dbw->fetchObject( $res )) {
if(strtolower($row->rev_user_text) != "mediawiki default"){
$i ++;
$name = $row->rev_user_text;
if (strlen($name) > name_cut ) $name = substr($name,0,name_cut) ."...";
if ($navbar == "navbar") {
$html .= ( "\n**Special:Contributions/". $row->rev_user_text . "|". $name ." (" . $row->num . ")" ) ;
} elseif ($navbar == "skin_call") {
$html .= "<li>[[Special:Contributions/". $row->rev_user_text . "|". $name ."]]" . " (" . $row->num . ")</li>" ;
} else {
$html .= $i . ": [[Special:Contributions/". $row->rev_user_text . "|". $row->rev_user_text ."]]" . " (" . $row->num . ")<br>" ;
}
}
}
and replace that with:if(fullnames){
$table_2 = $dbw->tableName( 'user' );
$t1 = str_replace("`", "", $table_1);
$t2 = str_replace("`", "", $table_2);
$SQL = "SELECT $t1.rev_user, $t1.rev_user_text, $t2.user_real_name, ";
$SQL .= "COUNT($t1.rev_user_text) AS num ";
$SQL .= "FROM $table_1 LEFT OUTER JOIN $table_2 ";
$SQL .= "ON $t1.rev_user_text=$t2.user_name ";
$SQL .= "GROUP BY $t1.rev_user_text ";
$SQL .= "ORDER BY num DESC, $t1.rev_user_text ";
$SQL .= "LIMIT 0,".num;
$res = $dbw->query($SQL);
} else {
$res = $dbw->query("SELECT rev_user_text, COUNT(rev_user_text) AS num FROM $table_1 GROUP BY rev_user_text ORDER BY num DESC, rev_user_text LIMIT 0,".num);
}
while ($row = $dbw->fetchObject( $res )) {
if(strtolower($row->rev_user_text) != "mediawiki default"){
$i ++;
$name = $row->user_real_name;
if (strlen($name) > name_cut ) $name = substr($name,0,name_cut) ."...";
if ($navbar == "navbar") {
$html .= ( "\n**Special:Contributions/". $row->rev_user_text . "|". $name ." (" . $row->num . ")" ) ;
} elseif ($navbar == "skin_call") {
$html .= "<li>[[Special:Contributions/". $row->rev_user_text . "|". $name ."]]" . " (" . $row->num . ")</li>" ;
} else {
$html .= $i . ": [[Special:Contributions/". $row->rev_user_text . "|". $row->rev_user_text ."]]" . " (" . $row->num . ")<br>" ;
}
}
}
I would make a back up of the top_ten.php just in case, ive also included the top_ten.txt i tested the above with.
- Note... with the file i uploaded here, there could be other changes to it which i forgot about... i guess use it at your own risk :)
I'll get back to you on the Admin group thing... If i dont post back here in the next few days, send me a reminder ;)
Good luck... ohh... all the above was tested on MediaWiki: 1.5.7 so if your using a deifferent version its possable it wont work. Sorry abuot this but its been a while since ive code anything, let-alone MW.
_
|
|
|
AWC's:
2.6.0 MediaWiki - Stand Alone Forum Extension Forum theme style by: AWC
|