/** * Generate module */ protected function compile() { // Overwrite default template if ($this->nl_template) { $this->Template = new \FrontendTemplate($this->nl_template); $this->Template->setData($this->arrData); } $inputHelper = new NlpInputHelper($submitted); $forms = $inputHelper->addEmailField($objChannel); // Unsubscribe if ($this->Input->post('FORM_SUBMIT') == $this->strFormId && $this->Input->post('email', true)) { $this->removeRecipient(); } $blnHasError = false; // Error message if (strlen($_SESSION['UNSUBSCRIBE_ERROR'])) { $blnHasError = true; $this->Template->mclass = 'danger'; $this->Template->message = $_SESSION['UNSUBSCRIBE_ERROR']; $_SESSION['UNSUBSCRIBE_ERROR'] = ''; } // Confirmation message if (strlen($_SESSION['UNSUBSCRIBE_CONFIRM'])) { $this->Template->mclass = 'success'; $this->Template->message = $_SESSION['UNSUBSCRIBE_CONFIRM']; $_SESSION['UNSUBSCRIBE_CONFIRM'] = ''; } $arrChannels = array(); $objChannel = $this->Database->execute("SELECT id, title FROM tl_newsletter_channel WHERE id IN(" . implode(',', array_map('intval', $this->nl_channels)) . ") ORDER BY title"); // Get titles while ($objChannel->next()) { $arrChannels[$objChannel->id] = $objChannel->title; } // Default template variables $this->Template->forms = $forms; $this->Template->channels = $arrChannels; $this->Template->showChannels = !$this->nl_hideChannels; $this->Template->submit = specialchars($GLOBALS['TL_LANG']['MSC']['unsubscribe']); $this->Template->channelsLabel = $GLOBALS['TL_LANG']['MSC']['nl_channels']; $this->Template->emailLabel = $GLOBALS['TL_LANG']['MSC']['emailAddress']; $this->Template->action = $objPage->numRows ? $this->generateFrontendUrl($objPage->row()) : $this->getIndexFreeRequest(); $this->Template->formId = $this->strFormId; $this->Template->id = $this->id; $this->Template->hasError = $blnHasError; }