source: trunk/Modules/User/UserList.php

Last change on this file was 900, checked in by chronos, 9 months ago
  • Fixed: More form input fields validation.
  • Modified: Code cleanup.
File size: 3.1 KB
Line 
1<?php
2
3class PageUserList extends Page
4{
5 function Show(): string
6 {
7 $this->Title = T('Translators');
8 $Output = '';
9 if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];
10 else if (!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';
11 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
12 if ($_SESSION['search'] != '')
13 {
14 $SearchQuery = ' AND (`User`.`Name` LIKE "%'.$_SESSION['search'].'%")';
15 $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), $_SESSION['search']).'</a></div>';
16 } else $SearchQuery = '';
17
18 $TeamFilter = '';
19 if (array_key_exists('team', $_GET))
20 {
21 $TeamId = $_GET['team'] * 1;
22 $DbResult = $this->Database->select('Team', 'Name', '`Id`='.$TeamId);
23 if ($DbResult->num_rows > 0)
24 {
25 $Team = $DbResult->fetch_assoc();
26 $Output .= '<h3>'.sprintf(T('Users in team %s'), htmlspecialchars($Team['Name'])).'</h3>';
27 $TeamFilter = ' AND (`Team`='.$_GET['team'].')';
28 } else
29 {
30 $Output .= ShowMessage(sprintf(T('Team %d not found'), $TeamId), MESSAGE_CRITICAL);
31 }
32 } else
33 {
34 $Output .= '<h3>'.T('User list').'</h3>';
35 }
36
37 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `User` WHERE 1'.$SearchQuery.$TeamFilter);
38 $DbRow = $DbResult->fetch_row();
39 $PageList = GetPageList($DbRow[0]);
40
41 $Output .= $PageList['Output'].
42 '<table class="BaseTable">';
43
44 $TableColumns = array(
45 array('Name' => 'Name', 'Title' => T('Name')),
46 array('Name' => 'TranslatedCount', 'Title' => T('Translated count')),
47 array('Name' => 'XP', 'Title' => T('Level')),
48 array('Name' => 'XP', 'Title' => T('Experience')),
49 array('Name' => 'LastLogin', 'Title' => T('Last logged in')),
50 array('Name' => 'RegistrationTime', 'Title' => T('Registration time')),
51 );
52 $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1);
53 $Output .= $Order['Output'];
54
55 $Query = 'SELECT `User`.`ID`, `User`.`Name`, `LastLogin`, `GM`, `XP`, `TranslatedCount`, `RegistrationTime` '.
56 'FROM `User` '.
57 'LEFT JOIN `UserTrace` ON `UserTrace`.`User` = `User`.`Id` '.
58 'WHERE 1'.$SearchQuery.$TeamFilter.$Order['SQL'].$PageList['SQLLimit'];
59
60 $DbResult = $this->Database->query($Query);
61 while ($Line = $DbResult->fetch_assoc())
62 {
63 $XP = GetLevelMinMax($Line['XP']);
64 $Output .= '<tr><td><a href="'.$this->System->Link('/user/?user='.$Line['ID']).'">'.$Line['Name'].'</a></td>'.
65 '<td style="text-align: center;"><a href="'.$this->System->Link('/TranslationList.php?user='.$Line['ID'].'&amp;group=0&amp;state=2').'" title="Zobrazit Všechny jeho přeložené texty">'.$Line['TranslatedCount'].'</a></td>'.
66 '<td>'.$XP['Level'].'</td>'.
67 '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'.
68 '<td>'.HumanDate($Line['LastLogin']).'</td>'.
69 '<td>'.HumanDate($Line['RegistrationTime']).'</td></tr>';
70 }
71 $Output .= '</table>'.
72 $PageList['Output'];
73
74 return $Output;
75 }
76}
Note: See TracBrowser for help on using the repository browser.