Example #1
0
 /**
  * Fetches the campaign ID and sets its record
  */
 private function getCampaign()
 {
     // get the active campaign
     $id = $this->getParameter('campaign', 'int');
     // fetch the campaign record
     $this->campaign = BackendMailmotorModel::getCampaign($id);
 }
Example #2
0
 /**
  * Get the data
  */
 private function getData()
 {
     // get the record
     $this->record = (array) BackendMailmotorModel::getCampaign($this->id);
     // no item found, throw an exceptions, because somebody is f*****g with our URL
     if (empty($this->record)) {
         $this->redirect(BackendModel::createURLForAction('Campaigns') . '&error=non-existing');
     }
 }
Example #3
0
 /**
  * Load the confirmation dialog
  */
 private function loadConfirmationDialog()
 {
     // load statistics
     $groups = BackendMailmotorModel::getGroupsByIds($this->record['groups']);
     // fetch the campaign
     $campaign = BackendMailmotorModel::getCampaign($this->record['campaign_id']);
     // fetch the template
     $template = BackendMailmotorModel::getTemplate($this->record['language'], $this->record['template']);
     // declare stats array
     $stats['recipients'] = count($this->record['recipients']);
     $stats['mailing'] = $this->record['name'];
     $stats['label_persons'] = $stats['recipients'] > 1 ? BL::lbl('Persons', 'core') : BL::lbl('Person', 'core');
     // campaign was set
     if (!empty($campaign)) {
         // set data
         $stats['message'] = BL::msg('RecipientStatisticsCampaign', $this->getModule());
         $stats['campaign'] = $campaign['name'];
         // assign the recipient statistics variable
         $this->tpl->assign('recipientStatistics', sprintf($stats['message'], $stats['mailing'], $stats['campaign'], $stats['recipients'], $stats['label_persons']));
     } else {
         // set data
         $stats['message'] = BL::msg('RecipientStatisticsNoCampaign', $this->getModule());
         // assign the recipient statistics variable
         $this->tpl->assign('recipientStatistics', sprintf($stats['message'], $stats['mailing'], $stats['recipients'], $stats['label_persons']));
     }
     // add comma separator to groups
     if (!empty($groups)) {
         // fetch the last key in this array
         $lastRecord = end($groups);
         // loop the groups
         foreach ($groups as $key => &$group) {
             // add comma field to the groups if this is not the last item
             if ($lastRecord['id'] != $key) {
                 $group['comma'] = true;
             }
         }
     }
     // assign the groups to the template
     $this->tpl->assign('groups', $groups);
     // assign the template language
     $this->tpl->assign('templateLanguage', \SpoonFilter::ucfirst(BL::lbl(strtoupper($template['language']))));
     // get the price settings
     $pricePerEmail = $this->get('fork.settings')->get($this->getModule(), 'price_per_email');
     $pricePerCampaign = $this->get('fork.settings')->get($this->getModule(), 'price_per_campaign');
     // parse the price total
     $this->tpl->assign('price', $stats['recipients'] * $pricePerEmail + $pricePerCampaign);
 }
Example #4
0
 /**
  * Gets all data needed for this page
  */
 private function getData()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if (!BackendMailmotorModel::existsCampaign($this->id)) {
         $this->redirect(BackendModel::createURLForAction('Campaigns') . '&error=campaign-does-not-exist');
     }
     // store mailing
     $this->campaign = BackendMailmotorModel::getCampaign($this->id);
     // fetch the statistics
     $this->statistics = BackendMailmotorCMHelper::getStatisticsByCampaignID($this->id, true);
     // no stats found
     if ($this->statistics === false || empty($this->statistics)) {
         $this->redirect(BackendModel::createURLForAction('Campaigns') . '&error=no-statistics-loaded');
     }
 }