Exemple #1
0
 /**
  * A method to send the "midnight" reports during maintenance - that
  * is, the delivery information report, showing what the campaign(s)
  * have delivered since the last time the report was sendt.
  *
  * @access private
  */
 function _runReports()
 {
     OA::debug('  Starting to send advertiser "campaign delivery" reports.', PEAR_LOG_DEBUG);
     // Get all advertisers where the advertiser preference is to send reports
     OA::debug('   - Getting details of advertisers that require reports to be sent.', PEAR_LOG_DEBUG);
     $doClients = OA_Dal::factoryDO('clients');
     $doClients->report = 't';
     $doClients->find();
     while ($doClients->fetch()) {
         $aAdvertiser = $doClients->toArray();
         // Don't email report by default
         $sendReport = false;
         // Has the report interval date been passed?
         if ($aAdvertiser['reportlastdate'] == OA_Dal::noDateString()) {
             $sendReport = true;
             $oReportLastDate = null;
         } else {
             $oNowDate = new Date();
             $oReportLastDate = new Date($aAdvertiser['reportlastdate']);
             $oSpan = new Date_Span();
             $oSpan->setFromDateDiff($oReportLastDate, $oNowDate);
             $daysSinceLastReport = (int) floor($oSpan->toDays());
             if ($daysSinceLastReport >= $aAdvertiser['reportinterval']) {
                 $sendReport = true;
             }
         }
         if ($sendReport) {
             // Send the advertiser's campaign delivery report
             $oEmail = new OA_Email();
             $oEmail->sendCampaignDeliveryEmail($aAdvertiser, $oReportLastDate);
         }
     }
     OA::debug('  Finished sending advertiser "campaign delivery" reports.', PEAR_LOG_DEBUG);
 }
Exemple #2
0
 /**
  * The class constructor method.
  *
  * @param array $aParams An associative array of values to be assigned to
  *                       the object. Valid array keys are:
  *      'campaignid' or 'placement_id'                   -> The placement ID. Required!
  *      'activate'                                       -> The activation date of the placement in
  *                                                          'YYYY-MM-DD' string format
  *      'expire'                                         -> The expiration date of the placement in
  *                                                          'YYYY-MM-DD' string format
  *      'views' or 'impression_target_total'             -> The placement lifetime impression target
  *      'clicks' or 'click_target_total'                 -> The placement lifetime click target
  *      'conversions' or 'conversion_target_total'       -> The placement lifetime conversion target
  *      'target_impression' or 'impression_target_daily' -> The dail impression target
  *      'target_click' or 'click_target_daily'           -> The daily click target
  *      'target_conversion' or 'conversion_target_daily' -> The daily conversion target
  *      'priority'                                       -> The placement priority
  */
 function OX_Maintenance_Priority_Campaign($aParams)
 {
     // Convert "old" input value names to "new", if required
     foreach ($this->aNewOldTypes as $newName => $oldName) {
         if (empty($aParams[$newName])) {
             $aParams[$newName] = $aParams[$oldName];
         }
     }
     // Test the input values
     $valid = true;
     if (!is_array($aParams)) {
         $valid = false;
     }
     if (count($aParams) < 0) {
         $valid = false;
     }
     if (!is_numeric($aParams['placement_id'])) {
         $valid = false;
     }
     if (!$valid) {
         $this->_abort();
     }
     // Store the required supplied values
     $this->id = (int) $aParams['placement_id'];
     // Store the optional required values
     $this->activate = !empty($aParams['activate']) && $aParams['activate'] != OA_Dal::noDateString() ? $aParams['activate'] : OA_Dal::noDateValue();
     $this->expire = !empty($aParams['expire']) && $aParams['expire'] != OA_Dal::noDateString() ? $aParams['expire'] : OA_Dal::noDateValue();
     $this->impressionTargetTotal = isset($aParams['impression_target_total']) ? (int) $aParams['impression_target_total'] : 0;
     $this->clickTargetTotal = isset($aParams['click_target_total']) ? (int) $aParams['click_target_total'] : 0;
     $this->conversionTargetTotal = isset($aParams['conversion_target_total']) ? (int) $aParams['conversion_target_total'] : 0;
     $this->impressionTargetDaily = isset($aParams['impression_target_daily']) ? (int) $aParams['impression_target_daily'] : 0;
     $this->clickTargetDaily = isset($aParams['click_target_daily']) ? (int) $aParams['click_target_daily'] : 0;
     $this->conversionTargetDaily = isset($aParams['conversion_target_daily']) ? (int) $aParams['conversion_target_daily'] : 0;
     $this->priority = isset($aParams['priority']) ? (int) $aParams['priority'] : 0;
     // Set the object's data access layer objects
     $this->oMaxDalEntities =& $this->_getMAX_Dal_Entities();
     $this->oMaxDalMaintenancePriority =& $this->_getOA_Dal_Maintenance_Priority();
 }