Changeset 893 for trunk/Modules/User
- Timestamp:
- Mar 6, 2023, 1:48:45 AM (21 months ago)
- Location:
- trunk/Modules/User
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/Options.php
r892 r893 5 5 function UserOptionsFrom() 6 6 { 7 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 7 8 $Output = '<form action="'.$this->System->Link('/options/?action=save').'" method="post"> 8 9 <fieldset><legend>'.T('User settings').'</legend> 9 10 <table> 10 <tr><td>'.T('E-mail').':</td><td><input type="text" name="Email" value="'.$ this->System->User->Email.'" /></td></tr>11 <tr><td>'.T('E-mail').':</td><td><input type="text" name="Email" value="'.$User->Email.'" /></td></tr> 11 12 <tr><td>'.T('Original password').':</td><td><input type="password" name="OldPass" /></td></tr> 12 13 <tr><td>'.T('New password').':</td><td><input type="password" name="NewPass" /></td></tr> 13 14 <tr><td>'.T('New password confirmation').': </td><td><input type="password" name="NewPass2" /></td></tr> 14 <tr><td>'.T('I will translate normally to').': </td><td>'.WriteLanguages($ this->System->User->Language).'</td></tr>15 <tr><td>'.T('I will translate normally to').': </td><td>'.WriteLanguages($User->Language).'</td></tr> 15 16 <tr><td>'.T('After save translation redirect to').': </td><td>'; 16 17 $Output .= '<select name="redirecting">'. 17 18 '<option value="0">'.T('Nowhere').'</option>'. 18 19 '<option value="1"'; 19 if ($ this->System->User->Redirecting == '1') $Output .= ' selected="selected"';20 if ($User->Redirecting == '1') $Output .= ' selected="selected"'; 20 21 $Output .= '>'.T('To untranslated').'</option>'; 21 22 $Output .= '<option value="2"'; 22 if ($ this->System->User->Redirecting == '2') $Output .= ' selected="selected"';23 if ($User->Redirecting == '2') $Output .= ' selected="selected"'; 23 24 $Output .= '>'.T('To next translation').'</option>'; 24 25 $Output .= '<option value="3"'; 25 if ($ this->System->User->Redirecting == '3') $Output .= ' selected="selected"';26 if ($User->Redirecting == '3') $Output .= ' selected="selected"'; 26 27 $Output .= '>'.T('To previous translation').'</option>'; 27 28 $Output .= '</select>'; 28 29 29 30 $Output .= '</td></tr>'. 30 '<tr><td>'.T('Preferred client version').': </td><td>'.ClientVersionSelection($ this->System->User->PreferredVersion).'</td></tr>'.31 '<tr><td>'.T('Preferred client version').': </td><td>'.ClientVersionSelection($User->PreferredVersion).'</td></tr>'. 31 32 '<tr><td>'.T('Public profile text').':</td><td>'. 32 '<textarea name="info" cols="60" rows="10">'.htmlspecialchars($ this->System->User->Info).'</textarea></td></tr>';33 '<textarea name="info" cols="60" rows="10">'.htmlspecialchars($User->Info).'</textarea></td></tr>'; 33 34 34 35 $Output .= '<tr><td>'; … … 40 41 $Query = 'SELECT * FROM `UserTag` '. 41 42 //'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '. 42 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($ this->System->User->Id * 1);43 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1); 43 44 $DbResult2 = $this->Database->query($Query); 44 45 if ($DbResult2->num_rows != 0) $checked = true; … … 64 65 { 65 66 $Output .= '<option value="'.$LineTeam['Id'].'"'; 66 if ($LineTeam['Id'] == $ this->System->User->Team) $Output .= ' selected="selected"';67 if ($LineTeam['Id'] == $User->Team) $Output .= ' selected="selected"'; 67 68 $Output .= '>'.htmlspecialchars($LineTeam['Name']).'</option>'; 68 69 } … … 77 78 { 78 79 $Output = ''; 80 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 79 81 if (array_key_exists('Email', $_POST)) 80 82 { … … 94 96 if ($NewPass == $NewPass2) 95 97 { 96 $DbResult = $this->System->Database->query('SELECT `Pass`, '.$ this->System->User->CryptPasswordSQL('"'.$OldPass.'"', '`Salt`').' AS `Hash` FROM `User` WHERE `ID`= '.$this->System->User->Id);98 $DbResult = $this->System->Database->query('SELECT `Pass`, '.$User->CryptPasswordSQL('"'.$OldPass.'"', '`Salt`').' AS `Hash` FROM `User` WHERE `ID`= '.$User->Id); 97 99 $DbRow = $DbResult->fetch_assoc(); 98 100 if ($DbRow['Hash'] == $DbRow['Pass']) 99 101 { 100 102 // Update password 101 $Salt = $ this->System->User->GetPasswordSalt();102 $this->Database->query('UPDATE `User` SET `Pass` = '.$ this->System->User->CryptPasswordSQL('"'.$NewPass.'"', '"'.$Salt.'"').', `Salt`="'.$Salt.'" WHERE `ID` = '.$this->System->User->Id);103 $Salt = $User->GetPasswordSalt(); 104 $this->Database->query('UPDATE `User` SET `Pass` = '.$User->CryptPasswordSQL('"'.$NewPass.'"', '"'.$Salt.'"').', `Salt`="'.$Salt.'" WHERE `ID` = '.$User->Id); 103 105 $Output .= ShowMessage('Heslo změněno.'); 104 106 } else $Output .= ShowMessage('Staré heslo neodpovídá.', MESSAGE_CRITICAL); … … 113 115 { 114 116 $Query = 'SELECT * FROM `UserTag` '. 115 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($ this->System->User->Id * 1);117 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1); 116 118 $DbResult2 = $this->Database->query($Query); 117 119 if ($DbResult2->num_rows == 0) 118 120 { 119 121 $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '. 120 'VALUES (NULL, '.$UserTag['ID'].' , '.($ this->System->User->Id * 1).')';122 'VALUES (NULL, '.$UserTag['ID'].' , '.($User->Id * 1).')'; 121 123 $DbResult2 = $this->Database->query($Query); 122 124 } … … 124 126 { 125 127 $Query = 'DELETE FROM `UserTag` '. 126 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($ this->System->User->Id * 1);128 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1); 127 129 $DbResult2 = $this->Database->query($Query); 128 130 } 129 131 } 130 132 131 $this->Database->update('User', '`ID` = '.$ this->System->User->Id, array('Email' => $Email,133 $this->Database->update('User', '`ID` = '.$User->Id, array('Email' => $Email, 132 134 'Language' => $Language, 'Redirecting' => $Redirecting, 'Info' => $Info, 133 135 'PreferredVersion' => $PreferredVersion)); 134 $Output .= ShowMessage('Úprava nastavení proběhla v pořádku, Email: <b>'.$Email.'</b> Uživatel: <b>'.$ this->System->User->Name.'</b>');136 $Output .= ShowMessage('Úprava nastavení proběhla v pořádku, Email: <b>'.$Email.'</b> Uživatel: <b>'.$User->Name.'</b>'); 135 137 $this->System->ModuleManager->Modules['Log']->WriteLog('Úprava nastavení!', LOG_TYPE_USER); 136 $ this->System->User->Load();138 $User->Load(); 137 139 } else $Output .= ShowMessage('Nezadány údaje.', MESSAGE_CRITICAL); 138 140 return $Output; … … 143 145 $this->Title = T('User settings'); 144 146 $Output = ''; 145 if ($this->System->User->Licence(LICENCE_USER)) 147 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 148 if ($User->Licence(LICENCE_USER)) 146 149 { 147 150 if (array_key_exists('action', $_GET) and ($_GET['action'] == 'save')) -
trunk/Modules/User/Profile.php
r892 r893 5 5 function SendMail() 6 6 { 7 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 7 8 $Output = ''; 8 9 if (array_key_exists('text', $_POST)) 9 if ($ this->System->User->Licence(LICENCE_ADMIN))10 if ($User->Licence(LICENCE_ADMIN)) 10 11 { 11 12 $Text = $_POST['text']; … … 16 17 'Text: <strong>'.$Text.'</strong><br />'; 17 18 18 if (@mail($Email, $Subject, $Text, 'From: '. $this->System->Config['Web']['AdminEmail'].19 '\nReply-To: '. $this->System->Config['Web']['AdminEmail'].'\nX-Mailer: PHP/'))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/')) 20 21 { 21 22 $Output .= ShowMessage(T('Message was sent')); … … 29 30 { 30 31 $Output = ''; 32 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 31 33 $Filter = ' WHERE `Export`.`User` = '.($_GET['user'] * 1); 32 34 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter); … … 61 63 $Action = '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Export['Id'].'&Tab=0').'">'.T('Show').'</a> '. 62 64 '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Export['Id'].'&Tab=7').'">'.T('Export').'</a>'; 63 if ($Export['User'] == $ this->System->User->Id) $Action .= ' <a href="?Action=Delete&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Really remove item?').'\');">'.T('Remove').'</a>';64 if ($ this->System->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>';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>'; 65 67 $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'. 66 68 '<td>'.htmlspecialchars($Export['Title']).'</td>'. … … 95 97 $DbRow['TablePrefix'].'` AS `T` '. 96 98 'WHERE (`T`.`Complete` = 1) AND '. 97 '(`T`.`Language` != '. $this->System->Config['OriginalLanguage'].') AND '.99 '(`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND '. 98 100 '(`T`.`User` = '.($_GET['user'] * 1).') ORDER BY `T`.`ModifyTime` DESC LIMIT '. 99 101 $Count.') AS `T`'; … … 139 141 { 140 142 $Output = ''; 143 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 141 144 $Query = 'SELECT `User`.`Name`, `UserTrace`.`LastLogin`, `UserTrace`.`LastIP`, '. 142 145 '`User`.`Email`, `UserTrace`.`UserAgent`, `User`.`PreferredVersion`, '. … … 190 193 '</tr></table>'; 191 194 $Output .= '<br />'.$this->ShowLastForum().'<br />'; 192 if ($ this->System->User->Licence(LICENCE_MODERATOR))195 if ($User->Licence(LICENCE_MODERATOR)) 193 196 { 194 197 $Output .= '<fieldset><legend>Moderování</legend>'; … … 239 242 '<input type="text" name="email" value="'.$UserLine['Email'].'" /><br/>'. 240 243 'Předmět:'. 241 '<input type="text" name="subject" value="'. $this->System->Config['Web']['Title'].'" />'.244 '<input type="text" name="subject" value="'.Core::Cast($this->System)->Config['Web']['Title'].'" />'. 242 245 '<br />'. 243 246 '<textarea name="text" rows="20" cols="62">'. 244 247 ''."\n". 245 'S pozdravem '.$ this->System->User->Name."\n".248 'S pozdravem '.$User->Name."\n". 246 249 '--------------------------------------------------------'."\n". 247 $this->System->Config['Web']['Title'].' '.$this->System->Config['Web']['Host'].$this->System->Link('/')."\n".250 Core::Cast($this->System)->Config['Web']['Title'].' '.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/')."\n". 248 251 '</textarea><br/>'. 249 252 '<input type="submit" value="Odeslat" />'. -
trunk/Modules/User/Registration.php
r888 r893 86 86 function CheckRegistration() 87 87 { 88 global $Config;89 90 88 $Output = ''; 89 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 91 90 $ShowForm = true; 92 91 … … 114 113 if (($UserName != '') and ($Pass != '') and ($Pass2 != '')) 115 114 { 116 if (!in_array(strtolower($UserName), $Config['ForbiddedUserNames']))115 if (!in_array(strtolower($UserName), Core::Cast($this->System)->Config['ForbiddedUserNames'])) 117 116 { 118 117 if ($Pass == $Pass2) … … 121 120 $Line = $DbResult->fetch_row(); 122 121 if (!$Line) 123 { 122 { 124 123 if ($Team == 0) $Team = 'NULL'; 125 $ this->System->User->Register($UserName, $Pass, $Email, $Language, $Team, $PreferredVersion);124 $User->Register($UserName, $Pass, $Email, $Language, $Team, $PreferredVersion); 126 125 $Output .= ShowMessage(T('Registration was successful')); 127 126 $Output .= 'Přečtěte si pozorně <a href="'.$this->System->Link('/info/').'">pokyny pro překladání</a> a můžete pak hned začít překládat.'; 128 $ this->System->User->Login($UserName, $Pass);127 $User->Login($UserName, $Pass); 129 128 $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel se zaregistroval: '.$UserName, LOG_TYPE_USER); 130 129 $ShowForm = false; … … 136 135 if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) { 137 136 $Query = 'SELECT * FROM `UserTag` '. 138 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($ this->System->User->Id * 1);137 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1); 139 138 $DbResult2 = $this->Database->query($Query); 140 139 if ($DbResult2->num_rows == 0) { 141 140 $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '. 142 'VALUES (NULL, '.$UserTag['ID'].' , '.($ this->System->User->Id * 1).')';141 'VALUES (NULL, '.$UserTag['ID'].' , '.($User->Id * 1).')'; 143 142 $DbResult2 = $this->Database->query($Query); 144 143 } 145 144 } else { 146 145 $Query = 'DELETE FROM `UserTag` '. 147 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($ this->System->User->Id * 1);146 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1); 148 147 $DbResult2 = $this->Database->query($Query); 149 148 } -
trunk/Modules/User/User.php
r892 r893 1 1 <?php 2 2 3 include_once(dirname(__FILE__).'/ModuleUser.php'); 3 4 include_once(dirname(__FILE__).'/UserList.php'); 4 5 include_once(dirname(__FILE__).'/Options.php'); 5 6 include_once(dirname(__FILE__).'/Registration.php'); 6 7 include_once(dirname(__FILE__).'/Profile.php'); 7 8 class ModuleUser extends Module9 {10 function __construct(System $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 DoStart(): void22 {23 $this->System->User = new User($this->System);24 $this->System->RegisterPage(['users'], 'PageUserList');25 $this->System->RegisterPage(['options'], 'PageUserOptions');26 $this->System->RegisterPage(['registration'], 'PageUserRegistration');27 $this->System->RegisterPage(['user'], 'PageUserProfile');28 $this->System->RegisterPage(['login'], 'PageUserLogin');29 Core::Cast($this->System)->RegisterMenuItem(array(30 'Title' => T('Translators'),31 'Hint' => 'Seznam registrovaných uživatelů',32 'Link' => $this->System->Link('/users/'),33 'Permission' => LICENCE_ANONYMOUS,34 'Icon' => '',35 ), 0);36 if (array_key_exists('Search', $this->System->ModuleManager->Modules))37 $this->System->ModuleManager->Modules['Search']->RegisterSearch('user',38 T('Translators'), array('Name'), '`User`', $this->System->Link('/users/?search='));39 Core::Cast($this->System)->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback'));40 Core::Cast($this->System)->RegisterPageBarItem('Left', 'User', array($this, 'ShowOnlineList'));41 }42 43 function ShowOnlineList()44 {45 $Output = T('Online translators').':<br />';46 $DbResult = $this->System->Database->query('SELECT * FROM ('.47 'SELECT `User`.`Name`, `User`.`ID` FROM `UserOnline` '.48 'JOIN `User` ON `User`.`ID` = `UserOnline`.`User` '.49 'WHERE (`ActivityTime` >= NOW() - 300) '.50 'ORDER BY `ActivityTime` DESC ) AS `T` GROUP BY `Name`');51 while ($DbUser = $DbResult->fetch_assoc())52 {53 $Name = '<a href="'.$this->System->Link('/user/?user='.$DbUser['ID']).'">'.$DbUser['Name'].'</a>';54 $Output .= $Name.'<br />';55 }56 return $Output;57 }58 59 function TopBarCallback()60 {61 $Output = '';62 if ($this->System->User->Licence(LICENCE_USER))63 {64 //$DbResult =$this->Database->query('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$this->System->User->Team);65 //$Team = $DbResult->fetch_assoc();66 //$Output .= ''<span class="MenuItem">Moje překlady: <a href="">Dokončené</a> <a href="">Rozpracované</a> <a href="">Exporty</a> Tým: <a href="">'.$Team['name'].'</a></span>';67 $Output .= $this->System->User->Name.' <a href="'.$this->System->Link('/?action=logout').'">'.T('Logout').'</a>'.68 ' <a href="'.$this->System->Link('/user/?user='.$this->System->User->Id).'">'.T('My page').'</a>'.69 ' <a href="'.$this->System->Link('/options/').'">'.T('Options').'</a>'.70 ' <a title="Vámi přeložené texty" href="'.$this->System->Link('/TranslationList.php?user='.71 $this->System->User->Id.'&group=0&state=2&text=&entry=').'">'.T('Translated').'</a>'.72 ' <a title="Vaše rozpracované text" href="'.$this->System->Link('/TranslationList.php?user='.73 $this->System->User->Id.'&group=0&state=3&text=&entry=').'">'.T('Unfinished').'</a>'.74 ' <a title="Nikým nepřeložené texty" href="'.75 $this->System->Link('/TranslationList.php?user=0&group=0&state=1&text=&entry=').'">'.T('Untranslated').'</a>';76 } else77 {78 $Output .= '<a href="'.$this->System->Link('/login/').'">'.T('Login').'</a> '.79 '<a href="'.$this->System->Link('/registration/').'">'.T('Registration').'</a>';80 }81 return $Output;82 }83 }84 8 85 9 class PageUserLogin extends Page … … 117 41 { 118 42 var $Id; 119 var$Name;43 public string $Name; 120 44 var $Team; 121 45 var $Role; … … 126 50 var $OnlineStateTimeout; 127 51 var $PreferredVersion = 0; 52 public string $PreferredVersionGame; 53 public string $Email; 54 public string $Info; 128 55 129 56 function __construct(System $System)
Note:
See TracChangeset
for help on using the changeset viewer.