function sendFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { $helpdesk = $this->database->table("helpdesk")->get(1); $helpdesk_admin = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(1); $helpdesk_customer = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(2); $arr = array("subject" => $form->values->name, "email" => $form->values->email, "message" => $form->values->message, "ipaddress" => getenv('REMOTE_ADDR'), "helpdesk_id" => 1, 'date_created' => date("Y-m-d H:i"), 'session_id' => session_id()); if ($this->presenter->user->isLoggedIn()) { $arr["users_id"] = $this->presenter->template->member->id; } if ($helpdesk->fill_phone > 0) { $arr["phone"] = $form->values->phone; } $this->database->table("helpdesk_messages")->insert($arr); $params = array('name' => $form->values->name, 'email' => $form->values->email, 'phone' => $form->values->phone, 'message' => $form->values->message, 'ipaddress' => getenv('REMOTE_ADDR'), 'time' => date("Y-m-d H:i"), 'settings' => $this->presenter->template->settings); $latte = new \Latte\Engine(); $latte->setLoader(new Latte\Loaders\StringLoader()); //$latte->setTempDirectory(__DIR__ . '/../temp'); $email_admin = $latte->renderToString($helpdesk_admin->body, $params); $email_customer = (string) $latte->renderToString($helpdesk_customer->body, $params); $mail = new \Nette\Mail\Message(); $mail->setFrom($this->presenter->template->settings["contacts:email:hq"]); $mail->addTo($this->presenter->template->settings["contacts:email:hq"]); $mail->setHTMLBody($email_customer); $mailA = new \Nette\Mail\Message(); $mailA->setFrom($this->presenter->template->settings["contacts:email:hq"]); $mailA->addTo($form->values->email); $mailA->setHTMLBody($email_admin); $mailer = new \Nette\Mail\SendmailMailer(); $mailer->send($mail); $mailer->send($mailA); $this->presenter->flashMessage($this->presenter->translator->translate('messages.sign.thanksForMessage'), "error"); $this->presenter->redirect(":Front:Contact:default"); }
public function convert($filePathIn, $filePathOut) { $replace = []; $replace['js_app'] = file_get_contents(__DIR__ . "/../../templates/{$this->usedTemplate}/" . "{$this->usedTemplate}.js"); $replace['js_bootstrap'] = file_get_contents(self::PATH_DIST_BOOTSTRAP_JS); $replace['css_app'] = file_get_contents(__DIR__ . "/../../templates/{$this->usedTemplate}/" . "{$this->usedTemplate}.css"); $replace['css_bootstrap'] = file_get_contents(self::PATH_DIST_BOOTSTRAP_CSS); $replace['content'] = $this->mdParser->parse(file_get_contents($filePathIn)); $output['html'] = $this->latte->renderToString(__DIR__ . "/../../templates/{$this->usedTemplate}/" . "{$this->usedTemplate}.latte", $replace); $output['pdf'] = "@todo :)"; $this->fs->write("{$filePathOut}.html", $output['html']); $this->fs->write("{$filePathOut}.pdf", $output['pdf']); }
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); }
/** * @return self */ public function convert($filePathIn, $filePathOut, $formats = ['html', 'pdf']) { $output = ['html' => '', 'pdf' => '']; $replace = ['content' => '', 'js' => '', 'css' => '']; try { $tpl = TemplatesRegistry::get($this->usedTemplate); foreach (['js', 'css'] as $type) { foreach ($tpl[$type] as $file) { if (!is_readable($file)) { throw new \Exception("Cannot load file {$file}."); } $file = file_get_contents($file); $replace[$type] .= $file . "\n"; } } if (file_exists("{$filePathOut}.html")) { unlink("{$filePathOut}.html"); } $replace['content'] = $this->mdParser->parse(file_get_contents($filePathIn)); $output['html'] = $this->latte->renderToString($tpl['layout'], $replace); $this->fs->write("{$filePathOut}.html", $output['html']); if (in_array('pdf', $formats)) { try { $html2pdf = new \HTML2PDF('P', 'A4', 'cs'); $html2pdf->setDefaultFont('dejavusans'); //$html2pdf->addFont('dejavusans'); $html2pdf->pdf->SetDisplayMode('real'); $output['html'] = str_replace('\\xe28087', "  ", $output['html']); $html2pdf->writeHTML($output['html']); $pdf = $html2pdf->Output("{$filePathOut}.pdf", 'S'); $this->fs->write("{$filePathOut}.pdf", $pdf); } catch (Html2PdfException $e) { $formatter = new ExceptionFormatter($e); echo "PDF: " . $formatter->getHtmlMessage(); } } if (!in_array('html', $formats)) { //unlink("{$filePathOut}.html"); } } catch (\InvalidArgumentException $e) { echo $e->getMessage(), "\n"; } return $this; }
/** * Funkce odesílající email s heslem po registraci. * * Maily odesílá podle šablony v presenters/Emaily/novyucet.latte * * @param string $jmeno Jméno člověka * @param string $heslo Heslo * @param string $email Email * @return integer Počet odeslaných mailů */ public function sendRegistrace($jmeno, $heslo, $email) { $mail = new Message(); $mail->setFrom($this->mailerFromAddress)->setSubject('Registrace na stránkách SVJ Čiklova 647/3'); $mail->addTo($email, $jmeno); $latte = new \Latte\Engine(); $params = array('email' => $email, 'heslo' => $heslo); $mail->setHtmlBody($latte->renderToString(self::templateFolder . 'novyucet.latte', $params)); $this->mailer->send($mail); return 1; }
public function formContactSubmitted(Nette\Application\UI\Form $form) { $fd = $form->getValues(); $latte = new \Latte\Engine(); $params = array('text' => $fd->text); $mail = new Nette\Mail\Message(); $mail->setFrom($fd->email)->addTo('*****@*****.**')->setSubject('Svatba ' . $fd->phone)->setHtmlBody($latte->renderToString('../app/presenters/templates/mail.latte', $params)); $this->mailer->send($mail); $this->flashMessage("Email byl odeslán. Ozveme se :-)", "success"); $this->redirect("this"); }
function sendFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { $emailDb = $this->database->table("helpdesk_emails")->get($form->values->id); $latte = new \Latte\Engine(); $params = array('body' => "Body"); $paramsTemplate = array('name' => "John Doe", 'phone' => "+420 123 456 789", 'email' => $this->presenter->template->settings["contacts:email:hq"], 'address' => "42.42.42.256", 'time' => date("j. n. Y H:i:s"), 'message' => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " . "Aliquam purus lacus, tempor sit amet tincidunt ut, finibus non quam. " . "Quisque ac metus quis odio vestibulum consectetur congue id diam. " . "Sed ligula ante, suscipit sed purus ac, dignissim hendrerit nisi.<br /> " . "Praesent scelerisque nulla nec posuere accumsan. Etiam ac libero in " . "ipsum volutpat accumsan. Sed pretium sodales fermentum. Quisque sed feugiat odio. "); $latte->setLoader(new \Latte\Loaders\StringLoader()); $renderedTemplate = $latte->renderToString($emailDb->body, $paramsTemplate); $mail = new \Nette\Mail\Message(); $mail->setFrom($this->presenter->template->settings["site:title"] . ' <' . $this->presenter->template->settings["contacts:email:hq"] . '>')->addTo($form->values->email)->setSubject($emailDb->subject)->setHTMLBody($renderedTemplate); $this->presenter->mailer->send($mail); $this->presenter->redirect(this, array("id" => $form->values->id)); }
/** * @dataProvider translateDataProvider */ public function testTranslate($translated, $latteTpl, $expected, $arguments) { $translatorMock = $this->getMockForAbstractClass('Nette\\Localization\\ITranslator'); $translatorMock->expects($this->any())->method('translate')->will($this->returnValue($translated)); $latte = new Latte\Engine(); $latte->addFilter('translate', array($translatorMock, 'translate')); $latte->onCompile[] = function ($engine) { Nedryse\Latte\Macros\TemplateMacroSet::install($engine->getCompiler()); }; $name = tempnam(sys_get_temp_dir(), 'name'); file_put_contents($name, $latteTpl); $this->assertSame($expected, $latte->renderToString($name, $arguments)); unlink($name); }
/** * @param $to array|string * @param $params array * @param $template string * @return bool|string * @throws \Exception */ public function send($to, $params, $template) { $latte = new \Latte\Engine(); $mail = new Message(); $mail->setFrom($this->fromEmail)->setHtmlBody($latte->renderToString($this->templateDir . '/' . $template, $params)); if (!empty($this->archiveEmail)) { $mail->addBcc($this->archiveEmail); } if (is_string($to)) { $mail->addTo($to); } elseif (is_array($to) && count($to) > 0) { $mail->addTo($to[0]); for ($i = 1; $i < count($to); $i++) { $mail->addCc($to[$i]); } } else { return "Bad 'to' parameter"; } $this->mailer->send($mail); return true; }
public function createSunglassesSucceeded($form, $values) { unset($values['create']); unset($values['next']); $sessionCompetition = $this->getSession('sessionCompetition'); /* if ($this->model->existEmail($values['email'])) { $sessionCompetition->finishMore = true; $this->redirect('default'); } */ $userCompetition = $this->model->saveCompetition($values); var_dump($userCompetition->competitionSunglassesid); $saveEmailData = array("email" => $values['email'], "type" => 1); $this->modelEmails->saveEmail($saveEmailData); $sessionCompetition->finishSucces = true; $latte = new \Latte\Engine(); $params = array('orderId' => 123); $mail = new \Nette\Mail\Message(); $mail->setFrom('CoMa <*****@*****.**>')->addTo('*****@*****.**')->setHtmlBody($latte->renderToString(__DIR__ . "/../presenters/templates/Email/confirmRegistration.latte", $params)); $mailer = new \Nette\Mail\SendmailMailer(); $mailer->send($mail); //$this->redirect('default'); }
function sendLoginFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { $pwd = \Nette\Utils\Random::generate(10); $pwdEncrypted = \Nette\Security\Passwords::hash($pwd); $user = $this->database->table('users')->get($form->values->contact_id); $this->database->table("users")->get($user->id)->update(array("password" => $pwdEncrypted)); if ($form->values->sendmail) { $latte = new \Latte\Engine(); $latte->setLoader(new \Latte\Loaders\StringLoader()); $params = array('username' => $user->username, 'email' => $user->email, 'password' => $pwd, 'settings' => $this->presenter->template->settings); $helpdesk = $this->database->table("helpdesk")->get(4); $helpdesk_resend_login = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(8); $helpdesk_resend = $latte->renderToString($helpdesk_resend_login->body, $params); $mail = new \Nette\Mail\Message(); $mail->setFrom($this->presenter->template->settings["site:title"] . ' <' . $this->presenter->template->settings["contacts:email:hq"] . '>')->addTo($user->email)->setHTMLBody($helpdesk_resend); $mailer = new \Nette\Mail\SendmailMailer(); $mailer->send($mail); } else { $this->presenter->flashMessage("pass", "success"); } $this->presenter->redirect(this, array("id" => $form->values->contact_id, "pdd" => $pwd)); }
public function actionDoc($articleId) { try { $article = $this->articleFacade->findOneById($articleId); $latte = new \Latte\Engine(); $latte->setTempDirectory("../temp/cache"); $content["article"] = $article; $content["basePath"] = $this->getHttpRequest()->getUrl()->getBaseUrl(); $result = $latte->renderToString(__DIR__ . "/templates/export/article/default.latte", $content); $fileName = \Nette\Utils\Strings::webalize($article->url); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment;filename={$fileName}.doc"); header("Content-Transfer-Encoding: binary "); echo $result; exit; } catch (EntityNotFoundException $ex) { \Tracy\Debugger::log($ex); $this->flashMessage("Požadovaný článek nebyl nalezen.", "alert-danger"); $this->redirect("Articles:default"); } }
function signUpFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { $activationCode = \Nette\Utils\Random::generate(12, "987654321zyxwvutsrqponmlkjihgfedcba"); $password = \Nette\Security\Passwords::hash($form->values->pwd); $arr = array("email" => $form->values->email, "username" => $form->values->username, "password" => $password, "activation" => $activationCode, "newsletter" => (bool) $form->values->newsletter, "state" => 0, "users_roles_id" => 4, "date_created" => date("Y-m-d H:i:s")); if ($this->presenter->template->settings['members:groups:enabled']) { $arr["categories_id"] = $form->values->group; } $userId = $this->database->table("users")->insert($arr); $this->database->table("users")->where(array("id" => $userId->id))->update(array("uid" => \Nette\Utils\Strings::padLeft($userId->id, 6, '0'))); if ($this->template->settings['members:signup:contactEnabled']) { $arrContacts = array("categories_id" => 44, "users_id" => $userId, "name" => $form->values->name, "street" => $form->values->street, "city" => $form->values->city, "zip" => $form->values->zip, "countries_id" => 1); if ($this->presenter->template->settings['members:signup:companyEnabled']) { $arrContacts["company"] = $form->values->company; $arrContacts["vatin"] = $form->values->vatin; $arrContacts["vatid"] = $form->values->vatid; } $contactId = $this->database->table("contacts")->insert($arrContacts); $this->database->table("contacts")->get($contactId)->update(array("order" => $contactId)); } if ($form->values->vatin) { $ares = new \h4kuna\Ares\Ares(); $aresArr = $ares->loadData('')->toArray(); } $latte = new \Latte\Engine(); $latte->setLoader(new \Latte\Loaders\StringLoader()); $params = array('username' => $form->values->username, 'activationCode' => $activationCode, 'settings' => $this->presenter->template->settings, 'form' => $form, 'aresArr' => $aresArr); $helpdesk = $this->database->table("helpdesk")->get(3); $helpdesk_signup_member = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(5); $helpdesk_signup_confirmbyadmin = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(6); $helpdesk_signup_adminconfirm = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(7); try { if ($this->presenter->template->settings['members:signup:confirmByAdmin']) { $email_signup_confirmbyamin = $latte->renderToString($helpdesk_signup_confirmbyadmin->body, $params); $email_signup_adminconfirm = $latte->renderToString($helpdesk_signup_adminconfirm->body, $params); $mail = new \Nette\Mail\Message(); $mail->setFrom($this->presenter->template->settings['contacts:email:hq'])->addTo($form->values->email)->setHTMLBody($email_signup_confirmbyamin); $this->presenter->mailer->send($mail); $mailA = new \Nette\Mail\Message(); $mailA->setFrom($this->presenter->template->settings['contacts:email:hq'])->addTo($this->presenter->template->settings['contacts:email:hq'])->setHTMLBody($email_signup_adminconfirm); $this->presenter->mailer->send($mailA); $this->flashMessage('Registrace byla dokončena. Po ověření Vám bude zaslán e-mail, po kterém se můžete přihlásit', 'note'); } else { $email_signup_member = $latte->renderToString($helpdesk_signup_member->body, $params); $mail = new \Nette\Mail\Message(); $mail->setFrom($this->presenter->template->settings['contacts:email:hq'])->addTo($form->values->email)->setHTMLBody($email_signup_member); $this->presenter->mailer->send($mail); $this->presenter->flashMessage('Vaše registrace proběhla úspěšně. Po ověření se můžete přihlásit.', 'note'); } $this->presenter->redirect(":Front:Sign:ed"); } catch (\Nette\Mail\SmtpException $e) { $this->presenter->flashMessage('E-mail nebyl odeslán' . $e->getMessage(), 'error'); $this->presenter->redirect(":Front:Sign:up"); } }
/** * Returns HTML code of panel. * @return mixed */ public function getPanel() { if ($this->countAll === 0 && $this->hideEmpty) { return; } $this->processMessage(); $latte = new \Latte\Engine(); $latte->setTempDirectory($this->fileMailer->getTempDirectory()); return $latte->renderToString(__DIR__ . '/MailPanel.latte', ['messages' => $this->messages, 'countNew' => $this->countNew, 'countAll' => $this->countAll, 'show' => $this->show]); }
function setBodyLatte($name, $pars = array()) { $latte = new \Latte\Engine(); $this->Message->setHtmlBody($latte->renderToString($name, $pars)); }
private function sendDeleteMail($email) { $latte = new \Latte\Engine(); $mail = new Message(); $mail->setFrom('*****@*****.**', 'Ololoď')->addTo($email)->addReplyTo('*****@*****.**', 'Ololoď')->setSubject('Ololoď – rezervace zrušena')->setHtmlBody($latte->renderToString(__DIR__ . '/../presenters/templates/Emails/deleted.latte')); $mailer = new SmtpMailer(array('host' => 'mail.gigaserver.cz', 'username' => '*****@*****.**', 'password' => 'wu6raCet', 'secure' => 'ssl')); $mailer->send($mail); }