Changeset 816 for trunk/Modules/User/Options.php
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- File:
-
- 1 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 }
Note:
See TracChangeset
for help on using the changeset viewer.