Esempio n. 1
0
 /**
  * 
  * @return Ambigous <\Zend\View\Model\ViewModel, \Zend\View\Model\ViewModel>
  */
 public function newinsertionorderAction()
 {
     $needed_input = array('campaignname', 'startdate', 'enddate', 'maximpressions', 'maxspend');
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     $this->validateInput($needed_input);
     $campaignname = $this->getRequest()->getPost('campaignname');
     $startdate = $this->getRequest()->getPost('startdate');
     $enddate = $this->getRequest()->getPost('enddate');
     $customername = $this->getRequest()->getPost('customername');
     $customerid = $this->getRequest()->getPost('customerid');
     if (!$customerid) {
         $customerid = "001";
     }
     $maximpressions = intval($this->getRequest()->getPost('maximpressions'));
     $maxspend = $this->getRequest()->getPost('maxspend');
     $campaignid = $this->getRequest()->getPost('campaignid');
     $campaign_preview_id = $this->getRequest()->getPost('campaignpreviewid');
     $ispreview = $this->getRequest()->getPost('ispreview');
     $px_feeds = $this->getRequest()->getPost('px-feeds');
     $pc_feeds = $this->getRequest()->getPost('pc-feeds');
     $ssp_feeds = $this->getRequest()->getPost('ssp-feeds');
     $pc_feeds = is_array($pc_feeds) ? $pc_feeds : array();
     $px_feeds = is_array($px_feeds) ? $px_feeds : array();
     $ssp_feeds = is_array($ssp_feeds) ? $ssp_feeds : array();
     $exchange_feeds = array_merge($pc_feeds, $px_feeds);
     // 4 byte max int(11) check
     if ($maximpressions < 1 || $maximpressions > 2147483647) {
         $maximpressions = 2147483647;
     }
     $InsertionOrderPreview = new \model\InsertionOrderPreview();
     if ($campaignid != null && $ispreview != true) {
         /*
          * THIS METHOD CHECKS IF THERE IS AN EXISTING PREVIEW MODE CAMPAIGN
          * IF NOT, IT CHECKS THE ACL PERMISSIONS ON THE PRODUCTION BANNER/CAMPAIGN REFERENCED
          * THEN IT CREATES A PREVIEW VERSION OF THE AD CAMPAIGN
          */
         $update_data = array('type' => 'InsertionOrderID', 'id' => $campaignid);
         $return_val = \transformation\TransformPreview::previewCheckInsertionOrderID($campaignid, $this->auth, $this->config_handle, $this->getServiceLocator()->get('mail.transport'), $update_data);
         if ($return_val !== null) {
             $campaign_preview_id = $return_val["InsertionOrderPreviewID"];
         }
         $InsertionOrderPreview->InsertionOrderID = $campaignid;
     }
     if ($campaign_preview_id != null) {
         // ACL PREVIEW PERMISSIONS CHECK
         transformation\CheckPermissions::checkEditPermissionInsertionOrderPreview($campaign_preview_id, $this->auth, $this->config_handle);
         $InsertionOrderPreview->InsertionOrderPreviewID = $campaign_preview_id;
         $params = array();
         $params["InsertionOrderPreviewID"] = $campaign_preview_id;
         $InsertionOrderPreviewFactory = \_factory\InsertionOrderPreview::get_instance();
         $_InsertionOrderPreview = $InsertionOrderPreviewFactory->get_row($params);
         $InsertionOrderPreview->InsertionOrderID = $_InsertionOrderPreview->InsertionOrderID;
     }
     // else new campaign, ispreview is always true
     $InsertionOrderPreview->UserID = $this->auth->getEffectiveUserID();
     $InsertionOrderPreview->Name = $campaignname;
     $InsertionOrderPreview->StartDate = date("Y-m-d H:i:s", strtotime($startdate));
     $InsertionOrderPreview->EndDate = date("Y-m-d H:i:s", strtotime($enddate));
     $InsertionOrderPreview->Customer = $customername;
     $InsertionOrderPreview->CustomerID = $customerid;
     $InsertionOrderPreview->ImpressionsCounter = 0;
     $InsertionOrderPreview->MaxImpressions = $maximpressions;
     $InsertionOrderPreview->CurrentSpend = 0;
     $InsertionOrderPreview->MaxSpend = $maxspend;
     $InsertionOrderPreview->Active = 1;
     $InsertionOrderPreview->DateCreated = date("Y-m-d H:i:s");
     $InsertionOrderPreview->DateUpdated = date("Y-m-d H:i:s");
     $InsertionOrderPreview->ChangeWentLive = 0;
     $InsertionOrderPreview->WentLiveDate = '0000-00-00 00:00:00';
     $InsertionOrderPreviewFactory = \_factory\InsertionOrderPreview::get_instance();
     $new_campaign_preview_id = $InsertionOrderPreviewFactory->saveInsertionOrderPreview($InsertionOrderPreview);
     /*
      * Private Exchange Feeds
      * 
      * wipe out existing preview data first
      */
     $PmpDealPublisherWebsiteToInsertionOrderPreviewFactory = \_factory\PmpDealPublisherWebsiteToInsertionOrderPreview::get_instance();
     $PmpDealPublisherWebsiteToInsertionOrderPreviewFactory->deletePmpDealPublisherWebsiteToInsertionOrderByInsertionOrderPreviewID($new_campaign_preview_id);
     foreach ($exchange_feeds as $raw_feed_data) {
         $raw_feed_data = rawurldecode($raw_feed_data);
         $exchange_feed_data = \util\AuthHelper::parse_feed_id($raw_feed_data);
         if ($exchange_feed_data === null) {
             continue;
         }
         $exchange_feed_id = intval($exchange_feed_data["id"]);
         $exchange_feed_description = $exchange_feed_data["description"];
         $is_local = false;
         if (!$this->is_super_admin) {
             $authorized = \util\AuthHelper::domain_user_authorized_px_publisher_website_passthru($this->config_handle, $this->auth->getUserID(), $exchange_feed_id, $is_local);
             if (!$authorized) {
                 $viewModel = new ViewModel(array('admin_email' => $this->config_handle['mail']['reply-to']['email'], 'refresh_url' => '/private-exchange/editinsertionorder/' . $new_campaign_preview_id . '?ispreview=true'));
                 return $viewModel->setTemplate('dashboard-manager/demand/creditapp.phtml');
             }
         } else {
             $ret_val = \util\AuthHelper::domain_user_authorized_publisher_passthru($this->auth->getEffectiveUserID(), $PublisherWebsite->DomainOwnerID);
             if ($ret_val === true) {
                 $is_local = true;
             }
         }
         $params = array();
         $params["PublisherWebsiteID"] = $exchange_feed_id;
         $_PmpDealPublisherWebsiteToInsertionOrderPreview = $PmpDealPublisherWebsiteToInsertionOrderPreviewFactory->get_row($params);
         $PmpDealPublisherWebsiteToInsertionOrderPreview = new \model\PmpDealPublisherWebsiteToInsertionOrderPreview();
         if ($_PmpDealPublisherWebsiteToInsertionOrderPreview != null) {
             $PmpDealPublisherWebsiteToInsertionOrderPreview->PmpDealPublisherWebsiteToInsertionOrderPreviewID = $_PmpDealPublisherWebsiteToInsertionOrderPreview->PmpDealPublisherWebsiteToInsertionOrderPreviewID;
         }
         $PmpDealPublisherWebsiteToInsertionOrderPreview->PublisherWebsiteID = $exchange_feed_id;
         $PmpDealPublisherWebsiteToInsertionOrderPreview->PublisherWebsiteLocal = $is_local;
         $PmpDealPublisherWebsiteToInsertionOrderPreview->PublisherWebsiteDescription = $exchange_feed_description;
         $PmpDealPublisherWebsiteToInsertionOrderPreview->InsertionOrderPreviewID = $new_campaign_preview_id;
         $PmpDealPublisherWebsiteToInsertionOrderPreview->Enabled = 1;
         $PmpDealPublisherWebsiteToInsertionOrderPreviewFactory->savePmpDealPublisherWebsiteToInsertionOrderPreview($PmpDealPublisherWebsiteToInsertionOrderPreview);
     }
     /*
      * SSP RTB Feeds
      * 
      * wipe out existing preview data first
      */
     $SspRtbChannelToInsertionOrderPreviewFactory = \_factory\SspRtbChannelToInsertionOrderPreview::get_instance();
     $SspRtbChannelToInsertionOrderPreviewFactory->deleteSspRtbChannelToInsertionOrderByInsertionOrderPreviewID($new_campaign_preview_id);
     /*
      * If they are adding inventory from SSP RTB Channels
      * make sure they are approved for that
      */
     if (!$this->is_super_admin && count($ssp_feeds) >= 1) {
         if (!\util\CreditHelper::wasApprovedForSspRtbInventoryAuthUserID($this->auth->getUserID())) {
             $viewModel = new ViewModel(array('admin_email' => $this->config_handle['mail']['reply-to']['email'], 'refresh_url' => '/private-exchange/editinsertionorder/' . $new_campaign_preview_id . '?ispreview=true'));
             return $viewModel->setTemplate('dashboard-manager/demand/creditapp.phtml');
         }
     }
     foreach ($ssp_feeds as $raw_feed_data) {
         $raw_feed_data = rawurldecode($raw_feed_data);
         $ssp_feed_data = \util\AuthHelper::parse_feed_id($raw_feed_data);
         if ($ssp_feed_data === null) {
             continue;
         }
         $ssp_feed_id = $ssp_feed_data["id"];
         $ssp_exchange = $ssp_feed_data["exchange"];
         $ssp_feed_id = str_replace('__COLON__', ':', $ssp_feed_id);
         $ssp_exchange = str_replace('__COLON__', ':', $ssp_exchange);
         $ssp_feed_description = $ssp_feed_data["description"];
         if (!$this->is_super_admin) {
             $authorized = \util\AuthHelper::domain_user_authorized_ssp_passthru($this->auth->getUserID(), $ssp_feed_id);
             if (!$authorized) {
                 die("You are not authorized to add inventory from SSP RTB Channel: " . $ssp_feed_id . ' - ' . $ssp_feed_description . " <br />Please contact an administrator for more information.");
             }
         }
         $params = array();
         $params["SspPublisherChannelID"] = $ssp_feed_id;
         $_SspRtbChannelToInsertionOrderPreview = $SspRtbChannelToInsertionOrderPreviewFactory->get_row($params);
         $SspRtbChannelToInsertionOrderPreview = new \model\SspRtbChannelToInsertionOrderPreview();
         if ($_SspRtbChannelToInsertionOrderPreview != null) {
             $SspRtbChannelToInsertionOrderPreview->SspRtbChannelToInsertionOrderPreviewID = $_SspRtbChannelToInsertionOrderPreview->SspRtbChannelToInsertionOrderPreviewID;
         }
         $SspRtbChannelToInsertionOrderPreview->SspPublisherChannelID = $ssp_feed_id;
         $SspRtbChannelToInsertionOrderPreview->SspPublisherChannelDescription = $ssp_feed_description;
         $SspRtbChannelToInsertionOrderPreview->SspExchange = $ssp_exchange;
         $SspRtbChannelToInsertionOrderPreview->InsertionOrderPreviewID = $new_campaign_preview_id;
         $SspRtbChannelToInsertionOrderPreview->Enabled = 1;
         $SspRtbChannelToInsertionOrderPreviewFactory->saveSspRtbChannelToInsertionOrderPreview($SspRtbChannelToInsertionOrderPreview);
     }
     if (!$this->is_super_admin && $this->config_handle['mail']['subscribe']['campaigns'] === true) {
         // if this ad campaign was not created/edited by the admin, then send out a notification email
         $message = '<b>NginAd Insertion Order Added/Updated by ' . $this->true_user_name . '.</b><br /><br />';
         $message = $message . '<table border="0" width="10%">';
         $message = $message . '<tr><td><b>InsertionOrderID: </b></td><td>' . $new_campaign_preview_id . '</td></tr>';
         $message = $message . '<tr><td><b>UserID: </b></td><td>' . $InsertionOrderPreview->UserID . '</td></tr>';
         $message = $message . '<tr><td><b>Name: </b></td><td>' . $InsertionOrderPreview->Name . '</td></tr>';
         $message = $message . '<tr><td><b>StartDate: </b></td><td>' . $InsertionOrderPreview->StartDate . '</td></tr>';
         $message = $message . '<tr><td><b>EndDate: </b></td><td>' . $InsertionOrderPreview->EndDate . '</td></tr>';
         $message = $message . '<tr><td><b>Customer: </b></td><td>' . $InsertionOrderPreview->Customer . '</td></tr>';
         $message = $message . '<tr><td><b>CustomerID: </b></td><td>' . $InsertionOrderPreview->CustomerID . '</td></tr>';
         $message = $message . '<tr><td><b>MaxImpressions: </b></td><td>' . $InsertionOrderPreview->MaxImpressions . '</td></tr>';
         $message = $message . '<tr><td><b>MaxSpend: </b></td><td>' . $InsertionOrderPreview->MaxSpend . '</td></tr>';
         $message = $message . '</table>';
         $subject = "NginAd Insertion Order Added/Updated by " . $this->true_user_name;
         $transport = $this->getServiceLocator()->get('mail.transport');
         $text = new Mime\Part($message);
         $text->type = Mime\Mime::TYPE_HTML;
         $text->charset = 'utf-8';
         $mimeMessage = new Mime\Message();
         $mimeMessage->setParts(array($text));
         $zf_message = new Message();
         $zf_message->addTo($this->config_handle['mail']['admin-email']['email'], $this->config_handle['mail']['admin-email']['name'])->addFrom($this->config_handle['mail']['reply-to']['email'], $this->config_handle['mail']['reply-to']['name'])->setSubject($subject)->setBody($mimeMessage);
         $transport->send($zf_message);
     }
     $refresh_url = "/private-exchange/?ispreview=true";
     $viewModel = new ViewModel(array('refresh_url' => $refresh_url));
     return $viewModel->setTemplate('dashboard-manager/demand/interstitial.phtml');
 }
