Title = 'Uživatel'; $this->Description = 'Uživatel'; $this->ParentClass = 'PagePortal'; } function Panel($Title, $Content, $Menu = array()) { if (count($Menu) > 0) foreach ($Menu as $Item) $Title .= '
'.$Item.'
'; return '
'.$Title.'
'.$Content.'
'; } function ShowContacts() { $Query = 'SELECT `Contact`.`Value`, `Contact`.`Description`, (SELECT `Name` FROM `ContactCategory` WHERE `ContactCategory`.`Id` = `Contact`.`Category`) AS `Category` '. 'FROM `Contact` WHERE `User` = '. Core::Cast($this->System)->User->User['Id']; $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS T'); $DbRow = $DbResult->fetch_row(); $PageList = GetPageList('Contacts', $DbRow[0]); $Output = '
Kontakty
'; $Output .= $PageList['Output']; $Output .= ''; $TableColumns = array( array('Name' => 'Category', 'Title' => 'Skupina'), array('Name' => 'Value', 'Title' => 'Hodnota'), array('Name' => 'Description', 'Title' => 'Popis'), ); $Order = GetOrderTableHeader('Contacts', $TableColumns, 'Value', 0); $Output .= $Order['Output']; $Query = $Query.' '.$Order['SQL'].$PageList['SQLLimit']; $DbResult = $this->Database->query($Query); while ($Contact = $DbResult->fetch_assoc()) { $Output .= ''. ''. ''. ''. ''; } $Output .= '
'.$Contact['Category'].''.$Contact['Value'].''.$Contact['Description'].'
'; $Output .= $PageList['Output']; return $Output; } function ShowUserPanel() { $Output = ''; if (Core::Cast($this->System)->User->User['Id'] != null) { $Actions = ''; foreach ($this->System->ModuleManager->Modules['User']->UserPanel as $Action) { if (is_string($Action[0])) { $Class = new $Action[0]($this->System); $Method = $Action[1]; $Actions .= $Class->$Method(); } else $Actions .= call_user_func($Action).'
'; } $Output .= '
'; $Output .= $this->Panel('Nabídka uživatele', $Actions); $Output .= ''; if (Core::Cast($this->System)->User->User['Id'] != null) { $Form = new Form(Core::Cast($this->System)->FormManager); $Form->SetClass('UserOptions'); $Form->LoadValuesFromDatabase(Core::Cast($this->System)->User->User['Id']); $Form->OnSubmit = '?Action=UserOptionsSave'; $Output .= $Form->ShowViewForm(); //$Output .= '
'.$this->ShowContacts(); } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen'); //$Output .= $this->Panel('Přehled', $this->UserPanel()); $Output .= '
'; } else $Output .= $this->SystemMessage('Oprávnění', 'Nejste přihlášen'); return $Output; } function Show(): string { $Output = ''; if (array_key_exists('Action', $_GET)) { $Action = $_GET['Action']; if ($Action == 'LoginForm') { $Form = new Form(Core::Cast($this->System)->FormManager); $Form->SetClass('UserLogin'); $Form->OnSubmit = '?Action=Login'; $Output .= $Form->ShowEditForm(); $Output .= '
Registrovat se '. 'Obnova zapomenutého hesla
'; } else if ($Action == 'Login') { if (array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST)) { $Form = new Form(Core::Cast($this->System)->FormManager); $Form->SetClass('UserLogin'); $Form->OnSubmit = '?Action=Login'; if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true; else $StayLogged = false; $Result = Core::Cast($this->System)->User->Login($_POST['Username'], $_POST['Password'], $StayLogged); $Output .= $this->SystemMessage('Přihlášení', $Result); if ($Result <> USER_LOGGED_IN) { $Form->LoadValuesFromForm(); $Form->Values['Password'] = ''; $Output .= $Form->ShowEditForm(); $Output .= '
Registrovat se '. 'Obnova zapomenutého hesla
'; } else { //$Output .= '
Za 5 sekund budete přesměrováni na nabídku uživatele
'; //Header('refresh:5;url=?Action=UserMenu'); Header('Location: ?Action=UserMenu'); } } else $Output .= $this->SystemMessage('Přihlášení', 'Nezadány přihlašovací údaje'); } else if ($Action == 'Logout') { if (Core::Cast($this->System)->User->User['Id'] != null) { $Output .= $this->SystemMessage('Odhlášení', Core::Cast($this->System)->User->Logout()); } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen'); } else if ($Action == 'UserOptions') { if (Core::Cast($this->System)->User->User['Id'] != null) { $Form = new Form(Core::Cast($this->System)->FormManager); $Form->SetClass('UserOptions'); $Form->LoadValuesFromDatabase(Core::Cast($this->System)->User->User['Id']); $Form->OnSubmit = '?Action=UserOptionsSave'; $Output .= $Form->ShowEditForm(); } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen'); } else if ($Action == 'UserOptionsSave') { $Form = new Form(Core::Cast($this->System)->FormManager); $Form->SetClass('UserOptions'); $Form->LoadValuesFromForm(); $Form->SaveValuesToDatabase(Core::Cast($this->System)->User->User['Id']); $Output .= $this->SystemMessage('Nastavení', 'Nastavení uloženo.'); $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Nastavení uživatele změněno', $Form->Values['Name']); $Form->LoadValuesFromDatabase(Core::Cast($this->System)->User->User['Id']); $Form->OnSubmit = '?Action=UserOptionsSave'; $Output .= $Form->ShowEditForm(); } else if ($Action == 'UserRegister') { $Form = new Form(Core::Cast($this->System)->FormManager); $Form->SetClass('UserRegister'); //$Form->LoadValuesFromForm(); $Form->OnSubmit = '?Action=UserRegisterSave'; $Output .= $Form->ShowEditForm(); } else if ($Action == 'UserRegisterConfirm') { $Output .= $this->SystemMessage('Potvrzení registrace', Core::Cast($this->System)->User->RegisterConfirm($_GET['User'], $_GET['H'])); } else if ($Action == 'PasswordRecovery') { $Form = new Form(Core::Cast($this->System)->FormManager); $Form->SetClass('PasswordRecovery'); $Form->OnSubmit = '?Action=PasswordRecovery2'; $Output .= $Form->ShowEditForm(); } else if ($Action == 'PasswordRecovery2') { $Form = new Form(Core::Cast($this->System)->FormManager); $Form->SetClass('PasswordRecovery'); $Form->LoadValuesFromForm(); $Result = Core::Cast($this->System)->User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']); $Output .= $this->SystemMessage('Obnova hesla', $Result); if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS) { $Output .= $Form->ShowEditForm(); } } else if ($Action == 'PasswordRecoveryConfirm') { $Output .= $this->SystemMessage('Obnova hesla', Core::Cast($this->System)->User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P'])); } else if ($Action == 'UserRegisterSave') { $Form = new Form(Core::Cast($this->System)->FormManager); $Form->SetClass('UserRegister'); $Form->LoadValuesFromForm(); $Result = Core::Cast($this->System)->User->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']); $Output .= $this->SystemMessage('Registrace nového účtu', $Result); if ($Result <> USER_REGISTRATED) { $Form->OnSubmit = '?Action=UserRegisterSave'; $Output .= $Form->ShowEditForm(); } } else if ($Action == 'UserMenu') { $Output = $this->ShowUserPanel(); } else $Output = $this->ShowMain(); } else $Output = $this->ShowMain(); return $Output; } function ShowMain() { $Output = 'Nebyla vybrána akce'; return $Output; } }