/** * @param NewsletterMailing $newsletterMailing The newsletterMailing object to add. */ protected function doAddNewsletterMailing($newsletterMailing) { $this->collNewsletterMailings[] = $newsletterMailing; $newsletterMailing->setNewsletter($this); }
/** * Filter the query by a related NewsletterMailing object * * @param NewsletterMailing|PropelObjectCollection $newsletterMailing the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return NewsletterQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByNewsletterMailing($newsletterMailing, $comparison = null) { if ($newsletterMailing instanceof NewsletterMailing) { return $this->addUsingAlias(NewsletterPeer::ID, $newsletterMailing->getNewsletterId(), $comparison); } elseif ($newsletterMailing instanceof PropelObjectCollection) { return $this->useNewsletterMailingQuery()->filterByPrimaryKeys($newsletterMailing->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByNewsletterMailing() only accepts arguments of type NewsletterMailing or PropelCollection'); } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param NewsletterMailing $obj A NewsletterMailing object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null NewsletterMailingPeer::$instances[$key] = $obj; } }
/** * Exclude object from result * * @param NewsletterMailing $newsletterMailing Object to remove from the list of results * * @return NewsletterMailingQuery The current query, for fluid interface */ public function prune($newsletterMailing = null) { if ($newsletterMailing) { $this->addUsingAlias(NewsletterMailingPeer::ID, $newsletterMailing->getId(), Criteria::NOT_EQUAL); } return $this; }
/** sendNewsletter() * * @param int BatchNumber * * @return boolean full or partial success */ public function sendNewsletter($iBatchNumber = 0) { if ($this->aRecipients === null || $this->sSenderEmail === null || $this->aMailGroups === null) { throw new Exception("Error in sendNewsletter: prepare not called"); } // Send newsletter if newsletter is chosen and there are recipients $oNewsletter = NewsletterQuery::create()->findPk($this->iNewsletterId); if ($oNewsletter === null) { throw new LocalizedException("newsletter.mailing.newsletter_missing"); } if ($iBatchNumber === 0) { $this->aUnsuccessfulAttempts = array(); } if ($this->aRecipients instanceof PropelObjectCollection) { $this->aRecipients = $this->aRecipients->getData(); } $aRecipients = array_slice($this->aRecipients, $iBatchNumber * $this->iBatchSize, $this->iBatchSize); $bRequiresUnsubsribeLink = true; $oNewsletterMailer = new NewsletterMailer($oNewsletter, $aRecipients, $bRequiresUnsubsribeLink, $this->sSenderEmail, $this->sSenderName); if (!$oNewsletterMailer->send()) { $this->aUnsuccessfulAttempts = array_merge($this->aUnsuccessfulAttempts, $oNewsletterMailer->getInvalidEmails()); } if (count($aRecipients) === $this->iBatchSize) { return $iBatchNumber + 1; } else { // Return batch count/boolean and register Mailings per group $bOneGroupOnly = count($this->aMailGroups) === 1; foreach ($this->aMailGroups as $mMailGroupId) { $oNewsletterMailing = new NewsletterMailing(); $oNewsletterMailing->setDateSent(date('c')); if (is_numeric($mMailGroupId)) { $oNewsletterMailing->setSubscriberGroupId($mMailGroupId); } else { $oNewsletterMailing->setExternalMailGroupId($mMailGroupId); } // @todo check change jm > write recipient count if newsletter is sent to singe group only if ($bOneGroupOnly) { $oNewsletterMailing->setRecipientCount(count($this->aRecipients)); } $oNewsletterMailing->setNewsletterId($oNewsletter->getId()); $oNewsletterMailing->save(); } $this->aRecipients = null; $this->sSenderEmail = null; $this->aMailGroups = null; return count($this->aUnsuccessfulAttempts) === 0; } }
/** * @param NewsletterMailing $newsletterMailing The newsletterMailing object to add. */ protected function doAddNewsletterMailing($newsletterMailing) { $this->collNewsletterMailings[] = $newsletterMailing; $newsletterMailing->setSubscriberGroup($this); }