System->GetModule('User'))->User;
$Output = '';
if (array_key_exists('text', $_POST))
if ($User->Licence(LICENCE_ADMIN))
{
$Text = $_POST['text'];
$Email = $_POST['email'];
$Subject = $_POST['subject'];
$Output = 'Email: '.$Email.' '.
'Předmět: '.$Subject.' '.
'Text: '.$Text.' ';
if (@mail($Email, $Subject, $Text, 'From: '.Core::Cast($this->System)->Config['Web']['AdminEmail'].
'\nReply-To: '.Core::Cast($this->System)->Config['Web']['AdminEmail'].'\nX-Mailer: PHP/'))
{
$Output .= ShowMessage(T('Message was sent'));
}
else $Output .= ShowMessage('Nepodařilo se odesat E-mail.', MESSAGE_CRITICAL);
} else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
return $Output;
}
function ExportList()
{
$Output = '';
$User = ModuleUser::Cast($this->System->GetModule('User'))->User;
$Filter = ' WHERE `Export`.`User` = '.($_GET['user'] * 1);
$DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter);
$DbRow = $DbResult->fetch_row();
$PageList = GetPageList($DbRow[0]);
$Output .= '
'.T('Exports').' '.
$PageList['Output'];
$TableColumns = array(
array('Name' => 'TimeCreate', 'Title' => T('Creation time')),
array('Name' => 'Title', 'Title' => T('Name')),
// array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'),
// array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'),
array('Name' => 'OutputType', 'Title' => T('Output type')),
array('Name' => 'ClientVersion', 'Title' => T('Client version')),
array('Name' => 'UsedCount', 'Title' => T('Output inspections')),
array('Name' => '', 'Title' => T('Actions')),
);
$Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1);
$Output .= ''.
$Order['Output'];
$DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, `Export`.`ClientVersion` AS `ClientVersionId`, '.
'(SELECT Version FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersion`, '.
'(SELECT Name FROM `ExportOutputType` WHERE `ExportOutputType`.`Id`=`Export`.`OutputType`) AS `OutputType`, '.
'(SELECT COUNT(*) FROM `ExportGroup` WHERE `ExportGroup`.`Export`=`Export`.`Id`) AS `GroupCount`, '.
'(SELECT COUNT(*) FROM `ExportUser` WHERE `ExportUser`.`Export`=`Export`.`Id`) AS `UserCount` FROM `Export` '.
'LEFT JOIN `User` ON `User`.`ID`=`Export`.`User` '.$Filter.$Order['SQL'].$PageList['SQLLimit']);
while ($Export = $DbResult->fetch_assoc())
{
$Action = ''.T('Show').' '.
''.T('Export').' ';
if ($Export['User'] == $User->Id) $Action .= ' '.T('Remove').' ';
if ($User->Id != null) $Action .= ' '.T('Clone').' ';
$Output .= ''.HumanDate($Export['TimeCreate']).' '.
''.htmlspecialchars($Export['Title']).' '.
''.$Export['OutputType'].' '.
''.$Export['ClientVersion'].' '.
''.$Export['UsedCount'].' '.
''.$Action.' ';
}
$Output .= '
'.
$PageList['Output'];
$Output .= '';
return $Output;
}
function ShowLastTranslated()
{
$Count = 20;
$Output = ''.T('Latest translations').' ';
$GroupListQuery = 'SELECT `Group`.* FROM `Group`';
$Query = '';
$UnionItems = array();
$DbResult = $this->Database->query($GroupListQuery);
if ($DbResult->num_rows > 0)
{
while ($DbRow = $DbResult->fetch_assoc())
{
$UnionItems[] = 'SELECT `T`.`ID`, `T`.`Take`, `T`.`User`, `T`.`ModifyTime`, `T`.`Group`, `T`.`GroupName` '.
'FROM (SELECT `T`.`User`, `T`.`ID`, `T`.`ModifyTime`, '.
$DbRow['Id'].' AS `Group`, "'.addslashes($DbRow['Name']).'" AS `GroupName`, `T`.`Take` FROM `'.
$DbRow['TablePrefix'].'` AS `T` '.
'WHERE (`T`.`Complete` = 1) AND '.
'(`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND '.
'(`T`.`User` = '.($_GET['user'] * 1).') ORDER BY `T`.`ModifyTime` DESC LIMIT '.
$Count.') AS `T`';
}
$Query = 'SELECT `TT`.*, `User`.`Name` AS `UserName`, `User`.`Id` AS `UserId` '.
'FROM ('.implode(' UNION ', $UnionItems).') AS `TT` '.
'JOIN `User` ON `User`.`Id` = `TT`.`User` '.
'ORDER BY `ModifyTime` DESC LIMIT '.$Count;
$DbResult = $this->Database->query($Query);
$Output .= '';
}
return $Output;
}
function ShowLastForum()
{
$Count = 20;
$Output = ''.T('Latest forum posts').': ';
$Output .= '';
return $Output;
}
function ShowProfile()
{
$Output = '';
if (!is_numeric($_GET['user']))
{
$Output .= ShowMessage('Uživatel nenalezen', MESSAGE_CRITICAL);
return $Output;
}
$User = ModuleUser::Cast($this->System->GetModule('User'))->User;
$Query = 'SELECT `User`.`Name`, `UserTrace`.`LastLogin`, `UserTrace`.`LastIP`, '.
'`User`.`Email`, `UserTrace`.`UserAgent`, `User`.`PreferredVersion`, '.
'`User`.`TranslatedCount`, `User`.`Team`, `User`.`ID`, `User`.`Info`, '.
'`Team`.`Name` AS `TeamName`, `Language`.`Name` AS `LanguageName`, '.
'`ClientVersion`.`Version` AS `Version`, `User`.`XP` FROM `User` '.
'LEFT JOIN `UserTrace` ON `UserTrace`.`User` = `User`.`Id` '.
'LEFT JOIN `Language` ON `Language`.`Id` = `User`.`Language` '.
'LEFT JOIN `Team` ON `Team`.`Id` = `User`.`Team` '.
'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id` = `User`.`PreferredVersion` '.
'WHERE `User`.`Id` = '.($_GET['user'] * 1);
$DbResult = $this->Database->query($Query);
if ($DbResult->num_rows > 0)
{
$UserLine = $DbResult->fetch_array();
$XP = GetLevelMinMax($UserLine['XP']);
$Output .=
''.T('Translator').' '.$UserLine['Name'].' '.
T('Default language:').' '.T($UserLine['LanguageName']).' '.
T('Default client version:').' '.$UserLine['Version'].' '.
T('Last logged in:').' '.HumanDateTime($UserLine['LastLogin']).' '.
T('Number of translated:').' '.$UserLine['TranslatedCount'].' '.
T('Level:').' '.$XP['Level'].' '.T('experience:').' '.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).' ';
if ($this->System->ModuleManager->ModuleRunning('Team') and ($UserLine['TeamName'] != ''))
$Output .= T('Member of team:').' '.htmlspecialchars($UserLine['TeamName']).' ';
// User tags
$Query = 'SELECT * FROM `UserTag` '.
'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '.
'WHERE `User` = '.($_GET['user'] * 1);
$DbResult = $this->Database->query($Query);
if ($DbResult->num_rows != 0)
{
$Output .= T('Translator is using this rules:').' ';
$Output .= '';
while ($UserTag = $DbResult->fetch_array())
{
$Output .= ' '.$UserTag['Text'].' ';
}
$Output .= ' ';
}
$UserInfo = $UserLine['Info'];
if ($UserInfo == null) $UserInfo = '';
$UserInfo = htmlspecialchars(str_replace("\n", ' ', $UserInfo));
$Output .= ''.T('Profile text').' '.$UserInfo.' ';
$Output .= ''.
''.$this->ShowLastTranslated().' '.
''.$this->ExportList().' '.
'
';
$Output .= ' '.$this->ShowLastForum().' ';
if ($User->Licence(LICENCE_MODERATOR))
{
$Output .= 'Moderování ';
$Output .= '';
$Output .= ' PosledníIP: '.$UserLine['LastIP'].' '.
'Prohlížeč: '.$UserLine['UserAgent'].' '.
'Email: '.$UserLine['Email'].' ';
$Output .= ' ';
}
} else $Output .= ShowMessage('Uživatel nenalezen', MESSAGE_CRITICAL);
return $Output;
}
function Show(): string
{
$this->Title = T('User profile');
$Output = $this->SendMail();
if (array_key_exists('user', $_GET))
{
$Output .= $this->ShowProfile();
} else $Output .= ShowMessage('Nevybrán uživatel', MESSAGE_CRITICAL);
return $Output;
}
}