コード例 #1
0
 protected function getSubscriberInfo(DeliveranceList $list)
 {
     $info = $list->getDefaultSubscriberInfo();
     // Send welcome is used to signify a new signup to the list. In that
     // case set correct site as the source.
     if ($this->send_welcome && $this->app->config->mail_chimp->source != '') {
         $info['source'] = $this->app->config->mail_chimp->source;
     }
     return $info;
 }
コード例 #2
0
 protected function checkMember(DeliveranceList $list, $email)
 {
     if ($list->isMember($email)) {
         $this->send_welcome = false;
         $message = $this->getExistingMemberMessage($list, $email);
         if ($message != null) {
             $this->addAppMessage($message);
         }
     }
 }
コード例 #3
0
ファイル: Cancel.php プロジェクト: GervaisdeM/deliverance
 protected function saveDBData()
 {
     $campaign_type = $this->newsletter->instance instanceof SiteInstance ? $this->newsletter->instance->shortname : null;
     $campaign = $this->newsletter->getCampaign($this->app, $campaign_type);
     $message = null;
     $relocate = true;
     try {
         DeliveranceCampaign::removeResources($this->app, $campaign);
         $this->list->unscheduleCampaign($campaign);
         $this->newsletter->send_date = null;
         $this->newsletter->save();
         $message = new SwatMessage(sprintf(Deliverance::_('The delivery of “%s” has been canceled.'), $this->newsletter->subject));
     } catch (DeliveranceAPIConnectionException $e) {
         $relocate = false;
         // log api connection exceptions in the admin to keep a track of how
         // frequent they are.
         $e->processAndContinue();
         $message = new SwatMessage(Deliverance::_('There was an issue connecting to the email ' . 'service provider.'), 'error');
         $message->content_type = 'text/xml';
         $message->secondary_content = sprintf('<strong>%s</strong><br />%s', sprintf(Deliverance::_('The delivery of “%s” has not been canceled.'), $this->newsletter->subject), Deliverance::_('Connection issues are typically short-lived ' . 'and attempting to cancel the newsletter again after a ' . 'delay will usually be successful.'));
     } catch (Exception $e) {
         $relocate = false;
         $e = new DeliveranceException($e);
         $e->processAndContinue();
         $message = new SwatMessage(Deliverance::_('An error has occurred. The newsletter has not ' . 'been cancelled.'), 'system-error');
     }
     if ($message !== null) {
         $this->app->messages->add($message);
     }
     return $relocate;
 }
 protected function updateSegment(DeliveranceList $list, DeliveranceCampaignSegment $segment)
 {
     if ($list->isAvailable()) {
         $this->debug(sprintf(Deliverance::_('Updating ‘%s’... '), $segment->title));
         try {
             $size = $list->getSegmentSize($segment->getSegmentOptions());
             $segment->cached_segment_size = $size;
             $segment->save();
             $locale = SwatI18NLocale::get();
             $this->debug(sprintf(Deliverance::_('found %s subscribers.') . "\n", $locale->formatNumber($size)));
         } catch (DeliveranceApiConnectionException $e) {
             // ignore these exceptions. segment sizes will be updated next
             // time around.
             $this->debug(sprintf(Deliverance::_('list unavailable. Segment ‘%s’ was not updated.') . "\n", $segment->title));
         } catch (Exception $e) {
             $e = new DeliveranceException($e);
             $e->processAndContinue();
             $this->debug(sprintf(Deliverance::_('Update error. Segment ‘%s’ was not updated.') . "\n", $segment->title));
         }
     } else {
         $this->debug(sprintf(Deliverance::_('Mailing list unavailable. Segment ‘%s’ was not updated.') . "\n", $segment->title));
     }
 }
コード例 #5
0
 protected function handleUpdateResponse(DeliveranceList $list, $response)
 {
     $message = $list->handleUpdateResponse($response);
     $this->handleMessage($message);
 }
コード例 #6
0
 protected function removeInterests(DeliveranceList $list, array $interests)
 {
     $list->setReplaceInterests(true);
     parent::removeInterests($list, $interests);
 }
コード例 #7
0
 public function __construct(SiteApplication $app, $shortname = null)
 {
     parent::__construct($app, $shortname);
     $this->client = new MailChimpAPI($this->getApiKey());
     $this->client->useSecure(true);
     // by default if the connection takes longer than 1s timeout. This will
     // prevent users from waiting too long when MailChimp is down - requests
     // will just get queued. Without setting this, the default timeout is
     // 300 seconds
     $this->client->setTimeout($app->config->deliverance->list_connection_timeout);
     if ($this->shortname === null) {
         $this->shortname = $app->config->mail_chimp->default_list;
     }
     $this->initListMergeArrayMap();
     // default double_opt_in to the config var.
     $this->double_opt_in = $this->app->config->mail_chimp->double_opt_in;
 }
コード例 #8
0
 protected function unsubscribeQueued(DeliveranceList $list)
 {
     $addresses = $this->getQueuedUnsubscribes();
     if (count($addresses) == 0) {
         $this->debug(Deliverance::_('No queued addresses to unsubscribe.') . "\n");
         return;
     }
     $this->debug(sprintf(Deliverance::_('Unsubscribing %s queued addresses.') . "\n", count($addresses)));
     if ($this->dry_run === false) {
         $result = $list->batchUnsubscribe($addresses);
         $clear_queued = $this->handleResult($result, Deliverance::_('%s queued addresses unsubscribed.') . "\n");
         // don't clean the queued subscribes if they have been re-queued.
         if ($clear_queued === true) {
             $this->clearQueuedUnsubscribes($addresses);
         }
     }
     $this->debug(Deliverance::_('done unsubscribing queued addresses.') . "\n\n");
 }