Changeset 816 for trunk/Modules/User/Profile.php
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/Profile.php
r797 r816 3 3 class PageUserProfile extends Page 4 4 { 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 5 function SendMail() 6 { 7 $Output = ''; 8 if(array_key_exists('text', $_POST)) 9 if($this->System->User->Licence(LICENCE_ADMIN)) 10 { 11 $Text = $_POST['text']; 12 $Email = $_POST['email']; 13 $Subject = $_POST['subject']; 14 $Output = 'Email: <strong>'.$Email.'</strong><br />'. 15 'Předmět: <strong>'.$Subject.'</strong><br />'. 16 'Text: <strong>'.$Text.'</strong><br />'; 17 18 if(@mail($Email, $Subject, $Text, 'From: '.$this->System->Config['Web']['AdminEmail'].'\nReply-To: '.$this->System->Config['Web']['AdminEmail'].'\nX-Mailer: PHP/')) 19 { 20 $Output .= ShowMessage(T('Message was sent')); 21 } 22 else $Output .= ShowMessage('Nepodařilo se odesat E-mail.', MESSAGE_CRITICAL); 23 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 24 return($Output); 25 } 26 27 function ExportList() 28 { 29 $Output = ''; 30 $Filter = ' WHERE `Export`.`User` = '.($_GET['user'] * 1); 31 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter); 32 $DbRow = $DbResult->fetch_row(); 33 $PageList = GetPageList($DbRow[0]); 34 35 $Output .= '<h3>Exporty</h3>'. 36 $PageList['Output']; 37 38 $TableColumns = array( 39 array('Name' => 'TimeCreate', 'Title' => 'Čas vytvoření'), 40 array('Name' => 'Title', 'Title' => 'Označení'), 41 // array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'), 42 // array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'), 43 array('Name' => 'OutputType', 'Title' => 'Typ výstupu'), 44 array('Name' => 'ClientVersion', 'Title' => 'Verze klienta'), 45 array('Name' => 'UsedCount', 'Title' => 'Prohlédnutí výstupu'), 46 array('Name' => '', 'Title' => 'Akce'), 47 ); 48 $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1); 49 $Output .= '<table class="BaseTable">'. 50 $Order['Output']; 51 52 $DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, `Export`.`ClientVersion` AS `ClientVersionId`, '. 53 53 '(SELECT Version FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersion`, '. 54 54 '(SELECT Name FROM `ExportOutputType` WHERE `ExportOutputType`.`Id`=`Export`.`OutputType`) AS `OutputType`, '. … … 56 56 '(SELECT COUNT(*) FROM `ExportUser` WHERE `ExportUser`.`Export`=`Export`.`Id`) AS `UserCount` FROM `Export` '. 57 57 'LEFT JOIN `User` ON `User`.`ID`=`Export`.`User` '.$Filter.$Order['SQL'].$PageList['SQLLimit']); 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 { 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 } 118 119 58 while($Export = $DbResult->fetch_assoc()) 59 { 60 $Action = '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Export['Id'].'&Tab=0').'">Zobrazit</a> '. 61 '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Export['Id'].'&Tab=7').'">Exportovat</a>'; 62 if($Export['User'] == $this->System->User->Id) $Action .= ' <a href="?Action=Delete&ExportId='.$Export['Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>'; 63 if($this->System->User->Id != null) $Action .= ' <a href="'.$this->System->Link('/export/?Action=Clone&ExportId='.$Export['Id']).'" onclick="return confirmAction(\'Opravdu klonovat položku?\');">Klonovat</a>'; 64 $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'. 65 '<td>'.$Export['Title'].'</td>'. 66 '<td>'.$Export['OutputType'].'</td>'. 67 '<td><a href="'.$this->System->Link('/client-version/?action=item&id='.$Export['ClientVersionId']).'">'.$Export['ClientVersion'].'</a></td>'. 68 '<td>'.$Export['UsedCount'].'</td>'. 69 '<td>'.$Action.'</td></tr>'; 70 } 71 $Output .= '</table>'. 72 $PageList['Output']; 73 74 $Output .= '<div style="text-align: center;"><a href="'.$this->System->Link('/export/').'">Stránka exportů</a></div>'; 75 return($Output); 76 } 77 78 function ShowLastTranslated() 79 { 80 $Count = 20; 81 $Output = '<strong>Poslední překlady:</strong>'; 82 83 $GroupListQuery = 'SELECT `Group`.* FROM `Group`'; 84 $Query = ''; 85 $UnionItems = array(); 86 $DbResult = $this->Database->query($GroupListQuery); 87 if($DbResult->num_rows > 0) 88 { 89 while($DbRow = $DbResult->fetch_assoc()) 90 { 91 $UnionItems[] = 'SELECT `T`.`ID`, `T`.`Take`, `T`.`User`, `T`.`ModifyTime`, `T`.`Group`, `T`.`GroupName` '. 92 'FROM (SELECT `T`.`User`, `T`.`ID`, `T`.`ModifyTime`, '. 93 $DbRow['Id'].' AS `Group`, "'.addslashes($DbRow['Name']).'" AS `GroupName`, `T`.`Take` FROM `'. 94 $DbRow['TablePrefix'].'` AS `T` '. 95 'WHERE (`T`.`Complete` = 1) AND '. 96 '(`T`.`Language` != '.$this->System->Config['OriginalLanguage'].') AND '. 97 '(`T`.`User` = '.($_GET['user'] * 1).') ORDER BY `T`.`ModifyTime` DESC LIMIT '. 98 $Count.') AS `T`'; 99 } 100 $Query = 'SELECT `TT`.*, `User`.`Name` AS `UserName`, `User`.`Id` AS `UserId` '. 101 'FROM ('.implode(' UNION ', $UnionItems).') AS `TT` '. 102 'JOIN `User` ON `User`.`Id` = `TT`.`User` '. 103 'ORDER BY `ModifyTime` DESC LIMIT '.$Count; 104 $DbResult = $this->Database->query($Query); 105 $Output .= '<table class="BaseTable"><tr>'. 106 '<th>Datum</th><th>Nový</th><th>Zdroj</th><th>Skupina</th></tr>'; 107 while($DbRow = $DbResult->fetch_assoc()) 108 { 109 $Output .= '<tr><td>'.HumanDate($DbRow['ModifyTime']).'</td>'. 110 '<td><a href="form.php?group='.$DbRow['Group'].'&ID='.$DbRow['ID'].'">'.$DbRow['ID'].'</a></td>'. 111 '<td><a href="form.php?group='.$DbRow['Group'].'&ID='.$DbRow['Take'].'">'.$DbRow['Take'].'</a></td>'. 112 '<td><a href="TranslationList.php?group='.$DbRow['Group'].'&action=filter">'.$DbRow['GroupName'].'</a></td></tr>'; 113 } 114 $Output .= '</table>'; 115 } 116 return($Output); 117 } 118 119 function ShowLastForum() 120 120 { 121 121 $parser = new HTML_BBCodeParser2(array('filters' => array('Basic','Extended','Images','Links','Lists','Email'))); 122 123 124 125 126 127 128 129 130 131 } 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 122 $Count = 20; 123 $Output = '<strong>Poslední příspěvky ve fóru:</strong>'; 124 125 $Output .= '<div class="shoutbox">'; 126 $DbResult = $this->System->Database->query('SELECT `ForumText`.`Text`, `ForumText`.`Date`, `ForumText`.`UserName`,`ForumThread`.`Text` as `ThreadName`,`ForumText`.`Thread` FROM `ForumText` JOIN `ForumThread` ON `ForumThread`.`ID` = `ForumText`.`Thread` WHERE `ForumText`.`User` = '.($_GET['user'] * 1).' ORDER BY `ForumText`.`Date` DESC LIMIT '.$Count); 127 while($Line = $DbResult->fetch_assoc()) 128 $Output .= '<div><a href="'.$this->System->Link('/forum/?Thread='.$Line['Thread']).'">'.$Line['ThreadName'].'</a><br /><strong>'.$Line['UserName'].'</strong> ('.HumanDate($Line['Date']).'): '.$parser->qparse($Line['Text']).'</div> '; 129 $Output .= '</div>'; 130 return($Output); 131 } 132 133 function ShowProfile() 134 { 135 $Output = ''; 136 $Query = 'SELECT `User`.`Name`, `UserTrace`.`LastLogin`, `UserTrace`.`LastIP`, '. 137 '`User`.`Email`, `UserTrace`.`UserAgent`, `User`.`PreferredVersion`, '. 138 '`User`.`TranslatedCount`, `User`.`Team`, `User`.`ID`, `User`.`Info`, '. 139 '`Team`.`Name` AS `TeamName`, `Language`.`Name` AS `LanguageName`, '. 140 '`ClientVersion`.`Version` AS `Version` FROM `User` '. 141 'LEFT JOIN `UserTrace` ON `UserTrace`.`User` = `User`.`Id` '. 142 'LEFT JOIN `Language` ON `Language`.`Id` = `User`.`Language` '. 143 'LEFT JOIN `Team` ON `Team`.`Id` = `User`.`Team` '. 144 'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id` = `User`.`PreferredVersion` '. 145 'WHERE `User`.`Id` = '.($_GET['user'] * 1); 146 $DbResult = $this->Database->query($Query); 147 if($DbResult->num_rows > 0) 148 { 149 $UserLine = $DbResult->fetch_array(); 150 151 $Output .= 152 '<h3>Překladatel '.$UserLine['Name'].'</h3>'. 153 'Výchozí jazyk: <strong>'.$UserLine['LanguageName'].'</strong><br />'. 154 'Výchozí verze klienta: <a href="'.$this->System->Link('/client-version/?action=item&id='.$UserLine['PreferredVersion']).'"><strong>'.$UserLine['Version'].'</strong></a><br />'. 155 'Poslední připojení: <strong>'.HumanDateTime($UserLine['LastLogin']).'</strong><br />'. 156 'Počet přeložených: <a href="TranslationList.php?user='.$UserLine['ID'].'&state=2&group=0" title="Zobrazit Všechny jeho přeložené texty"><strong>'.$UserLine['TranslatedCount'].'</strong></a><br />'; 157 if($UserLine['TeamName'] != '') 158 $Output .= 'Člen týmu: <a href="team/?action=team&id='.$UserLine['Team'].'"><strong>'.$UserLine['TeamName'].'</strong></a><br />'; 159 //user tags 160 $Query = 'SELECT * FROM `UserTag` '. 161 161 'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '. 162 162 'WHERE `User` = '.($_GET['user'] * 1); 163 163 $DbResult = $this->Database->query($Query); 164 164 if ($DbResult->num_rows != 0) { 165 165 $Output .= 'Překladatel se řídí těmito pravidly:<br />'; … … 174 174 $Output .= '<br /><fieldset><legend>Text profilu:</legend>'.str_replace("\n", '<br/>', $UserLine['Info']).'</fieldset><br/>'; 175 175 176 177 178 179 180 181 182 183 176 $Output .= '<table class="Home"><tr>'. 177 '<td>'.$this->ShowLastTranslated().'</td>'. 178 '<td>'.$this->ExportList().'</td>'. 179 '</tr></table>'; 180 $Output .= '<br />'.$this->ShowLastForum().'<br />'; 181 if($this->System->User->Licence(LICENCE_MODERATOR)) 182 { 183 $Output .= '<fieldset><legend>Moderování</legend>'; 184 184 185 185 $Output .= '<form action="?user='.($_GET['user'] * 1).'" method="post">Přidání tagu uživateli:<br />'; 186 187 186 $Query = 'SELECT * FROM UserTagType'; 187 $DbResult = $this->Database->query($Query); 188 188 while ($UserTag = $DbResult->fetch_array()) { 189 189 //save: 190 190 if (array_key_exists('save', $_POST)) { 191 191 if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) { 192 192 $Query = 'SELECT * FROM `UserTag` '. 193 193 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user']*1); 194 194 $DbResult2 = $this->Database->query($Query); 195 195 if ($DbResult2->num_rows == 0) { 196 196 $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '. 197 197 'VALUES (NULL, '.$UserTag['ID'].' , '.($_GET['user']*1).')'; 198 198 $DbResult2 = $this->Database->query($Query); 199 199 } 200 200 } else { 201 201 $Query = 'DELETE FROM `UserTag` '. 202 202 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user'] * 1); 203 203 $DbResult2 = $this->Database->query($Query); 204 204 } 205 205 } 206 206 207 207 $Query = 'SELECT * FROM `UserTag` '. 208 208 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user'] * 1); 209 209 $DbResult2 = $this->Database->query($Query); 210 210 if ($DbResult2->num_rows != 0) $checked = true; 211 211 else $checked = false; … … 216 216 $Output .= '<input name="save" type="submit" value="Uložit" /></form>'; 217 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 218 $Output .= ' PosledníIP: <strong>'.$UserLine['LastIP'].'</strong><br />'. 219 'Prohlížeč: <strong>'.$UserLine['UserAgent'].'</strong><br />'. 220 'Email: <strong>'.$UserLine['Email'].'</strong><br />'; 221 $Output .= '<br/><form action="user.php" method="post"><div>'. 222 'Napsat E-mail:'. 223 '<input type="text" name="email" value="'.$UserLine['Email'].'" /><br/>'. 224 'Předmět:'. 225 '<input type="text" name="subject" value="'.$this->System->Config['Web']['Title'].'" />'. 226 '<br />'. 227 '<textarea name="text" rows="20" cols="62">'. 228 ''."\n". 229 'S pozdravem '.$this->System->User->Name."\n". 230 '--------------------------------------------------------'."\n". 231 $this->System->Config['Web']['Title'].' '.$this->System->Config['Web']['Host'].$this->System->Link('/')."\n". 232 '</textarea><br/>'. 233 '<input type="submit" value="Odeslat" />'. 234 '</div></form></fieldset>'; 235 } 236 } else $Output .= ShowMessage('Uživatel nenalezen', MESSAGE_CRITICAL); 237 return($Output); 238 } 239 240 function Show() 241 { 242 $this->Title = T('User profile'); 243 $Output = $this->SendMail(); 244 if(array_key_exists('user', $_GET)) 245 { 246 $Output .= $this->ShowProfile(); 247 } else $Output .= ShowMessage('Nevybrán uživatel', MESSAGE_CRITICAL); 248 return($Output); 249 } 250 250 }
Note:
See TracChangeset
for help on using the changeset viewer.