

namibia
bb2698c383a0585633180c7996aba816667c9e6d
namibia / module / Newsletter / src / Newsletter / Service / Newsletter.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
<?php namespace Newsletter\Service; /** * Manage Newsletter data. * @author andre.fourie */ class Newsletter extends \Newsletter\DataBin\Newsletter { /** * ExecuteAfter: Create, Update. * New newsletter created, notifications be required, probably. * @param array $meta * @param object|null $jobRecord * @param object|null $record * @param \Workspace\Utility\ServiceInputParams $contract */ public function sendNewsletter($meta, $jobRecord, $record, \Workspace\Utility\ServiceInputParams $contract) { #-> Options. \Utility\Debug::errorLog('options', $contract->options); $jobRecord = !is_null($jobRecord) ? $jobRecord : $record; $profileId = 0; if ('Sending' == $jobRecord->jobState) { return; } if ($contract->options->SaveDraft) { $jobRecord->jobState = 'Draft'; $this->em->flush($jobRecord); } elseif ($contract->options->TestDraft) { $jobRecord->jobState = 'Draft'; $this->em->flush($jobRecord); $profileId = \Utility\Registry::getAuthParam('id'); exec("php /var/www/namibia/public/index.php newsletter send " . $jobRecord->id . " 1 $profileId > /dev/null &"); } elseif ($contract->options->Send) { $jobRecord->jobState = 'Sending'; $this->em->flush($jobRecord); exec("php /var/www/namibia/public/index.php newsletter send " . $jobRecord->id . " 0 $profileId > /dev/null &"); } } /** * Cron: newsletter send * Send newsletter. * @param integer $jobId * @param integer $test * @param integer $profileId */ public function send($jobId, $test, $profileId) { #-> Options. $jobRecord = $this->em ->getRepository('\Newsletter\Entity\Newsletter') ->find($jobId); if (is_null($jobRecord)) { return; } if (1 == $test) { $oNotify = new \Utility\Comms\Notification(); $sentTo = $oNotify->sendNewsletter($jobRecord->id, true, $profileId); $jobRecord->jobState = 'Draft'; $jobRecord->sentTo = is_numeric($sentTo) ? $sentTo : 0; } elseif (0 == $test) { $oNotify = new \Utility\Comms\Notification(); $sentTo = $oNotify->sendNewsletter($jobRecord->id, false); $jobRecord->jobState = 'Sent'; $jobRecord->sentTo = is_numeric($sentTo) ? $sentTo : 0; } $this->em->flush($jobRecord); } } |
Commits for namibiamodule/Newsletter/src/Newsletter/Service/Newsletter.php
Revision | Author | Commited | Message |
---|---|---|---|
bb2698 ...
![]() |
Mark | Mon 24 Oct, 2016 08:44:08 +0000 | latest update |
df0489 ... | Mark | Fri 14 Oct, 2016 10:01:00 +0000 | initial commit |