public function forgotPasswordFormSubmitted($button) { //Inicializacia $values = $button->getForm()->getValues(); //Nacitanie hodnot formulara $clen = $this->users->findOneBy(['email' => $values->email]); $new_password_requested = StrFTime("%Y-%m-%d %H:%M:%S", Time()); $new_password_key = $this->hasser->HashPassword($values->email . $new_password_requested); if (isset($clen->email) && $clen->email == $values->email) { //Taky clen existuje $templ = new Latte\Engine(); $params = ["site_name" => $this->nazov_stranky, "nadpis" => sprintf($this->trLang('email_reset_nadpis'), $this->nazov_stranky), "email_reset_txt" => $this->trLang('email_reset_txt'), "email_nefunkcny_odkaz" => $this->trLang('email_nefunkcny_odkaz'), "email_pozdrav" => $this->trLang('email_pozdrav'), "nazov" => $this->trLang('forgot_pass'), "odkaz" => 'http://' . $this->nazov_stranky . $this->link("User:resetPassword", $clen->id, $new_password_key)]; $mail = new Message(); $mail->setFrom($this->nazov_stranky . ' <' . $this->clen->users->email . '>')->addTo($values->email)->setSubject($this->trLang('forgot_pass'))->setHtmlBody($templ->renderToString(__DIR__ . '/templates/User/forgot_password-html.latte', $params)); try { $sendmail = new SendmailMailer(); $sendmail->send($mail); $this->users->find($clen->id)->update(['new_password_key' => $new_password_key, 'new_password_requested' => $new_password_requested]); $this->flashMessage($this->trLang('forgot_pass_email_ok'), 'success'); } catch (Exception $e) { $this->flashMessage($this->trLang('send_email_err') . $e->getMessage(), 'danger,n'); } $this->redirect('Homepage:'); } else { //Taky clen neexzistuje $this->flashMessage(sprintf($this->trLang('forgot_pass_user_err'), $values->email), 'danger'); } }
$form->addText('rok', 'Rok narodenia:', 4, 5)->addRule(Form::RANGE, 'Rok narodenia musí byť v rozsahu od %d do %d', [1900, StrFTime("%Y", Time())]); } if ($user_view_fields["telefon"]) { $form->addText('telefon', 'Telefón:', 20, 20); } if ($user_view_fields["poznamka"]) { $form->addText('poznamka', 'Poznámka:', 50, 250); } if ($user_view_fields["pohl"]) { $form->addSelect('pohl', 'Pohlavie:', ['M' => 'Muž', 'Z' => 'Žena']); } $form->onValidate[] = [$this, 'validateEditUserForm']; $form->addSubmit('uloz', 'Ulož')->setAttribute('class', 'btn btn-success')->onClick[] = [$this, 'editUserFormSubmitted']; $form->addSubmit('cancel', 'Cancel')->setAttribute('class', 'btn btn-default')->setValidationScope(FALSE); return $form; } /** Vlastná validácia * @param Nette\Application\UI\Form $button