protected function updateNewsletterStats() { // the url for stats can only be generated once the campaign has sent. // It may not be immediately available, so try to grab it if we've sent // the campaign but it hasn't been saved yet. if ($this->newsletter->isSent() && $this->newsletter->campaign_report_url === null) { $list = DeliveranceListFactory::get($this->app, 'default', DeliveranceNewsletter::getDefaultList($this->app, $this->newsletter->instance)); $list->setTimeout($this->app->config->deliverance->list_admin_connection_timeout); try { $this->newsletter->campaign_report_url = $list->getCampaignReportUrl($this->newsletter->campaign_id); $this->newsletter->save(); } catch (Exception $e) { $e = new SiteException($e); $e->processAndContinue(); } } }
protected function getList(DeliveranceNewsletter $newsletter) { $key = $newsletter->instance instanceof SiteInstance ? $newsletter->instance->id : null; if (!isset($this->lists[$key])) { $list = DeliveranceListFactory::get($this->app, 'default', DeliveranceNewsletter::getDefaultList($this->app, $newsletter->instance)); $list->setTimeout($this->app->config->deliverance->list_admin_connection_timeout); $this->lists[$key] = $list; } return $this->lists[$key]; }
protected function initList() { $this->list = DeliveranceListFactory::get($this->app, 'default', DeliveranceNewsletter::getDefaultList($this->app, $this->newsletter->instance)); $this->list->setTimeout($this->app->config->deliverance->list_admin_connection_timeout); }
protected function saveMailChimpCampaign() { $list = DeliveranceListFactory::get($this->app, 'default', DeliveranceNewsletter::getDefaultList($this->app, $this->newsletter->instance)); // Set a long timeout on mailchimp calls as we're in the admin & patient $list->setTimeout($this->app->config->deliverance->list_admin_connection_timeout); $lookup_id_by_title = false; if ($this->newsletter->id !== null && $this->newsletter->campaign_id === null) { // if the newsletter exists in the db, and doesn't have a campaign // id set try to look it up when saving. $lookup_id_by_title = true; } $campaign_type = $this->newsletter->instance instanceof SiteInstance ? $this->newsletter->instance->shortname : null; $campaign = $this->newsletter->getCampaign($this->app, $campaign_type); $campaign_id = $list->saveCampaign($campaign, $lookup_id_by_title); // save/update campaign resources. DeliveranceCampaign::uploadResources($this->app, $campaign); return $campaign_id; }