forum.webdiplomacy.net
http://forum.webdiplomacy.net/

Users list table newone
http://forum.webdiplomacy.net/viewtopic.php?f=27&t=980
Page 1 of 1

Author:  Flame [ Wed Oct 31, 2012 8:49 am ]
Post subject:  Users list table newone

Dear sirs!

I've got a suggestion to develop the page containing list of users like Oliver's (Sleepcap's) variants list table (I've installed it yesterday to my Diplomail.Ru with some changes - watch it here.

The users table should consist of the following columns (which are mostly taken from profile.php script):
- Increment number
- ID
- Nickname
- Registration date
- Status (Admin/Moder/User ...)
- Rank (Pro/Mastermind ...)
- Online mark
- Avaliable points
- Points in play
- Total points
- Defeated
- Won
- Drawn
- Survived
- Resigned
- Total (finished)
- Playing
- Left games
- Reliability

Maybe you'll add some other columns.
What do you guys think about all this?

Author:  Sleepcap [ Thu Nov 01, 2012 11:38 am ]
Post subject:  Re: Users list table newone

Here is some code to get you started.
Most is taken from the profile.php. There you can take a look what other information you want to add....

Code:
<?php

require_once('header.php');

libHTML::starthtml();

print libHTML::pageTitle('webDiplomacy variants','A list of the variants available on this server, with credits and information on variant-specific rules.');
print '<script type="text/javascript" src="contrib/tablekit/tablekit.js"></script>';

print '<style type="text/css">
      .sortcol { cursor: pointer;
         padding-right: 20px;
         background-repeat: no-repeat;
         background-position: right center; }
      .sortasc {
         background-color: #DDFFAC;
         background-image: url(contrib/tablekit/up.gif); }
      .sortdesc {
         background-color: #B9DDFF;
         background-image: url(contrib/tablekit/down.gif); }
      .nosort { cursor: default;}
   </style>';
   
print '<TABLE class="sortable">
         <THEAD>
            <TH style="border: 1px solid #000" class="sortfirstasc">ID</TH>
            <TH style="border: 1px solid #000">Nick</TH>
            <TH style="border: 1px solid #000">Reg.</TH>
            <TH style="border: 1px solid #000">Rank</TH>
            <TH style="border: 1px solid #000">Avaliable points</TH>
            <TH style="border: 1px solid #000">Points in play</TH>
            <TH style="border: 1px solid #000">Total points</TH>
            <TH style="border: 1px solid #000">Defeated</TH>
            <TH style="border: 1px solid #000">Won</TH>
            <TH style="border: 1px solid #000">Drawn</TH>
            <TH style="border: 1px solid #000">Survived</TH>
            <TH style="border: 1px solid #000">Resigned</TH>
         </THEAD>
         <TFOOT>
            <tr style="border: 1px solid #666"><td colspan=6><b>**Rating</b> = ("players" x "games played") - <b>**Hot</b> = Number of active games</td></tr>
         </TFOOT>';

$tabl = $DB->sql_tabl("SELECT id FROM wD_Users WHERE id > 4 order BY id");

while ( list($userID) = $DB->tabl_row($tabl) )
{
   $UserProfile = new User($userID);
   $rankingDetails = $User->rankingDetails();
   $showAnon = ($User->id == $User->id || $User->type['Moderator']);

   print '<TR>
         <TD style="border: 1px solid #666">'.$userID.'</TD>
         <TD style="border: 1px solid #666">'.$UserProfile->username.'</TD>
         <TD style="border: 1px solid #666">'.gmstrftime("%d %b %y", $UserProfile->timeJoined).'</TD>
         <TD style="border: 1px solid #666">'.$rankingDetails['position'].'</TD>
         <TD style="border: 1px solid #666">'.$UserProfile->points.' '.libHTML::points().'</TD>
         <TD style="border: 1px solid #666">'.($rankingDetails['worth']-$UserProfile->points-($showAnon ? 0 : $rankingDetails['anon']['points'])).' '.libHTML::points().'</TD>
         <TD style="border: 1px solid #666">'.$rankingDetails['worth'].' '.libHTML::points().'</TD>
         <TD style="border: 1px solid #666">'.(isset($rankingDetails['stats']['Defeated'])?$rankingDetails['stats']['Defeated']:'0').'</TD>
         <TD style="border: 1px solid #666">'.(isset($rankingDetails['stats']['Won'])?$rankingDetails['stats']['Won']:'0').'</TD>
         <TD style="border: 1px solid #666">'.(isset($rankingDetails['stats']['Drawn'])?$rankingDetails['stats']['Drawn']:'0').'</TD>
         <TD style="border: 1px solid #666">'.(isset($rankingDetails['stats']['Survived'])?$rankingDetails['stats']['Survived']:'0').'</TD>
         <TD style="border: 1px solid #666">'.(isset($rankingDetails['stats']['Resigned'])?$rankingDetails['stats']['Resigned']:'0').'</TD>
      </TR>';
}
print '</TABLE>';         

print '</div>';
libHTML::footer();

?>

Author:  Flame [ Fri Nov 02, 2012 6:42 am ]
Post subject:  Re: Users list table newone

$rankingDetails(); - returns the same for different users. Damn! :?
Because $UserID is not changing during the script run.

http://diplomail.ru/users.php

By the way where is located $rankingDetails(); ?
And what does it mean $showAnon?

Author:  Flame [ Fri Nov 02, 2012 6:56 am ]
Post subject:  Re: Users list table newone

Flame wrote:
$rankingDetails(); - returns the same for different users. Damn! :?
Because $UserID is not changing during the script run.

http://diplomail.ru/users.php

By the way where is located $rankingDetails(); ?

ha. It takes the UserID of currently logged user - That is my own ID.

SORRY!! I've already solved this.
$rankingDetails = $UserProfile->rankingDetails();
And so on...

Thanx.

Author:  Sleepcap [ Fri Nov 02, 2012 7:50 am ]
Post subject:  Re: Users list table newone

Glad you found the solution on your own.
Some explainations:
Code:
   $UserProfile = new User($userID);

This creates a new User-Object with from the User with the ID $userID.
You can than use all functions as defined in "objects/user.php" on this object.

Code:
   $rankingDetails = $User->rankingDetails();

This function is in objects/user.php (about line 800)

Code:
   $showAnon = ($User->id == $User->id || $User->type['Moderator']);

The rankingDetails()-function counts the points in anon games separate, so it can hide the information about anon games if not seen by a moderator.
The $showAnon is a trigger that checks if the User is viewing his own profile, or if a Mod is looking at the page...

later in the code:
Code:
($rankingDetails['worth']-$UserProfile->points-($showAnon ? 0 : $rankingDetails['anon']['points']))

It checks this $showAnon and substracts the "anon"-points if it's viewed by a normal user.

You can get even more information from the profile.php script.

Oliver

Author:  Flame [ Fri Nov 02, 2012 8:25 am ]
Post subject:  Re: Users list table newone

Oli!

And how to calculate winning percentage? Lose percentage? Draw? Surviving percentage?
http://diplomail.ru/users.php

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/