/** * Create a new template either with a file-based Twig template, or a Twig string. * @global type $wpdb * @param string|false $templateName * @param string|false $templateString */ public function __construct($templateName = false, $templateString = false) { $this->templateName = $templateName; $this->templateString = $templateString; $this->transientNotices = 'notices'; $notices = isset($_SESSION[$this->transientNotices]) ? $_SESSION[$this->transientNotices] : array(); $this->data = array('tabulate_version' => Config::version(), 'notices' => $notices, 'baseurl' => Config::baseUrl(), 'debug' => Config::debug(), 'site_title' => Config::siteTitle()); $this->loader = new \Twig_Loader_Filesystem([__DIR__ . '/../templates']); }
public function __construct($template) { $this->template = $template; $config = new Config(); $this->data['app_title'] = App::name() . ' ' . App::version(); $this->data['app_version'] = App::version(); $this->data['mode'] = $config->mode(); $this->data['baseurl'] = $config->baseUrl(); $this->data['baseurl_full'] = $config->baseUrl(true); $this->data['site_title'] = $config->siteTitle(); $this->data['alerts'] = isset($_SESSION['alerts']) ? $_SESSION['alerts'] : array(); $_SESSION['alerts'] = array(); $user = new User(); if (isset($_SESSION['userid'])) { $user->load($_SESSION['userid']); } $this->data['user'] = $user; }
public function remind(Request $request, Response $response, array $args) { $name = $request->get('name'); if ($request->get('login')) { return new RedirectResponse($this->config->baseUrl() . '/login?name=' . $name); } $config = new Config(); $user = new User($this->db); $user->loadByName($name); $template = new Template('remind_email.twig'); if (!empty($user->getEmail())) { $template->user = $user; $template->token = $user->getReminder(); $message = \Swift_Message::newInstance()->setSubject('Password reminder')->setFrom(array($config->siteEmail() => $config->siteTitle()))->setTo(array($user->getEmail() => $user->getName()))->setBody($template->render(), 'text/html'); $this->email($message); } else { // Pause for a moment, so it's not so obvious which users' names are resulting in mail being sent. sleep(5); } $template->alert('success', 'Please check your email', true); return new RedirectResponse($this->config->baseUrl() . '/remind?name=' . $user->getName()); }