function signUpFormValidated(\Nette\Forms\BootstrapUIForm $form) { $userCorrects = preg_match("/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_]{4,40}\$/", $form->getValues()->username, $userTest); $member = new \App\Model\MemberModel($this->database); $userExists = $member->getUserName($form->values->username); $emailExists = $member->getEmail($form->values->email); $formVal = $form->getValues(TRUE); if ($userExists > 0) { unset($formVal["username"]); $this->presenter->flashMessage('Uživatelské jméno již existuje', 'error'); } elseif (\Nette\Utils\Validators::isEmail($form->values->email) == FALSE) { unset($formVal["email"]); $this->presenter->flashMessage('Neplatná e-mailová adresa', 'error'); } elseif ($emailExists > 0) { unset($formVal["email"]); $this->presenter->flashMessage('E-mail již existuje', 'error'); } elseif ($userTest == 0) { unset($formVal["username"]); $this->presenter->flashMessage('Uživatelské jméno obsahuje nepovolené znaky', 'error'); } elseif (strlen($form->values->name) < 2) { $this->presenter->flashMessage('Příliš krátké jméno', 'error'); } else { $msg = 1; } if ($msg != 1) { unset($formVal["pwd"], $formVal["pwd2"], $formVal["confirmation"]); $this->presenter->redirect(":Front:Sign:up", $formVal); } }
function editEventFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { $values = $form->getHttpData($form::DATA_TEXT); $date_start = \DateTime::createFromFormat('j. n. Y', $form->values->date_event); $date1 = $date_start->format('Y-m-d'); $date_start = \DateTime::createFromFormat('j. n. Y', $form->values->date_event_end); $date2 = $date_start->format('Y-m-d'); if ($form->values->date_event == '') { $dateEvent = null; } else { if ($form->values->allday) { $dateEvent = $date1 . ' 00:00:00'; } else { $dateEvent = $date1 . ' ' . $values["hour_event"] . ':' . $values["minute_event"]; } } if ($form->values->date_event_end == '') { $dateEventEnd = null; } else { if ($form->values->allday) { $dateEventEnd = $date2 . ' 23:55:00'; } else { $dateEventEnd = $date2 . ' ' . $values["hour_event_end"] . ':' . $values["minute_event_end"]; } } $arr = array("date_event" => $dateEvent, "date_event_end" => $dateEventEnd, "all_day" => $form->values->allday, "price" => $form->values->price, "capacity" => $form->values->capacity, "capacity_start" => $form->values->capacity_start, "time_range" => $form->values->time_range); if ($form->values->contact) { $arr["contacts_id"] = $form->values->contact; } $this->database->table("events")->get($form->values->event_id)->update($arr); $this->presenter->redirect(":Admin:Events:detail", array("id" => $form->values->id)); }
function sendFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { $email = $form->getValues()->email; if ($form->values->layer == 'admin') { $lostPass = $this->database->table("helpdesk_emails")->where("template", "lostpass-admin")->fetch(); } else { $lostPass = $this->database->table("helpdesk_emails")->where("template", "lostpass-member")->fetch(); } if (!\Nette\Utils\Validators::isEmail($email)) { $this->presenter->flashMessage("Adresa je neplatná"); $this->presenter->redirect(":Front:Sign:lostpass"); } $passwordGenerate = \Nette\Utils\Random::generate(12, "987654321zyxwvutsrqponmlkjihgfedcba"); if ($this->database->table('users')->where(array('email' => $email))->count() == 0) { $this->flashMessage("E-mail nenalezen"); $this->presenter->redirect(":Front:Sign:lostpass"); } $member = new \App\Model\MemberModel($this->database); $member->setActivation($email, $passwordGenerate); $latte = new \Latte\Engine(); $latte->setLoader(new \Latte\Loaders\StringLoader()); $params = array('code' => $passwordGenerate, 'email' => $email, 'settings' => $this->presenter->template->settings); $mail = new \Nette\Mail\Message(); $mail->setFrom($this->presenter->template->settings['contacts:email:hq'])->addTo($email)->setSubject("Informace o novém hesle")->setHTMLBody($latte->renderToString($lostPass->body, $params)); $mailer = new \Nette\Mail\SendmailMailer(); $mailer->send($mail); $this->presenter->flashMessage('Informace o zapomenutém hesle odeslány', 'success'); $this->presenter->redirect(this); }
function editSettingsSucceeded(\Nette\Forms\BootstrapUIForm $form) { $values = $form->getHttpData($form::DATA_TEXT); // get value from html input foreach ($values["set"] as $key => $value) { $this->database->table("settings")->where(array("setkey" => $key))->update(array("setvalue" => $value)); } $this->presenter->redirect(this, array("id" => $form->values->category_id)); }
function resetFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { $email = $form->values->email; $emailExistsDb = $this->database->table('users')->where(array('email' => $email, 'activation' => $form->values->code)); if ($emailExistsDb->count() == 0) { $msg = 'Aktivace není platná'; } elseif (strcmp($form->getValues()->password, $form->getValues()->password2) != 0) { $msg = 'Hesla se neshodují'; } else { $msg = 'Vytvořili jste nové heslo. Můžete se přihlásit.'; $this->database->table("users")->where(array("email" => $email))->update(array("activation" => NULL, "password" => \Nette\Security\Passwords::hash($form->getValues()->password))); } $this->presenter->flashMessage($msg, 'success'); $this->presenter->redirect("Sign:in"); }