/** * index action for the module controller * This will render the HTML needed for ExtJS application */ public function indexAction() { $pageType = ''; $record = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('doktype', 'pages', 'uid =' . $this->pageId); if (!empty($record['doktype']) && $record['doktype'] == 254) { $pageType = 'folder'; } elseif (!empty($record['doktype'])) { $pageType = 'page'; } $configuration = ['pageId' => $this->pageId, 'pageType' => $pageType, 'emailShowUrl' => UriBuilder::buildFrontendUri($this->pageId, 'Email', 'show')]; $this->view->assign('configuration', $configuration); }
/** * Get the link with auth code. * * @param Email $email * @param string $url * @param bool $isPreview * @param string $isPlainText * @return string The link url */ private function getLinkAuthCode(Email $email, $url, $isPreview, $isPlainText = false) { global $TYPO3_DB; $url = html_entity_decode($url); // First check in our local cache if (isset($this->linksCache[$url])) { $linkId = $this->linksCache[$url]; } elseif ($isPreview) { $linkId = count($this->linksCache); } else { // Look for the link database, it may already exist $res = $TYPO3_DB->sql_query('SELECT uid FROM tx_newsletter_domain_model_link WHERE url = ' . $TYPO3_DB->fullQuoteStr($url, 'tx_newsletter_domain_model_link') . ' AND newsletter = ' . $TYPO3_DB->fullQuoteStr($this->newsletter->getUid(), 'tx_newsletter_domain_model_link') . ' LIMIT 1'); $row = $TYPO3_DB->sql_fetch_row($res); if ($row) { $linkId = $row[0]; } else { $TYPO3_DB->exec_INSERTquery('tx_newsletter_domain_model_link', ['pid' => $this->newsletter->getPid(), 'url' => $url, 'newsletter' => $this->newsletter->getUid()]); $linkId = $TYPO3_DB->sql_insert_id(); } } // Store link in cache $this->linksCache[$url] = $linkId; $authCode = md5($email->getAuthCode() . $linkId); $arguments = []; $arguments['n'] = $this->newsletter->getUid(); $arguments['l'] = $authCode; if ($isPlainText) { $arguments['p'] = 1; } $newUrl = UriBuilder::buildFrontendUri($email->getPid(), 'Link', 'clicked', $arguments); return $newUrl; }
/** * Return the URL to unsubscribe from the newsletter * @return string */ public function getUnsubscribeUrl() { return UriBuilder::buildFrontendUri($this->getPid(), 'Email', 'unsubscribe', ['c' => $this->getAuthCode()]); }
/** * Return HTML code showing an extract of recipients (first X recipients) */ public function getExtract($limit = 30) { if ($this->getError()) { $out = 'Error: ' . $this->getError(); } else { $i = 0; while ($row = $this->getRecipient()) { // Dump formatted table header if ($i == 0) { $out .= '<tr>'; foreach (array_keys($row) as $key) { $out .= '<th style="padding-right: 1em;">' . $this->getFieldTitle($key) . '</th>'; } $out .= '</tr>'; } $out .= '<tr style="border: 1px grey solid; border-collapse: collapse;">'; foreach ($row as $field) { $out .= '<td style="padding-right: 1em;">' . $field . '</td>'; } $out .= '</tr>'; if (++$i == $limit) { break; } } $out = '<table style="border: 1px grey solid; border-collapse: collapse;">' . $out . '</table>'; // From TYPO3 7.6.0 and higher we are able to generate URI without entirely breaking the backend $export = ''; if (version_compare(TYPO3_version, '7.6.0', '>=')) { $authCode = \TYPO3\CMS\Core\Utility\GeneralUtility::stdAuthCode($this->_getCleanProperties()); $uriXml = UriBuilder::buildFrontendUri($this->getPid(), 'RecipientList', 'export', ['uidRecipientList' => $this->getUid(), 'authCode' => $authCode, 'format' => 'xml']); $uriCsv = UriBuilder::buildFrontendUri($this->getPid(), 'RecipientList', 'export', ['uidRecipientList' => $this->getUid(), 'authCode' => $authCode, 'format' => 'csv']); $export = ' (<a href="' . $uriXml . '">export XML</a>, <a href="' . $uriCsv . '">export CSV</a>)'; } $out .= '<p><strong>' . $i . '/' . $this->getCount() . '</strong> recipients' . $export . '</p>'; } $out = '<h4>' . $this->getTitle() . '</h4>' . $out; return $out; }