| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | class PageUserProfile extends Page
|
|---|
| 4 | {
|
|---|
| 5 | function SendMail()
|
|---|
| 6 | {
|
|---|
| 7 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 8 | $Output = '';
|
|---|
| 9 | if (array_key_exists('text', $_POST))
|
|---|
| 10 | if ($User->Licence(LICENCE_ADMIN))
|
|---|
| 11 | {
|
|---|
| 12 | $Text = $_POST['text'];
|
|---|
| 13 | $Email = $_POST['email'];
|
|---|
| 14 | $Subject = $_POST['subject'];
|
|---|
| 15 | $Output = 'Email: <strong>'.$Email.'</strong><br />'.
|
|---|
| 16 | 'Předmět: <strong>'.$Subject.'</strong><br />'.
|
|---|
| 17 | 'Text: <strong>'.$Text.'</strong><br />';
|
|---|
| 18 |
|
|---|
| 19 | if (@mail($Email, $Subject, $Text, 'From: '.Core::Cast($this->System)->Config['Web']['AdminEmail'].
|
|---|
| 20 | '\nReply-To: '.Core::Cast($this->System)->Config['Web']['AdminEmail'].'\nX-Mailer: PHP/'))
|
|---|
| 21 | {
|
|---|
| 22 | $Output .= ShowMessage(T('Message was sent'));
|
|---|
| 23 | }
|
|---|
| 24 | else $Output .= ShowMessage('Nepodařilo se odesat E-mail.', MESSAGE_CRITICAL);
|
|---|
| 25 | } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 26 | return $Output;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | function ExportList()
|
|---|
| 30 | {
|
|---|
| 31 | $Output = '';
|
|---|
| 32 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 33 | $Filter = ' WHERE `Export`.`User` = '.($_GET['user'] * 1);
|
|---|
| 34 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter);
|
|---|
| 35 | $DbRow = $DbResult->fetch_row();
|
|---|
| 36 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 37 |
|
|---|
| 38 | $Output .= '<h3>'.T('Exports').'</h3>'.
|
|---|
| 39 | $PageList['Output'];
|
|---|
| 40 |
|
|---|
| 41 | $TableColumns = array(
|
|---|
| 42 | array('Name' => 'TimeCreate', 'Title' => T('Creation time')),
|
|---|
| 43 | array('Name' => 'Title', 'Title' => T('Name')),
|
|---|
| 44 | // array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'),
|
|---|
| 45 | // array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'),
|
|---|
| 46 | array('Name' => 'OutputType', 'Title' => T('Output type')),
|
|---|
| 47 | array('Name' => 'ClientVersion', 'Title' => T('Client version')),
|
|---|
| 48 | array('Name' => 'UsedCount', 'Title' => T('Output inspections')),
|
|---|
| 49 | array('Name' => '', 'Title' => T('Actions')),
|
|---|
| 50 | );
|
|---|
| 51 | $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1);
|
|---|
| 52 | $Output .= '<table class="BaseTable">'.
|
|---|
| 53 | $Order['Output'];
|
|---|
| 54 |
|
|---|
| 55 | $DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, `Export`.`ClientVersion` AS `ClientVersionId`, '.
|
|---|
| 56 | '(SELECT Version FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersion`, '.
|
|---|
| 57 | '(SELECT Name FROM `ExportOutputType` WHERE `ExportOutputType`.`Id`=`Export`.`OutputType`) AS `OutputType`, '.
|
|---|
| 58 | '(SELECT COUNT(*) FROM `ExportGroup` WHERE `ExportGroup`.`Export`=`Export`.`Id`) AS `GroupCount`, '.
|
|---|
| 59 | '(SELECT COUNT(*) FROM `ExportUser` WHERE `ExportUser`.`Export`=`Export`.`Id`) AS `UserCount` FROM `Export` '.
|
|---|
| 60 | 'LEFT JOIN `User` ON `User`.`ID`=`Export`.`User` '.$Filter.$Order['SQL'].$PageList['SQLLimit']);
|
|---|
| 61 | while ($Export = $DbResult->fetch_assoc())
|
|---|
| 62 | {
|
|---|
| 63 | $Action = '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Export['Id'].'&Tab=0').'">'.T('Show').'</a> '.
|
|---|
| 64 | '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Export['Id'].'&Tab=7').'">'.T('Export').'</a>';
|
|---|
| 65 | if ($Export['User'] == $User->Id) $Action .= ' <a href="?Action=Delete&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Really remove item?').'\');">'.T('Remove').'</a>';
|
|---|
| 66 | if ($User->Id != null) $Action .= ' <a href="'.$this->System->Link('/export/?Action=Clone&ExportId='.$Export['Id']).'" onclick="return confirmAction(\''.T('Really clone item?').'\');">'.T('Clone').'</a>';
|
|---|
| 67 | $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'.
|
|---|
| 68 | '<td>'.htmlspecialchars($Export['Title']).'</td>'.
|
|---|
| 69 | '<td>'.$Export['OutputType'].'</td>'.
|
|---|
| 70 | '<td><a href="'.$this->System->Link('/client-version/?action=item&id='.$Export['ClientVersionId']).'">'.$Export['ClientVersion'].'</a></td>'.
|
|---|
| 71 | '<td>'.$Export['UsedCount'].'</td>'.
|
|---|
| 72 | '<td>'.$Action.'</td></tr>';
|
|---|
| 73 | }
|
|---|
| 74 | $Output .= '</table>'.
|
|---|
| 75 | $PageList['Output'];
|
|---|
| 76 |
|
|---|
| 77 | $Output .= '<div style="text-align: center;"><a href="'.$this->System->Link('/export/').'">'.T('Export page').'</a></div>';
|
|---|
| 78 | return $Output;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | function ShowLastTranslated()
|
|---|
| 82 | {
|
|---|
| 83 | $Count = 20;
|
|---|
| 84 | $Output = '<strong>'.T('Latest translations').'</strong>';
|
|---|
| 85 |
|
|---|
| 86 | $GroupListQuery = 'SELECT `Group`.* FROM `Group`';
|
|---|
| 87 | $Query = '';
|
|---|
| 88 | $UnionItems = array();
|
|---|
| 89 | $DbResult = $this->Database->query($GroupListQuery);
|
|---|
| 90 | if ($DbResult->num_rows > 0)
|
|---|
| 91 | {
|
|---|
| 92 | while ($DbRow = $DbResult->fetch_assoc())
|
|---|
| 93 | {
|
|---|
| 94 | $UnionItems[] = 'SELECT `T`.`ID`, `T`.`Take`, `T`.`User`, `T`.`ModifyTime`, `T`.`Group`, `T`.`GroupName` '.
|
|---|
| 95 | 'FROM (SELECT `T`.`User`, `T`.`ID`, `T`.`ModifyTime`, '.
|
|---|
| 96 | $DbRow['Id'].' AS `Group`, "'.addslashes($DbRow['Name']).'" AS `GroupName`, `T`.`Take` FROM `'.
|
|---|
| 97 | $DbRow['TablePrefix'].'` AS `T` '.
|
|---|
| 98 | 'WHERE (`T`.`Complete` = 1) AND '.
|
|---|
| 99 | '(`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND '.
|
|---|
| 100 | '(`T`.`User` = '.($_GET['user'] * 1).') ORDER BY `T`.`ModifyTime` DESC LIMIT '.
|
|---|
| 101 | $Count.') AS `T`';
|
|---|
| 102 | }
|
|---|
| 103 | $Query = 'SELECT `TT`.*, `User`.`Name` AS `UserName`, `User`.`Id` AS `UserId` '.
|
|---|
| 104 | 'FROM ('.implode(' UNION ', $UnionItems).') AS `TT` '.
|
|---|
| 105 | 'JOIN `User` ON `User`.`Id` = `TT`.`User` '.
|
|---|
| 106 | 'ORDER BY `ModifyTime` DESC LIMIT '.$Count;
|
|---|
| 107 | $DbResult = $this->Database->query($Query);
|
|---|
| 108 | $Output .= '<table class="BaseTable"><tr>'.
|
|---|
| 109 | '<th>'.T('Date').'</th><th>'.T('New').'</th><th>'.T('Source').'</th><th>'.T('Group').'</th></tr>';
|
|---|
| 110 | while ($DbRow = $DbResult->fetch_assoc())
|
|---|
| 111 | {
|
|---|
| 112 | $Output .= '<tr><td>'.HumanDate($DbRow['ModifyTime']).'</td>'.
|
|---|
| 113 | '<td><a href="'.$this->System->Link('/form.php?group='.$DbRow['Group'].'&ID='.$DbRow['ID']).'">'.$DbRow['ID'].'</a></td>'.
|
|---|
| 114 | '<td><a href="'.$this->System->Link('/form.php?group='.$DbRow['Group'].'&ID='.$DbRow['Take']).'">'.$DbRow['Take'].'</a></td>'.
|
|---|
| 115 | '<td><a href="'.$this->System->Link('/TranslationList.php?group='.$DbRow['Group'].'&action=filter').'">'.T($DbRow['GroupName']).'</a></td></tr>';
|
|---|
| 116 | }
|
|---|
| 117 | $Output .= '</table>';
|
|---|
| 118 | }
|
|---|
| 119 | return $Output;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | function ShowLastForum()
|
|---|
| 123 | {
|
|---|
| 124 | $Count = 20;
|
|---|
| 125 | $Output = '<strong>'.T('Latest forum posts').':</strong>';
|
|---|
| 126 |
|
|---|
| 127 | $Output .= '<div class="shoutbox">';
|
|---|
| 128 | $DbResult = $this->System->Database->query('SELECT `ForumText`.`Text`, '.
|
|---|
| 129 | '`ForumText`.`Date`, `ForumText`.`UserName`,`ForumThread`.`Text` AS `ThreadName`, '.
|
|---|
| 130 | '`ForumText`.`Thread` FROM `ForumText` '.
|
|---|
| 131 | 'JOIN `ForumThread` ON `ForumThread`.`ID` = `ForumText`.`Thread` '.
|
|---|
| 132 | 'WHERE `ForumText`.`User` = '.($_GET['user'] * 1).' ORDER BY `ForumText`.`Date` DESC LIMIT '.$Count);
|
|---|
| 133 | while ($Line = $DbResult->fetch_assoc())
|
|---|
| 134 | $Output .= '<div><a href="'.$this->System->Link('/forum/?Thread='.$Line['Thread']).'">'.htmlspecialchars($Line['ThreadName']).'</a><br />'.
|
|---|
| 135 | '<strong>'.$Line['UserName'].'</strong> ('.HumanDate($Line['Date']).'): '.ShowBBcodes(htmlspecialchars($Line['Text'])).'</div> ';
|
|---|
| 136 | $Output .= '</div>';
|
|---|
| 137 | return $Output;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | function ShowProfile()
|
|---|
| 141 | {
|
|---|
| 142 | $Output = '';
|
|---|
| 143 | if (!is_numeric($_GET['user']))
|
|---|
| 144 | {
|
|---|
| 145 | $Output .= ShowMessage('Uživatel nenalezen', MESSAGE_CRITICAL);
|
|---|
| 146 | return $Output;
|
|---|
| 147 | }
|
|---|
| 148 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 149 | $Query = 'SELECT `User`.`Name`, `UserTrace`.`LastLogin`, `UserTrace`.`LastIP`, '.
|
|---|
| 150 | '`User`.`Email`, `UserTrace`.`UserAgent`, `User`.`PreferredVersion`, '.
|
|---|
| 151 | '`User`.`TranslatedCount`, `User`.`Team`, `User`.`ID`, `User`.`Info`, '.
|
|---|
| 152 | '`Team`.`Name` AS `TeamName`, `Language`.`Name` AS `LanguageName`, '.
|
|---|
| 153 | '`ClientVersion`.`Version` AS `Version`, `User`.`XP` FROM `User` '.
|
|---|
| 154 | 'LEFT JOIN `UserTrace` ON `UserTrace`.`User` = `User`.`Id` '.
|
|---|
| 155 | 'LEFT JOIN `Language` ON `Language`.`Id` = `User`.`Language` '.
|
|---|
| 156 | 'LEFT JOIN `Team` ON `Team`.`Id` = `User`.`Team` '.
|
|---|
| 157 | 'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id` = `User`.`PreferredVersion` '.
|
|---|
| 158 | 'WHERE `User`.`Id` = '.($_GET['user'] * 1);
|
|---|
| 159 | $DbResult = $this->Database->query($Query);
|
|---|
| 160 | if ($DbResult->num_rows > 0)
|
|---|
| 161 | {
|
|---|
| 162 | $UserLine = $DbResult->fetch_array();
|
|---|
| 163 |
|
|---|
| 164 | $XP = GetLevelMinMax($UserLine['XP']);
|
|---|
| 165 | $Output .=
|
|---|
| 166 | '<h3>'.T('Translator').' '.$UserLine['Name'].'</h3>'.
|
|---|
| 167 | T('Default language:').' <strong>'.T($UserLine['LanguageName']).'</strong><br />'.
|
|---|
| 168 | T('Default client version:').' <a href="'.$this->System->Link('/client-version/?action=item&id='.$UserLine['PreferredVersion']).'"><strong>'.$UserLine['Version'].'</strong></a><br />'.
|
|---|
| 169 | T('Last logged in:').' <strong>'.HumanDateTime($UserLine['LastLogin']).'</strong><br />'.
|
|---|
| 170 | T('Number of translated:').' <a href="'.$this->System->Link('/TranslationList.php?user='.$UserLine['ID'].'&state=2&group=0').'" title="Zobrazit Všechny jeho přeložené texty"><strong>'.$UserLine['TranslatedCount'].'</strong></a><br />'.
|
|---|
| 171 | T('Level:').' <strong>'.$XP['Level'].'</strong> '.T('experience:').' '.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'<br/>';
|
|---|
| 172 | if ($this->System->ModuleManager->ModuleRunning('Team') and ($UserLine['TeamName'] != ''))
|
|---|
| 173 | $Output .= T('Member of team:').' <a href="'.$this->System->Link('/team/?action=team&id='.$UserLine['Team']).'"><strong>'.htmlspecialchars($UserLine['TeamName']).'</strong></a><br />';
|
|---|
| 174 |
|
|---|
| 175 | // User tags
|
|---|
| 176 | $Query = 'SELECT * FROM `UserTag` '.
|
|---|
| 177 | 'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '.
|
|---|
| 178 | 'WHERE `User` = '.($_GET['user'] * 1);
|
|---|
| 179 | $DbResult = $this->Database->query($Query);
|
|---|
| 180 | if ($DbResult->num_rows != 0)
|
|---|
| 181 | {
|
|---|
| 182 | $Output .= T('Translator is using this rules:').'<br />';
|
|---|
| 183 | $Output .= '<ul>';
|
|---|
| 184 | while ($UserTag = $DbResult->fetch_array())
|
|---|
| 185 | {
|
|---|
| 186 | $Output .= ' <li>'.$UserTag['Text'].'</li>';
|
|---|
| 187 | }
|
|---|
| 188 | $Output .= '</ul>';
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | $UserInfo = $UserLine['Info'];
|
|---|
| 192 | if ($UserInfo == null) $UserInfo = '';
|
|---|
| 193 | $UserInfo = htmlspecialchars(str_replace("\n", '<br/>', $UserInfo));
|
|---|
| 194 | $Output .= '<br /><fieldset><legend>'.T('Profile text').'</legend>'.$UserInfo.'</fieldset><br/>';
|
|---|
| 195 |
|
|---|
| 196 | $Output .= '<table class="Home"><tr>'.
|
|---|
| 197 | '<td>'.$this->ShowLastTranslated().'</td>'.
|
|---|
| 198 | '<td>'.$this->ExportList().'</td>'.
|
|---|
| 199 | '</tr></table>';
|
|---|
| 200 | $Output .= '<br />'.$this->ShowLastForum().'<br />';
|
|---|
| 201 | if ($User->Licence(LICENCE_MODERATOR))
|
|---|
| 202 | {
|
|---|
| 203 | $Output .= '<fieldset><legend>Moderování</legend>';
|
|---|
| 204 |
|
|---|
| 205 | $Output .= '<form action="?user='.($_GET['user'] * 1).'" method="post">Přidání tagu uživateli:<br />';
|
|---|
| 206 | $Query = 'SELECT * FROM `UserTagType`';
|
|---|
| 207 | $DbResult = $this->Database->query($Query);
|
|---|
| 208 | while ($UserTag = $DbResult->fetch_array())
|
|---|
| 209 | {
|
|---|
| 210 | //save:
|
|---|
| 211 | if (array_key_exists('save', $_POST))
|
|---|
| 212 | {
|
|---|
| 213 | if (array_key_exists('Tag'.$UserTag['ID'], $_POST))
|
|---|
| 214 | {
|
|---|
| 215 | $Query = 'SELECT * FROM `UserTag` '.
|
|---|
| 216 | 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user']*1);
|
|---|
| 217 | $DbResult2 = $this->Database->query($Query);
|
|---|
| 218 | if ($DbResult2->num_rows == 0)
|
|---|
| 219 | {
|
|---|
| 220 | $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '.
|
|---|
| 221 | 'VALUES (NULL, '.$UserTag['ID'].' , '.($_GET['user']*1).')';
|
|---|
| 222 | $DbResult2 = $this->Database->query($Query);
|
|---|
| 223 | }
|
|---|
| 224 | } else
|
|---|
| 225 | {
|
|---|
| 226 | $Query = 'DELETE FROM `UserTag` '.
|
|---|
| 227 | 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user'] * 1);
|
|---|
| 228 | $DbResult2 = $this->Database->query($Query);
|
|---|
| 229 | }
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | $Query = 'SELECT * FROM `UserTag` '.
|
|---|
| 233 | 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user'] * 1);
|
|---|
| 234 | $DbResult2 = $this->Database->query($Query);
|
|---|
| 235 | if ($DbResult2->num_rows != 0) $checked = true;
|
|---|
| 236 | else $checked = false;
|
|---|
| 237 |
|
|---|
| 238 | $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox');
|
|---|
| 239 | $Output .= ''.$UserTag['Text'].'<br />';
|
|---|
| 240 | }
|
|---|
| 241 | $Output .= '<input name="save" type="submit" value="Uložit" /></form>';
|
|---|
| 242 |
|
|---|
| 243 | $Output .= ' PosledníIP: <strong>'.$UserLine['LastIP'].'</strong><br />'.
|
|---|
| 244 | 'Prohlížeč: <strong>'.$UserLine['UserAgent'].'</strong><br />'.
|
|---|
| 245 | 'Email: <strong>'.$UserLine['Email'].'</strong><br />';
|
|---|
| 246 | $Output .= '<br/><form action="'.$this->System->Link('/user/').'" method="post"><div>'.
|
|---|
| 247 | 'Napsat E-mail:'.
|
|---|
| 248 | '<input type="text" name="email" value="'.$UserLine['Email'].'" /><br/>'.
|
|---|
| 249 | 'Předmět:'.
|
|---|
| 250 | '<input type="text" name="subject" value="'.Core::Cast($this->System)->Config['Web']['Title'].'" />'.
|
|---|
| 251 | '<br />'.
|
|---|
| 252 | '<textarea name="text" rows="20" cols="62">'.
|
|---|
| 253 | ''."\n".
|
|---|
| 254 | 'S pozdravem '.$User->Name."\n".
|
|---|
| 255 | '--------------------------------------------------------'."\n".
|
|---|
| 256 | Core::Cast($this->System)->Config['Web']['Title'].' '.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/')."\n".
|
|---|
| 257 | '</textarea><br/>'.
|
|---|
| 258 | '<input type="submit" value="Odeslat" />'.
|
|---|
| 259 | '</div></form></fieldset>';
|
|---|
| 260 | }
|
|---|
| 261 | } else $Output .= ShowMessage('Uživatel nenalezen', MESSAGE_CRITICAL);
|
|---|
| 262 | return $Output;
|
|---|
| 263 | }
|
|---|
| 264 |
|
|---|
| 265 | function Show(): string
|
|---|
| 266 | {
|
|---|
| 267 | $this->Title = T('User profile');
|
|---|
| 268 | $Output = $this->SendMail();
|
|---|
| 269 | if (array_key_exists('user', $_GET))
|
|---|
| 270 | {
|
|---|
| 271 | $Output .= $this->ShowProfile();
|
|---|
| 272 | } else $Output .= ShowMessage('Nevybrán uživatel', MESSAGE_CRITICAL);
|
|---|
| 273 | return $Output;
|
|---|
| 274 | }
|
|---|
| 275 | }
|
|---|