System->GetModule('User'))->User; $Output = '
'.T('User settings').' '. ''. ''; $Output .= ''; $Output .= ''. '
'.T('E-mail').':
'.T('Original password').':
'.T('New password').':
'.T('New password confirmation').':
'.T('I will translate normally to').': '.WriteLanguages($User->Language).'
'.T('After save translation redirect to').': '; $Output .= ''; $Output .= '
'.T('Preferred client version').': '.ClientVersionSelection($User->PreferredVersion).'
'.T('Public profile text').':'. '
'; $Query = 'SELECT * FROM UserTagType'; $DbResult = $this->Database->query($Query); $Output .= T('User obey selected rules').':'; while ($UserTag = $DbResult->fetch_array()) { $Query = 'SELECT * FROM `UserTag` '. //'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '. 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1); $DbResult2 = $this->Database->query($Query); if ($DbResult2->num_rows != 0) $checked = true; else $checked = false; $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox'); $Output .= ''.$UserTag['Text'].'
'; } $Output .= '
'. '
'; $Output .= '
'.T('Translation team').''; $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `Team`'); $Output .= ''.T('Create team').'
'. ''.T('Leave team').'
'. '
'. ''. ''. ''. '
'; '
'; return $Output; } function UserOptionsSave() { $Output = ''; $User = ModuleUser::Cast($this->System->GetModule('User'))->User; if (array_key_exists('Email', $_POST)) { $Email = $_POST['Email']; $OldPass = $_POST['OldPass']; $NewPass = $_POST['NewPass']; $NewPass2 = $_POST['NewPass2']; $Language = $_POST['Language']; $Redirecting = $_POST['redirecting']; $PreferredVersion = $_POST['ClientVersion']; if ($PreferredVersion == '') $PreferredVersion = null; $Info = $_POST['info']; // Do user want to change password? if (($OldPass != '') or ($NewPass != '') or ($NewPass2 != '')) { if ($NewPass == $NewPass2) { $DbResult = $this->System->Database->query('SELECT `Pass`, '.$User->CryptPasswordSQL('"'.$OldPass.'"', '`Salt`').' AS `Hash` FROM `User` WHERE `ID`= '.$User->Id); $DbRow = $DbResult->fetch_assoc(); if ($DbRow['Hash'] == $DbRow['Pass']) { // Update password $Salt = $User->GetPasswordSalt(); $this->Database->query('UPDATE `User` SET `Pass` = '.$User->CryptPasswordSQL('"'.$NewPass.'"', '"'.$Salt.'"').', `Salt`="'.$Salt.'" WHERE `ID` = '.$User->Id); $Output .= ShowMessage('Heslo změněno.'); } else $Output .= ShowMessage('Staré heslo neodpovídá.', MESSAGE_CRITICAL); } else $Output .= ShowMessage('Hesla se neshodují.', MESSAGE_CRITICAL); } //tag $Query = 'SELECT * FROM UserTagType'; $DbResult = $this->Database->query($Query); while ($UserTag = $DbResult->fetch_array()) { if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) { $Query = 'SELECT * FROM `UserTag` '. 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1); $DbResult2 = $this->Database->query($Query); if ($DbResult2->num_rows == 0) { $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '. 'VALUES (NULL, '.$UserTag['ID'].' , '.($User->Id * 1).')'; $DbResult2 = $this->Database->query($Query); } } else { $Query = 'DELETE FROM `UserTag` '. 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1); $DbResult2 = $this->Database->query($Query); } } $this->Database->update('User', '`ID` = '.$User->Id, array('Email' => $Email, 'Language' => $Language, 'Redirecting' => $Redirecting, 'Info' => $Info, 'PreferredVersion' => $PreferredVersion)); $Output .= ShowMessage('Úprava nastavení proběhla v pořádku, Email: '.$Email.' Uživatel: '.$User->Name.''); $this->System->ModuleManager->Modules['Log']->WriteLog('Úprava nastavení!', LOG_TYPE_USER); $User->Load(); } else $Output .= ShowMessage('Nezadány údaje.', MESSAGE_CRITICAL); return $Output; } function Show(): string { $this->Title = T('User settings'); $Output = ''; $User = ModuleUser::Cast($this->System->GetModule('User'))->User; if ($User->Licence(LICENCE_USER)) { if (array_key_exists('action', $_GET) and ($_GET['action'] == 'save')) { $Output .= $this->UserOptionsSave(); } $Output .= $this->UserOptionsFrom(); } else $Output .= ShowMessage('Nejste přihlášený.', MESSAGE_CRITICAL); return $Output; } }