|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Smr\Pages\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use Smr\Database; |
|
6
|
|
|
use Smr\Page\AccountPage; |
|
7
|
|
|
use Smr\Template; |
|
8
|
|
|
use SmrAccount; |
|
9
|
|
|
|
|
10
|
|
|
class NewsletterSend extends AccountPage { |
|
11
|
|
|
|
|
12
|
|
|
public string $file = 'admin/newsletter_send.php'; |
|
13
|
|
|
|
|
14
|
|
|
public function build(SmrAccount $account, Template $template): void { |
|
15
|
|
|
$template->assign('PageTopic', 'Newsletter'); |
|
16
|
|
|
|
|
17
|
|
|
$template->assign('CurrentEmail', $account->getEmail()); |
|
18
|
|
|
|
|
19
|
|
|
// Get the most recent newsletter text for preview |
|
20
|
|
|
$db = Database::getInstance(); |
|
21
|
|
|
$dbResult = $db->read('SELECT newsletter_id, newsletter_html, newsletter_text FROM newsletter ORDER BY newsletter_id DESC LIMIT 1'); |
|
22
|
|
|
if ($dbResult->hasRecord()) { |
|
23
|
|
|
$dbRecord = $dbResult->record(); |
|
24
|
|
|
$id = $dbRecord->getInt('newsletter_id'); |
|
25
|
|
|
$template->assign('NewsletterId', $id); |
|
26
|
|
|
$template->assign('DefaultSubject', 'Space Merchant Realms Newsletter #' . $id); |
|
27
|
|
|
|
|
28
|
|
|
// Give both the template and processing container access to the message |
|
29
|
|
|
$processingContainer = new NewsletterSendProcessor( |
|
30
|
|
|
newsletterHtml: $dbRecord->getString('newsletter_html'), |
|
31
|
|
|
newsletterText: $dbRecord->getString('newsletter_text'), |
|
32
|
|
|
); |
|
33
|
|
|
$template->assign('NewsletterHtml', $dbRecord->getString('newsletter_html')); |
|
34
|
|
|
$template->assign('NewsletterText', $dbRecord->getString('newsletter_text')); |
|
35
|
|
|
|
|
36
|
|
|
// Create the form for the populated processing container |
|
37
|
|
|
$template->assign('ProcessingHREF', $processingContainer->href()); |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
|