forum.webdiplomacy.net

webDip dev coordination forum / public access todo list
It is currently Mon Oct 23, 2017 5:00 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Users list table newone
PostPosted: Wed Oct 31, 2012 8:49 am 
Offline

Joined: Sat Jan 14, 2012 7:08 am
Posts: 48
Location: Ukraine
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?

_________________
"There is nothing in the world more majestic than this idiotic Galicia" (GAL)
Jaroslav Hasek


Top
 Profile  
 
PostPosted: Thu Nov 01, 2012 11:38 am 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
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();

?>


Top
 Profile  
 
PostPosted: Fri Nov 02, 2012 6:42 am 
Offline

Joined: Sat Jan 14, 2012 7:08 am
Posts: 48
Location: Ukraine
$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?

_________________
"There is nothing in the world more majestic than this idiotic Galicia" (GAL)
Jaroslav Hasek


Last edited by Flame on Fri Nov 02, 2012 7:22 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Nov 02, 2012 6:56 am 
Offline

Joined: Sat Jan 14, 2012 7:08 am
Posts: 48
Location: Ukraine
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.

_________________
"There is nothing in the world more majestic than this idiotic Galicia" (GAL)
Jaroslav Hasek


Top
 Profile  
 
PostPosted: Fri Nov 02, 2012 7:50 am 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
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


Top
 Profile  
 
PostPosted: Fri Nov 02, 2012 8:25 am 
Offline

Joined: Sat Jan 14, 2012 7:08 am
Posts: 48
Location: Ukraine
Oli!

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

_________________
"There is nothing in the world more majestic than this idiotic Galicia" (GAL)
Jaroslav Hasek


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group