Changeset 893 for trunk/Modules/User/Options.php
- Timestamp:
- Mar 6, 2023, 1:48:45 AM (21 months ago)
- File:
-
- 1 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'))
Note:
See TracChangeset
for help on using the changeset viewer.