* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $ */ class Subscriber extends BaseSubscriber { const SALT = 'slknmbvfdáuiuztfgvrtzu isdu zsdh sdzgg'; public function postDelete($event) { $profile = $this->getProfile(); if (!is_null($profile->getId())) { $profile->setIsPdfSubscriber(false); $profile->save(); } } public function getToken() { return md5(self::SALT . $this->getEmail() . self::SALT); } public function postInsert($event) { parent::postInsert($event); if(saSettings::get('send_last_pdf')) { $this->sendLastBulletin(); } } public function sendLastBulletin() { sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); $bulletin = Doctrine::getTable('Bulletin')->createQuery() ->addWhere('send_date IS NOT NULL') ->orderBy('send_date DESC') ->fetchOne(); if($bulletin) { $m = new Swift_Message($bulletin->getSubject()); $m->setFrom(sfConfig::get('app_mail_from_address')); $m->setContentType('text/html'); if ($bulletin->hasFile()) { $m->attach(new Swift_Attachment(file_get_contents($bulletin->getPath()), $bulletin->getNiceFilename())); } $body = get_component('bulletin', 'mailBody', array('bulletin' => $bulletin, 'subscriber' => $this)); $m->setBody($body); $m->setTo($this->getEmail()); //$m->setTo('tomas.naibrt@gmail.com'); sfContext::getInstance()->getMailer()->send($m); $bulletin->setSubscribersNum($bulletin->getSubscribersNum() + 1); $bulletin->save(); } } }