Changeset 816 for trunk/Modules/User
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- Location:
- trunk/Modules/User
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/Options.php
r787 r816 3 3 class PageUserOptions 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 5 function UserOptionsFrom() 6 { 7 $Output = '<form action="Options.php?action=save" method="post"> 8 <fieldset><legend>Nastavení uživatele</legend> 9 <table> 10 <tr><td>Email:</td><td><input type="text" name="Email" value="'.$this->System->User->Email.'" /></td></tr> 11 <tr><td>Původní heslo:</td><td><input type="password" name="OldPass" /></td></tr> 12 <tr><td>Nové heslo:</td><td><input type="password" name="NewPass" /></td></tr> 13 <tr><td>Nové heslo pro potvrzení: </td><td><input type="password" name="NewPass2" /></td></tr> 14 <tr><td>Normálně budu překládat do: </td><td>'.WriteLanguages($this->System->User->Language).'</td></tr> 15 <tr><td>Po uložení překladu přesměrovat: </td><td>'; 16 $Output .= '<select name="redirecting">'. 17 '<option value="0">Nikam</option>'. 18 '<option value="1"'; 19 if($this->System->User->Redirecting == '1') $Output .= ' selected="selected"'; 20 $Output .= '>Na nepřeložené</option>'; 21 $Output .= '<option value="2"'; 22 if($this->System->User->Redirecting == '2') $Output .= ' selected="selected"'; 23 $Output .= '>Na další překlad</option>'; 24 $Output .= '<option value="3"'; 25 if($this->System->User->Redirecting == '3') $Output .= ' selected="selected"'; 26 $Output .= '>Na předchozí překlad</option>'; 27 $Output .= '</select>'; 28 29 $Output .= '</td></tr>'. 30 '<tr><td>Upřednostněná verze klienta: </td><td>'.ClientVersionSelection($this->System->User->PreferredVersion).'</td></tr>'. 31 '<tr><td>Veřejný text profilu:</td><td>'. 32 '<textarea name="info" cols="60" rows="10">'.$this->System->User->Info.'</textarea></td></tr>'; 33 34 35 35 $Output .= '<tr><td>'; 36 37 36 $Query = 'SELECT * FROM UserTagType'; 37 $DbResult = $this->Database->query($Query); 38 38 $Output .= 'Překladatel se řídí zaškrtnutými pravidly:</td><td>'; 39 while ($UserTag = $DbResult->fetch_array()) { 40 39 while ($UserTag = $DbResult->fetch_array()) { 40 $Query = 'SELECT * FROM `UserTag` '. 41 41 //'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '. 42 42 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1); 43 43 $DbResult2 = $this->Database->query($Query); 44 44 if ($DbResult2->num_rows != 0) $checked = true; 45 else $checked = false; 46 47 $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox'); 45 else $checked = false; 46 47 $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox'); 48 48 $Output .= ''.$UserTag['Text'].'<br />'; 49 49 } 50 50 $Output .= '</td></tr>'; 51 52 53 54 55 56 57 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 51 52 $Output .= '<tr><td colspan="2"><input type="submit" value="Uložit" /></td></tr>'. 53 '</table></fieldset>'. 54 '</form>'; 55 56 $Output .= ' <fieldset><legend>Překladatelský tým</legend>'; 57 $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `Team`'); 58 $Output .= '<a href="team/?action=create">Vytvořit tým</a><br />'. 59 '<a href="team/?action=leave">Opustit tým</a><br />'. 60 '<br /><form action="team/" method="get">'. 61 '<input type="hidden" name="action" value="gointeam"/>'. 62 '<select name="id">'; 63 while($LineTeam = $DbResult->fetch_assoc()) 64 { 65 $Output .= '<option value="'.$LineTeam['Id'].'"'; 66 if ($LineTeam['Id'] == $this->System->User->Team) $Output .= ' selected="selected"'; 67 $Output .= '>'.$LineTeam['Name'].'</option>'; 68 } 69 $Output .= '</select> <input type="submit" value="Vstoupit" /> 70 </form>'; 71 $Output .= '</fieldset>'; 72 return($Output); 73 } 74 75 function UserOptionsSave() 76 { 77 $Output = ''; 78 if(array_key_exists('Email', $_POST)) 79 { 80 $Email = $_POST['Email']; 81 $OldPass = $_POST['OldPass']; 82 $NewPass = $_POST['NewPass']; 83 $NewPass2 = $_POST['NewPass2']; 84 $Language = $_POST['Language']; 85 $Redirecting = $_POST['redirecting']; 86 $PreferredVersion = $_POST['ClientVersion']; 87 if($PreferredVersion == '') $PreferredVersion = null; 88 $Info = $_POST['info']; 89 90 // Do user want to change password? 91 if(($OldPass != '') or ($NewPass != '') or ($NewPass2 != '')) 92 { 93 if($NewPass == $NewPass2) 94 { 95 $DbResult = $this->System->Database->query('SELECT `Pass`, '.$this->System->User->CryptPasswordSQL('"'.$OldPass.'"', '`Salt`').' AS `Hash` FROM `User` WHERE `ID`= '.$this->System->User->Id); 96 $DbRow = $DbResult->fetch_assoc(); 97 if($DbRow['Hash'] == $DbRow['Pass']) 98 { 99 // Update password 100 $Salt = $this->System->User->GetPasswordSalt(); 101 $this->Database->query('UPDATE `User` SET `Pass` = '.$this->System->User->CryptPasswordSQL('"'.$NewPass.'"', '"'.$Salt.'"').', `Salt`="'.$Salt.'" WHERE `ID` = '.$this->System->User->Id); 102 $Output .= ShowMessage('Heslo změněno.'); 103 } else $Output .= ShowMessage('Staré heslo neodpovídá.', MESSAGE_CRITICAL); 104 } else $Output .= ShowMessage('Hesla se neshodují.', MESSAGE_CRITICAL); 105 } 106 106 //tag 107 108 109 while ($UserTag = $DbResult->fetch_array()) { 107 $Query = 'SELECT * FROM UserTagType'; 108 $DbResult = $this->Database->query($Query); 109 while ($UserTag = $DbResult->fetch_array()) { 110 110 if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) { 111 111 $Query = 'SELECT * FROM `UserTag` '. 112 112 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1); 113 113 $DbResult2 = $this->Database->query($Query); 114 114 if ($DbResult2->num_rows == 0) { 115 115 $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '. 116 116 'VALUES (NULL, '.$UserTag['ID'].' , '.($this->System->User->Id * 1).')'; 117 117 $DbResult2 = $this->Database->query($Query); 118 118 } 119 119 } else { 120 120 $Query = 'DELETE FROM `UserTag` '. 121 121 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1); 122 122 $DbResult2 = $this->Database->query($Query); 123 123 } 124 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 } 125 126 $this->Database->update('User', '`ID` = '.$this->System->User->Id, array('Email' => $Email, 127 'Language' => $Language, 'Redirecting' => $Redirecting, 'Info' => $Info, 128 'PreferredVersion' => $PreferredVersion)); 129 $Output .= ShowMessage('Úprava nastavení proběhla v pořádku, Email: <b>'.$Email.'</b> Uživatel: <b>'.$this->System->User->Name.'</b>'); 130 $this->System->ModuleManager->Modules['Log']->WriteLog('Úprava nastavení!', LOG_TYPE_USER); 131 $this->System->User->Load(); 132 } else $Output .= ShowMessage('Nezadány údaje.', MESSAGE_CRITICAL); 133 return($Output); 134 } 135 136 function Show() 137 { 138 $this->Title = T('User settings'); 139 $Output = ''; 140 if($this->System->User->Licence(LICENCE_USER)) 141 { 142 if(array_key_exists('action', $_GET) and ($_GET['action'] == 'save')) 143 { 144 $Output .= $this->UserOptionsSave(); 145 } 146 $Output .= $this->UserOptionsFrom(); 147 } else $Output .= ShowMessage('Nejste přihlášený.', MESSAGE_CRITICAL); 148 return($Output); 149 } 150 } -
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 } -
trunk/Modules/User/Registration.php
r801 r816 3 3 class PageUserRegistration extends Page 4 4 { 5 6 7 5 function ShowForm() 6 { 7 if(array_key_exists('sc', $_POST)) $Human = true; 8 8 else $Human = false; 9 10 11 12 13 14 15 16 9 if(array_key_exists('user', $_POST)) $UserName = $_POST['user']; 10 else $UserName = ''; 11 if(array_key_exists('Email', $_POST)) $Email = $_POST['Email']; 12 else $Email = ''; 13 if(array_key_exists('Team', $_POST)) $Team = $_POST['Team']; 14 else $Team = ''; 15 if(array_key_exists('Language', $_POST)) $Language = $_POST['Language']; 16 else $Language = 1; 17 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 53 54 55 56 57 58 59 60 61 62 63 64 18 $Output = '<form action="?" method="post"> 19 <fieldset><legend>'.T('New user registration').'</legend> 20 <table> 21 <tr><td colspan="2">Pozorně si přečtěte <a href="info.php">pokyny k překladu</a> a řiďte se jimi. Překládat je nutno včetně háčků a čárek!<br/><br/></td></tr> 22 <tr> 23 <td>Jsi člověk? </td>'; 24 if($Human) $Checked = ' checked="checked"'; 25 else $Checked = ''; 26 $Output .= '<td><input type="checkbox" name="sc" '.$Checked.'/></td> 27 </tr> 28 <tr> 29 <td>Jméno:</td> 30 <td><input type="text" name="user" value="'.$UserName.'"/></td> 31 </tr> 32 <tr> 33 <td>Heslo:</td> 34 <td><input type="password" name="pass" /></td> 35 </tr> 36 <tr> 37 <td>Potvrzení Hesla: </td> 38 <td><input type="password" name="pass2" /></td> 39 </tr> 40 <tr> 41 <td>Email: </td> 42 <td><input type="text" name="Email" value="'.$Email.'"/></td> 43 </tr> 44 <tr> 45 <td>Normálně budu překládat do: </td> 46 <td>'.WriteLanguages($Language).'</td> 47 </tr> 48 <tr> 49 <td>Patřím do týmu: </td>'; 50 if($Team == '') $Selected = ' selected="selected"'; 51 else $Selected = ''; 52 $Output .= '<td><select name="Team"><option value="0"'.$Selected.'>Žádného</option> 53 '; 54 $DbResult = $this->Database->query('SELECT `Name`, `Id` FROM `Team`'); 55 while($Line = $DbResult->fetch_assoc()) 56 { 57 if($Team == $Line['Id']) $Selected = ' selected="selected"'; 58 else $Selected = ''; 59 $Output .= '<option value="0'.$Line['Id'].'"'.$Selected.'>'.$Line['Name'].'</option>'; 60 } 61 $Output .= '</select></td> 62 </tr>'; 63 $Output .= '</td></tr>'. 64 '<tr><td>Upřednostněná verze klienta: </td><td>'.ClientVersionSelection('').'</td></tr>'; 65 65 66 66 $Output .= '<tr><td>'; 67 68 67 $Query = 'SELECT * FROM UserTagType'; 68 $DbResult = $this->Database->query($Query); 69 69 $Output .= 'Vyberte pravidla, kterými se při překladu chcete řídit:</td><td>'; 70 70 while ($UserTag = $DbResult->fetch_array()) { 71 71 $checked = false; 72 72 73 73 $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox'); … … 77 77 78 78 $Output .= '<tr> 79 80 81 82 83 79 <th><input type="submit" value="Registrovat" /></th> 80 </tr> 81 </table></fieldset></form>'; 82 return($Output); 83 } 84 84 85 85 function CheckRegistration() … … 157 157 } 158 158 159 160 161 162 163 164 159 function Show() 160 { 161 $this->Title = T('User registration'); 162 $Output = ''; 163 if(array_key_exists('user', $_POST)) 164 { 165 165 $Output .= $this->CheckRegistration(); 166 167 168 166 } else $Output .= $this->ShowForm(); 167 return($Output); 168 } 169 169 } -
trunk/Modules/User/User.php
r805 r816 8 8 class ModuleUser extends AppModule 9 9 { 10 11 12 13 14 15 16 17 18 19 20 21 22 23 10 function __construct($System) 11 { 12 parent::__construct($System); 13 $this->Name = 'User'; 14 $this->Version = '1.1'; 15 $this->Creator = 'Chronos'; 16 $this->License = 'GNU/GPL'; 17 $this->Description = 'User and permission management'; 18 $this->Dependencies = array(); 19 } 20 21 function Start() 22 { 23 $this->System->User = new User($this->System); 24 24 $this->System->RegisterPage('userlist.php', 'PageUserList'); 25 26 27 28 29 30 31 32 33 34 25 $this->System->RegisterPage('Options.php', 'PageUserOptions'); 26 $this->System->RegisterPage('registrace.php', 'PageUserRegistration'); 27 $this->System->RegisterPage('user.php', 'PageUserProfile'); 28 $this->System->RegisterPage('login', 'PageUserLogin'); 29 $this->System->RegisterMenuItem(array( 30 'Title' => T('Translators'), 31 'Hint' => 'Seznam registrovaných uživatelů', 32 'Link' => $this->System->Link('/userlist.php'), 33 'Permission' => LICENCE_ANONYMOUS, 34 'Icon' => '', 35 35 ), 0); 36 36 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) 37 37 $this->System->ModuleManager->Modules['Search']->RegisterSearch('user', 38 38 T('Translators'), array('Name'), '`User`', $this->System->Link('/userlist.php?search=')); 39 40 41 42 43 44 39 } 40 41 function ShowOnlineList() 42 { 43 $Output = T('Online translators').':<br />'; 44 $DbResult = $this->System->Database->query('SELECT * FROM ('. 45 45 'SELECT `User`.`Name`, `User`.`ID` FROM `UserOnline` '. 46 47 48 49 50 51 52 53 54 55 46 'JOIN `User` ON `User`.`ID` = `UserOnline`.`User` '. 47 'WHERE (`ActivityTime` >= NOW() - 300) '. 48 'ORDER BY `ActivityTime` DESC ) AS `T` GROUP BY `Name`'); 49 while($DbUser = $DbResult->fetch_assoc()) 50 { 51 $Name = '<a href="'.$this->System->Link('/user.php?user='.$DbUser['ID']).'">'.$DbUser['Name'].'</a>'; 52 $Output .= $Name.'<br />'; 53 } 54 return($Output); 55 } 56 56 } 57 57 58 58 class PageUserLogin extends Page 59 59 { 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 60 function Show() 61 { 62 $Output = '<form action="'.$this->System->Link('/?action=login').'" method="post">'. 63 '<fieldset><legend>'.T('Login').'</legend> 64 <table> 65 <tr> 66 <td>'.T('Name').':</td><td><input type="text" name="LoginUser" size="13" /></td> 67 </tr> 68 <tr> 69 <td>'.T('Password').':</td><td><input type="password" name="LoginPass" size="13" /></td> 70 </tr> 71 <tr> 72 <td>'.T('Stay logged').':</td><td><input type="checkbox" name="StayLogged" /></td> 73 </tr> 74 <tr> 75 <th><input type="submit" value="'.T('Do login').'" /></th> 76 </tr> 77 </table> 78 </fieldset></form>'; 79 return($Output); 80 } 81 81 } 82 82 … … 114 114 function Login($Name, $Password, $StayLogged = false) 115 115 { 116 116 $SID = session_id(); 117 117 $DbResult = $this->Database->query('SELECT `ID` FROM `User` WHERE '. 118 118 'LOWER(`Name`) = LOWER("'.$Name.'") AND `Pass` = '.$this->CryptPasswordSQL('"'.$Password.'"', '`Salt`')); … … 147 147 function Logout() 148 148 { 149 149 $SID = session_id(); 150 150 if($this->Role != LICENCE_ANONYMOUS) 151 151 { … … 162 162 $DbResult = $this->Database->query('SELECT `User`.`PreferredVersion`,`User`.`ID`,`User`.`Team`,`User`.`Redirecting`,`User`.`Email`,`User`.`Info`,'. 163 163 '`User`.`Language`,`User`.`Name`,`User`.`GM`,`ClientVersion`.`Version` AS `PreferredVersionGame` FROM `User` '. 164 164 'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id` = `User`.`PreferredVersion` '. 165 165 'WHERE `User`.`ID` = '.$this->Id); 166 166 if($DbResult->num_rows > 0) … … 230 230 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('ActivityTime' => 'NOW()')); 231 231 } else { 232 233 234 232 if(GetRemoteAddress() != '') $HostName = gethostbyaddr(GetRemoteAddress()); 233 else $HostName = ''; 234 $this->Database->insert('UserOnline', array('SessionId' => $SID, 235 235 'User' => null, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 236 236 'IpAddress' => GetRemoteAddress(), 'HostName' => $HostName, 237 237 'ScriptName' => GetRequestURI())); 238 238 } 239 239 240 240 // Logged permanently? 241 242 243 244 245 246 247 248 249 250 251 252 253 254 } 255 256 241 if(array_key_exists('LoginHash', $_COOKIE)) 242 { 243 $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId']. 244 ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"'); 245 if($DbResult->num_rows > 0) 246 { 247 $DbRow = $DbResult->fetch_assoc(); 248 if(sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash']) 249 { 250 $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"'); 251 $this->Database->query('UPDATE `UserOnline` SET `SessionId`="'.$SID.'" WHERE `Id`='.$DbRow['Id']); 252 } 253 } 254 } 255 256 // Check login 257 257 $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"'); 258 258 $Row = $Query->fetch_assoc(); 259 259 if($Row['User'] != '') 260 260 { 261 261 $this->Id = $Row['User']; 262 262 $this->Load(); 263 263 } else -
trunk/Modules/User/UserList.php
r637 r816 5 5 class PageUserList extends Page 6 6 { 7 8 9 10 11 12 13 14 15 16 17 18 19 20 } else $SearchQuery = ''; 7 function Show() 8 { 9 $this->Title = T('Translators'); 10 ImgLevelUpdate(); 11 12 $Output = ''; 13 if(array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search']; 14 else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = ''; 15 if(array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 16 if($_SESSION['search'] != '') 17 { 18 $SearchQuery = ' AND (`User`.`Name` LIKE "%'.$_SESSION['search'].'%")'; 19 $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), $_SESSION['search']).'</a></div>'; 20 } else $SearchQuery = ''; 21 21 22 22 $TeamFilter = ''; 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 53 54 55 56 57 $Output .= $Order['Output']; 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 } 23 if(array_key_exists('team', $_GET)) 24 { 25 $TeamId = $_GET['team'] * 1; 26 $DbResult = $this->Database->select('Team', 'Name', 'Id='.$TeamId); 27 if($DbResult->num_rows > 0) 28 { 29 $Team = $DbResult->fetch_assoc(); 30 $Output .= '<h3>'.sprintf(T('Users in team %s'), $Team['Name']).'</h3>'; 31 $TeamFilter = ' AND (`Team`='.$_GET['team'].')'; 32 } else { 33 $Output .= ShowMessage(sprintf(T('Team %d not found'), $TeamId), MESSAGE_CRITICAL); 34 } 35 } else 36 { 37 $Output .= '<h3>'.T('User list').'</h3>'; 38 } 39 40 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `User` WHERE 1'.$SearchQuery.$TeamFilter); 41 $DbRow = $DbResult->fetch_row(); 42 $PageList = GetPageList($DbRow[0]); 43 44 $Output .= $PageList['Output']. 45 '<table class="BaseTable">'; 46 47 $TableColumns = array( 48 array('Name' => 'Name', 'Title' => T('Name')), 49 array('Name' => 'TranslatedCount', 'Title' => T('Translated count')), 50 array('Name' => 'XP', 'Title' => T('Level')), 51 array('Name' => 'XP', 'Title' => T('Experience')), 52 //array('Name' => 'GM', 'Title' => T('GM')), 53 array('Name' => 'LastLogin', 'Title' => T('Last logged in')), 54 array('Name' => 'RegistrationTime', 'Title' => T('Registration time')), 55 ); 56 $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1); 57 $Output .= $Order['Output']; 58 59 $Query = 'SELECT `User`.`ID`, `User`.`Name`, `LastLogin`, `GM`, `XP`, `TranslatedCount`, `RegistrationTime` '. 60 'FROM `User` '. 61 'LEFT JOIN `UserTrace` ON `UserTrace`.`User` = `User`.`Id` '. 62 'WHERE 1'.$SearchQuery.$TeamFilter.$Order['SQL'].$PageList['SQLLimit']; 63 64 $DbResult = $this->Database->query($Query); 65 while($Line = $DbResult->fetch_assoc()) 66 { 67 $XP = GetLevelMinMax($Line['XP']); 68 $Output .= '<tr><td><a href="user.php?user='.$Line['ID'].'">'.$Line['Name'].'</a></td>'. 69 '<td style="text-align: center;"><a href="TranslationList.php?user='.$Line['ID'].'&group=0&state=2" title="Zobrazit Všechny jeho přeložené texty">'.$Line['TranslatedCount'].'</a></td>'. 70 '<td>'.$XP['Level'].'</td>'. 71 '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'. 72 //<td>'.$Moderators[$Line['GM']].'</td> 73 '<td>'.HumanDate($Line['LastLogin']).'</td>'. 74 '<td>'.HumanDate($Line['RegistrationTime']).'</td></tr>'; 75 } 76 $Output .= '</table>'. 77 $PageList['Output']; 78 79 return($Output); 80 } 81 81 }
Note:
See TracChangeset
for help on using the changeset viewer.