protected function buildToolbars() { $toolbars = $this->ui->getRoot()->getDescendants('SwatToolbar'); foreach ($toolbars as $toolbar) { $toolbar->setToolLinkValues($this->newsletter->id); } // Preview link can be unavailable if the database save was successful, // but the mailing list call failed. $preview_link = $this->ui->getWidget('preview_link'); if ($this->newsletter->campaign_id === null) { $preview_link->sensitive = false; $preview_link->tooltip = Deliverance::_('This newsletter’s preview is not available due to connection ' . 'issues with the email service provider. Edit the newsletter ' . 'to enable the preview.'); } else { $campaign_type = $this->newsletter->instance instanceof SiteInstance ? $this->newsletter->instance->shortname : null; $campaign_class = DeliveranceCampaignFactory::get($this->app, $campaign_type); $this->ui->getWidget('preview_link')->link = call_user_func_array(array($campaign_class, 'getPreviewUrl'), array($this->app, $this->newsletter->campaign_id)); } if ($this->newsletter->isSent()) { $preview_link->title = Deliverance::_('View Email'); $this->ui->getWidget('edit_link')->visible = false; $this->ui->getWidget('delete_link')->visible = false; $this->ui->getWidget('cancel_link')->visible = false; $this->ui->getWidget('schedule_link')->visible = false; $this->ui->getWidget('send_preview_link')->visible = false; // reports may not exist yet if the newsletter was recently sent. $stats_link = $this->ui->getWidget('stats_link'); if ($this->newsletter->campaign_report_url === null) { $stats_link->sensitive = false; $stats_link->tooltip = Deliverance::_('This newletter’s status report will become available ' . 'shortly after the newsletter has been sent.'); } else { $stats_link->link = $this->newsletter->campaign_report_url; } } elseif ($this->newsletter->isScheduled()) { $this->ui->getWidget('edit_link')->visible = false; $this->ui->getWidget('stats_link')->visible = false; $this->ui->getWidget('delete_link')->visible = false; $this->ui->getWidget('send_preview_link')->visible = false; $this->ui->getWidget('schedule_link')->title = Deliverance::_('Reschedule Delivery'); } else { $this->ui->getWidget('stats_link')->visible = false; $this->ui->getWidget('cancel_link')->visible = false; } }
public function getCampaign(SiteApplication $app, $campaign_type = 'default') { // TODO: allow loading different types of campaigns based on segment. $campaign = DeliveranceCampaignFactory::get($app, $campaign_type); $campaign->setId($this->getCampaignId()); $campaign->setShortname($this->getCampaignShortname()); $campaign->setSubject($this->subject); $campaign->setPreheader($this->preheader); $campaign->setCampaignSegment($this->campaign_segment); $campaign->setHtmlContent($this->html_content); $campaign->setTextContent($this->text_content); $campaign->setTitle($this->getCampaignTitle()); $campaign->setInstance($this->instance); $campaign->setTemplate($this->getTemplateShortname()); $campaign->setGoogleCampaign($this->google_campaign); if ($this->send_date instanceof SwatDate) { $campaign->setSendDate($this->send_date); } return $campaign; }