Esempio n. 2
0
 /**
  * 
  * @return Ambigous <\Zend\View\Model\ViewModel, \Zend\View\Model\ViewModel>
  */
 public function newcampaignAction()
 {
     $needed_input = array('campaignname', 'startdate', 'enddate', 'maximpressions', 'maxspend');
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     $this->validateInput($needed_input);
     $campaignname = $this->getRequest()->getPost('campaignname');
     $startdate = $this->getRequest()->getPost('startdate');
     $enddate = $this->getRequest()->getPost('enddate');
     $customername = $this->getRequest()->getPost('customername');
     $customerid = $this->getRequest()->getPost('customerid');
     if (!$customerid) {
         $customerid = "001";
     }
     $maximpressions = $this->getRequest()->getPost('maximpressions');
     $maxspend = $this->getRequest()->getPost('maxspend');
     $campaignid = $this->getRequest()->getPost('campaignid');
     $campaign_preview_id = $this->getRequest()->getPost('campaignpreviewid');
     $ispreview = $this->getRequest()->getPost('ispreview');
     $AdCampaignPreview = new \model\AdCampaignPreview();
     if ($campaignid != null && $ispreview != true) {
         /*
          * THIS METHOD CHECKS IF THERE IS AN EXISTING PREVIEW MODE CAMPAIGN
          * IF NOT, IT CHECKS THE ACL PERMISSIONS ON THE PRODUCTION BANNER/CAMPAIGN REFERENCED
          * THEN IT CREATES A PREVIEW VERSION OF THE AD CAMPAIGN
          */
         $update_data = array('type' => 'AdCampaignID', 'id' => $campaignid);
         $return_val = \transformation\TransformPreview::previewCheckAdCampaignID($campaignid, $this->auth, $update_data);
         if ($return_val !== null) {
             $campaign_preview_id = $return_val["AdCampaignPreviewID"];
         }
         $AdCampaignPreview->AdCampaignID = $campaignid;
     }
     if ($campaign_preview_id != null) {
         // ACL PREVIEW PERMISSIONS CHECK
         transformation\CheckPermissions::checkEditPermissionAdCampaignPreview($campaign_preview_id, $this->auth, $this->config_handle);
         $AdCampaignPreview->AdCampaignPreviewID = $campaign_preview_id;
         $params = array();
         $params["AdCampaignPreviewID"] = $campaign_preview_id;
         $AdCampaignPreviewFactory = \_factory\AdCampaignPreview::get_instance();
         $_AdCampaignPreview = $AdCampaignPreviewFactory->get_row($params);
         $AdCampaignPreview->AdCampaignID = $_AdCampaignPreview->AdCampaignID;
     }
     // else new campaign, ispreview is always true
     $AdCampaignPreview->UserID = $this->auth->getEffectiveUserID();
     $AdCampaignPreview->Name = $campaignname;
     $AdCampaignPreview->StartDate = date("Y-m-d H:i:s", strtotime($startdate));
     $AdCampaignPreview->EndDate = date("Y-m-d H:i:s", strtotime($enddate));
     $AdCampaignPreview->Customer = $customername;
     $AdCampaignPreview->CustomerID = $customerid;
     $AdCampaignPreview->ImpressionsCounter = 0;
     $AdCampaignPreview->MaxImpressions = $maximpressions;
     $AdCampaignPreview->CurrentSpend = 0;
     $AdCampaignPreview->MaxSpend = $maxspend;
     $AdCampaignPreview->Active = 1;
     $AdCampaignPreview->DateCreated = date("Y-m-d H:i:s");
     $AdCampaignPreview->DateUpdated = date("Y-m-d H:i:s");
     $AdCampaignPreview->ChangeWentLive = 0;
     $AdCampaignPreviewFactory = \_factory\AdCampaignPreview::get_instance();
     $AdCampaignPreviewFactory->saveAdCampaignPreview($AdCampaignPreview);
     $refresh_url = "/demand/?ispreview=true";
     $viewModel = new ViewModel(array('refresh_url' => $refresh_url));
     return $viewModel->setTemplate('dashboard-manager/demand/interstitial.phtml');
 }
 /**
  * 
  * @return Ambigous <\Zend\View\Model\ViewModel, \Zend\View\Model\ViewModel>
  */
 public function newcampaignAction()
 {
     $needed_input = array('campaignname', 'startdate', 'enddate', 'maximpressions', 'maxspend');
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     $this->validateInput($needed_input);
     $campaignname = $this->getRequest()->getPost('campaignname');
     $startdate = $this->getRequest()->getPost('startdate');
     $enddate = $this->getRequest()->getPost('enddate');
     $customername = $this->getRequest()->getPost('customername');
     $customerid = $this->getRequest()->getPost('customerid');
     if (!$customerid) {
         $customerid = "001";
     }
     $maximpressions = $this->getRequest()->getPost('maximpressions');
     $maxspend = $this->getRequest()->getPost('maxspend');
     $campaignid = $this->getRequest()->getPost('campaignid');
     $campaign_preview_id = $this->getRequest()->getPost('campaignpreviewid');
     $ispreview = $this->getRequest()->getPost('ispreview');
     $AdCampaignPreview = new \model\AdCampaignPreview();
     if ($campaignid != null && $ispreview != true) {
         /*
          * THIS METHOD CHECKS IF THERE IS AN EXISTING PREVIEW MODE CAMPAIGN
          * IF NOT, IT CHECKS THE ACL PERMISSIONS ON THE PRODUCTION BANNER/CAMPAIGN REFERENCED
          * THEN IT CREATES A PREVIEW VERSION OF THE AD CAMPAIGN
          */
         $update_data = array('type' => 'AdCampaignID', 'id' => $campaignid);
         $return_val = \transformation\TransformPreview::previewCheckAdCampaignID($campaignid, $this->auth, $this->config_handle, $this->getServiceLocator()->get('mail.transport'), $update_data);
         if ($return_val !== null) {
             $campaign_preview_id = $return_val["AdCampaignPreviewID"];
         }
         $AdCampaignPreview->AdCampaignID = $campaignid;
     }
     if ($campaign_preview_id != null) {
         // ACL PREVIEW PERMISSIONS CHECK
         transformation\CheckPermissions::checkEditPermissionAdCampaignPreview($campaign_preview_id, $this->auth, $this->config_handle);
         $AdCampaignPreview->AdCampaignPreviewID = $campaign_preview_id;
         $params = array();
         $params["AdCampaignPreviewID"] = $campaign_preview_id;
         $AdCampaignPreviewFactory = \_factory\AdCampaignPreview::get_instance();
         $_AdCampaignPreview = $AdCampaignPreviewFactory->get_row($params);
         $AdCampaignPreview->AdCampaignID = $_AdCampaignPreview->AdCampaignID;
     }
     // else new campaign, ispreview is always true
     $AdCampaignPreview->UserID = $this->auth->getEffectiveUserID();
     $AdCampaignPreview->Name = $campaignname;
     $AdCampaignPreview->StartDate = date("Y-m-d H:i:s", strtotime($startdate));
     $AdCampaignPreview->EndDate = date("Y-m-d H:i:s", strtotime($enddate));
     $AdCampaignPreview->Customer = $customername;
     $AdCampaignPreview->CustomerID = $customerid;
     $AdCampaignPreview->ImpressionsCounter = 0;
     $AdCampaignPreview->MaxImpressions = $maximpressions;
     $AdCampaignPreview->CurrentSpend = 0;
     $AdCampaignPreview->MaxSpend = $maxspend;
     $AdCampaignPreview->Active = 1;
     $AdCampaignPreview->DateCreated = date("Y-m-d H:i:s");
     $AdCampaignPreview->DateUpdated = date("Y-m-d H:i:s");
     $AdCampaignPreview->ChangeWentLive = 0;
     $AdCampaignPreviewFactory = \_factory\AdCampaignPreview::get_instance();
     $new_campaign_preview_id = $AdCampaignPreviewFactory->saveAdCampaignPreview($AdCampaignPreview);
     if (!$this->is_admin && $new_campaign_preview_id !== null && $this->config_handle['mail']['subscribe']['campaigns'] === true) {
         // if this ad campaign was not created/edited by the admin, then send out a notification email
         $message = '<b>NginAd Demand Customer Campaign Added by ' . $this->true_user_name . '.</b><br /><br />';
         $message = $message . '<table border="0" width="10%">';
         $message = $message . '<tr><td><b>AdCampaignID: </b></td><td>' . $new_campaign_preview_id . '</td></tr>';
         $message = $message . '<tr><td><b>UserID: </b></td><td>' . $AdCampaignPreview->UserID . '</td></tr>';
         $message = $message . '<tr><td><b>Name: </b></td><td>' . $AdCampaignPreview->Name . '</td></tr>';
         $message = $message . '<tr><td><b>StartDate: </b></td><td>' . $AdCampaignPreview->StartDate . '</td></tr>';
         $message = $message . '<tr><td><b>EndDate: </b></td><td>' . $AdCampaignPreview->EndDate . '</td></tr>';
         $message = $message . '<tr><td><b>Customer: </b></td><td>' . $AdCampaignPreview->Customer . '</td></tr>';
         $message = $message . '<tr><td><b>CustomerID: </b></td><td>' . $AdCampaignPreview->CustomerID . '</td></tr>';
         $message = $message . '<tr><td><b>MaxImpressions: </b></td><td>' . $AdCampaignPreview->MaxImpressions . '</td></tr>';
         $message = $message . '<tr><td><b>MaxSpend: </b></td><td>' . $AdCampaignPreview->MaxSpend . '</td></tr>';
         $message = $message . '</table>';
         $subject = "NginAd Demand Customer Campaign Added by " . $this->true_user_name;
         $transport = $this->getServiceLocator()->get('mail.transport');
         $text = new Mime\Part($message);
         $text->type = Mime\Mime::TYPE_HTML;
         $text->charset = 'utf-8';
         $mimeMessage = new Mime\Message();
         $mimeMessage->setParts(array($text));
         $zf_message = new Message();
         $zf_message->addTo($this->config_handle['mail']['admin-email']['email'], $this->config_handle['mail']['admin-email']['name'])->addFrom($this->config_handle['mail']['reply-to']['email'], $this->config_handle['mail']['reply-to']['name'])->setSubject($subject)->setBody($mimeMessage);
         $transport->send($zf_message);
     }
     $refresh_url = "/demand/?ispreview=true";
     $viewModel = new ViewModel(array('refresh_url' => $refresh_url));
     return $viewModel->setTemplate('dashboard-manager/demand/interstitial.phtml');
 }