当前位置: 首页>>代码示例>>PHP>>正文


PHP OA_Dal::noDateValue方法代码示例

本文整理汇总了PHP中OA_Dal::noDateValue方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_Dal::noDateValue方法的具体用法?PHP OA_Dal::noDateValue怎么用?PHP OA_Dal::noDateValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OA_Dal的用法示例。


在下文中一共展示了OA_Dal::noDateValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: readDataFromArray

 /**
  * This method initialises object from array.
  *
  * @param array $aEntityData
  */
 function readDataFromArray($aEntityData)
 {
     $aFieldsTypes = $this->getFieldsTypes();
     foreach ($aFieldsTypes as $fieldName => $fieldType) {
         if (array_key_exists($fieldName, $aEntityData)) {
             if ($fieldType == 'date') {
                 // If the date is 'no date' then don't return this element in the response at all.
                 if (empty($aEntityData[$fieldName]) || $aEntityData[$fieldName] == OA_Dal::noDateValue()) {
                     unset($this->{$fieldName});
                 } else {
                     $this->{$fieldName} = new Date($aEntityData[$fieldName]);
                 }
             } else {
                 $this->{$fieldName} = $aEntityData[$fieldName];
             }
         }
     }
 }
开发者ID:villos,项目名称:tree_admin,代码行数:23,代码来源:Info.php

示例2: defaultValueByType

 /**
  * Return (or set) a default field value based on field type
  *
  * @see DB_DataObject for list of defined field types
  *
  * @param string $fieldType        Field type to set
  * @param string $setDefaultValue  Value to set
  * @return string
  * @static
  */
 function defaultValueByType($fieldType, $setDefaultValue = null)
 {
     static $aDefaultValues;
     if ($setDefaultValue !== null) {
         $aDefaultValues[$fieldType] = $setDefaultValue;
     }
     if (isset($aDefaultValues[$fieldType])) {
         return $aDefaultValues[$fieldType];
     }
     // This is the only exception we found so far, if we will find more we may need
     // to refactor following
     if ($fieldType & DB_DATAOBJECT_DATE) {
         if ($fieldType & DB_DATAOBJECT_NOTNULL) {
             return MAX_DATAGENERATOR_DEFAULT_DATE_VALUE;
         }
         // According to https://developer.openx.org/wiki/DatabasePractices#UsingPEAR::MDB2
         return OA_Dal::noDateValue();
     }
     // If no default set for this data type try default type
     if (isset($aDefaultValues[MAX_DATAGENERATOR_DEFAULT_TYPE])) {
         return $aDefaultValues[MAX_DATAGENERATOR_DEFAULT_TYPE];
     }
     // If still nothing found use a global default
     return MAX_DATAGENERATOR_DEFAULT_VALUE;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:35,代码来源:DataGenerator.php

示例3: manageCampaigns


//.........这里部分代码省略.........
                         }
                     }
                     if ($aCampaign['targetconversions'] > 0) {
                         if ($aCampaign['targetconversions'] <= $valuesRow['conversions']) {
                             // The campaign has a target limitation, and this has been
                             // passed, so update and disable the campaign
                             $disableReason |= OX_CAMPAIGN_DISABLED_CONVERSIONS;
                         }
                     }
                     if ($disableReason) {
                         // One of the campaign targets was exceeded, so disable
                         $message = '- Exceeded a campaign quota: Deactivating campaign ID ' . "{$aCampaign['campaign_id']}: {$aCampaign['campaign_name']}";
                         OA::debug($message, PEAR_LOG_INFO);
                         $report .= $message . "\n";
                         $doCampaigns = OA_Dal::factoryDO('campaigns');
                         $doCampaigns->campaignid = $aCampaign['campaign_id'];
                         $doCampaigns->find();
                         $doCampaigns->fetch();
                         $doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
                         $result = $doCampaigns->update();
                         if ($result == false) {
                             return MAX::raiseError($rows, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                         }
                         phpAds_userlogSetUser(phpAds_userMaintenance);
                         phpAds_userlogAdd(phpAds_actionDeactiveCampaign, $aCampaign['campaign_id']);
                     } else {
                         // The campaign didn't have a diable reason,
                         // it *might* possibly be diabled "soon"...
                         $canExpireSoon = true;
                     }
                 }
             }
             // Does the campaign need to be disabled due to the date?
             if ($aCampaign['end'] != OA_Dal::noDateValue()) {
                 // The campaign has a valid end date, stored in the timezone of the advertiser;
                 // create an end date in the advertiser's timezone, set the time, and then
                 // convert to UTC so that it can be compared with the MSE run time, which is
                 // in UTC
                 $aAdvertiserPrefs = OA_Preferences::loadAccountPreferences($aCampaign['advertiser_account_id'], true);
                 $oTimezone = new Date_Timezone($aAdvertiserPrefs['timezone']);
                 $oEndDate = new Date();
                 $oEndDate->convertTZ($oTimezone);
                 $oEndDate->setDate($aCampaign['end'] . ' 23:59:59');
                 // Campaigns end at the end of the day
                 $oEndDate->toUTC();
                 if ($oDate->after($oEndDate)) {
                     // The end date has been passed; disable the campaign
                     $disableReason |= OX_CAMPAIGN_DISABLED_DATE;
                     $message = "- Passed campaign end time of '{$aCampaign['end']} 23:59:59 {$aAdvertiserPrefs['timezone']} (" . $oEndDate->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEndDate->tz->getShortName() . ")': Deactivating campaign ID {$aCampaign['campaign_id']}: {$aCampaign['campaign_name']}";
                     OA::debug($message, PEAR_LOG_INFO);
                     $report .= $message . "\n";
                     $doCampaigns = OA_Dal::factoryDO('campaigns');
                     $doCampaigns->campaignid = $aCampaign['campaign_id'];
                     $doCampaigns->find();
                     $doCampaigns->fetch();
                     $doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
                     $result = $doCampaigns->update();
                     if ($result == false) {
                         return MAX::raiseError($rows, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                     }
                     phpAds_userlogSetUser(phpAds_userMaintenance);
                     phpAds_userlogAdd(phpAds_actionDeactiveCampaign, $aCampaign['campaign_id']);
                 } else {
                     // The campaign wasn't disabled based on the end
                     // date, to it *might* possibly be disabled "soon"...
                     $canExpireSoon = true;
开发者ID:villos,项目名称:tree_admin,代码行数:67,代码来源:Statistics.php

示例4: checkDateOrder

 /**
  * Checks whether end date is after start date.
  *
  * @access public
  *
  * @param date $oStartDate  Pear::Date object with Start Date
  * @param date $oEndDate    Pear::Date object with End Date
  *
  * @return boolean  Returns false when start date
  *                      is after end date and true in other case.
  */
 function checkDateOrder($oStartDate, $oEndDate)
 {
     if (isset($oStartDate) && isset($oEndDate) && ($oStartDate->format("%Y-%m-%d") != OA_Dal::noDateValue() && $oEndDate->format("%Y-%m-%d") != OA_Dal::noDateValue()) && $oStartDate->after($oEndDate)) {
         $this->raiseError('The start date is after the end date');
         return false;
     } else {
         return true;
     }
 }
开发者ID:villos,项目名称:tree_admin,代码行数:20,代码来源:Dll.php

示例5: _convertDateFromIso8601Format

 /**
  * Convert Date from iso 8601 format.
  *
  * @access private
  *
  * @param string $date  date string in ISO 8601 format
  * @param PEAR::Date &$oResult  transformed date
  * @param XML_RPC_Response &$oResponseWithError  response with error message
  *
  * @return boolean  shows true if method was executed successfully
  */
 function _convertDateFromIso8601Format($date, &$oResult, &$oResponseWithError)
 {
     $datetime = explode('T', $date);
     $year = substr($datetime[0], 0, strlen($datetime[0]) - 4);
     $month = substr($datetime[0], -4, 2);
     $day = substr($datetime[0], -2, 2);
     // Explicitly allow the "zero date" value to be set
     if ($year == 0 && $month == 0 && $day == 0) {
         $oResult = new Date(OA_Dal::noDateValue());
         return true;
     }
     if ($year < 1970 || $year > 2038) {
         $oResponseWithError = XmlRpcUtils::generateError('Year should be in range 1970-2038');
         return false;
     } elseif ($month < 1 || $month > 12) {
         $oResponseWithError = XmlRpcUtils::generateError('Month should be in range 1-12');
         return false;
     } elseif ($day < 1 || $day > 31) {
         $oResponseWithError = XmlRpcUtils::generateError('Day should be in range 1-31');
         return false;
     } else {
         $oResult = new Date();
         $oResult->setYear($year);
         $oResult->setMonth($month);
         $oResult->setDay($day);
         return true;
     }
 }
开发者ID:villos,项目名称:tree_admin,代码行数:39,代码来源:XmlRpcUtils.php

示例6: setDefaultForAdd

 /**
  * This function sets all default values when adding new campaign.
  *
  */
 function setDefaultForAdd()
 {
     if (is_null($this->startDate)) {
         $this->startDate = new Date(OA_Dal::noDateValue());
     }
     if (is_null($this->endDate)) {
         $this->endDate = new Date(OA_Dal::noDateValue());
     }
     if (is_null($this->impressions)) {
         $this->impressions = -1;
     }
     if (is_null($this->clicks)) {
         $this->clicks = -1;
     }
     if (is_null($this->priority)) {
         $this->priority = 0;
     }
     if (is_null($this->weight)) {
         $this->weight = 1;
     }
     if (is_null($this->targetImpressions)) {
         $this->targetImpressions = 0;
     }
     if (is_null($this->targetClicks)) {
         $this->targetClicks = 0;
     }
     if (is_null($this->targetConversions)) {
         $this->targetConversions = 0;
     }
     if (is_null($this->revenue)) {
         // Leave null
     }
     if (is_null($this->revenueType)) {
         // Leave null
     }
     if (is_null($this->capping)) {
         // Leave null
     }
     if (is_null($this->sessionCapping)) {
         // Leave null
     }
     if (is_null($this->block)) {
         // Leave null
     }
 }
开发者ID:villos,项目名称:tree_admin,代码行数:49,代码来源:CampaignInfo.php

示例7: OX_Maintenance_Priority_Campaign

 /**
  * 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();
 }
开发者ID:villos,项目名称:tree_admin,代码行数:56,代码来源:Campaign.php

示例8: processCampaignForm

/**
 * Processes submit values of campaign form
 *
 * @param OA_Admin_UI_Component_Form $form form to process
 * @return An array of Pear::Error objects if any
 */
function processCampaignForm($form, &$oComponent = null)
{
    $aFields = $form->exportValues();
    $expire = !empty($aFields['end']) ? date('Y-m-d', strtotime($aFields['end'])) : OA_Dal::noDateValue();
    $activate = !empty($aFields['start']) ? date('Y-m-d', strtotime($aFields['start'])) : OA_Dal::noDateValue();
    if (empty($aFields['campaignid'])) {
        // The form is submitting a new campaign, so, the ID is not set;
        // set the ID to the string "null" so that the table auto_increment
        // or sequence will be used when the campaign is created
        $aFields['campaignid'] = "null";
    } else {
        // The form is submitting a campaign modification; need to test
        // if any of the banners in the campaign are linked to an email zone,
        // and if so, if the link(s) would still be valid if the change(s)
        // to the campaign were made...
        $dalCampaigns = OA_Dal::factoryDAL('campaigns');
        $aCurrentLinkedEmalZoneIds = $dalCampaigns->getLinkedEmailZoneIds($aFields['campaignid']);
        if (PEAR::isError($aCurrentLinkedEmalZoneIds)) {
            OX::disableErrorHandling();
            $errors[] = PEAR::raiseError($GLOBALS['strErrorDBPlain']);
            OX::enableErrorHandling();
        }
        $errors = array();
        foreach ($aCurrentLinkedEmalZoneIds as $zoneId) {
            $thisLink = Admin_DA::_checkEmailZoneAdAssoc($zoneId, $aFields['campaignid'], $activate, $expire);
            if (PEAR::isError($thisLink)) {
                $errors[] = $thisLink;
                break;
            }
        }
    }
    //correct and check revenue and ecpm
    correctAdnCheckNumericFormField($aFields, $errors, 'revenue', $GLOBALS['strErrorEditingCampaignRevenue']);
    correctAdnCheckNumericFormField($aFields, $errors, 'ecpm', $GLOBALS['strErrorEditingCampaignECPM']);
    if (empty($errors)) {
        //check booked limits values
        // If this is a remnant, ecpm or exclusive campaign with an expiry date, set the target's to unlimited
        if (OA_Dal::isValidDate($expire) && ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_ECPM || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_EXCLUSIVE)) {
            $aFields['impressions'] = $aFields['clicks'] = $aFields['conversions'] = -1;
        } else {
            if (!empty($aFields['impr_unlimited']) && $aFields['impr_unlimited'] == 't') {
                $aFields['impressions'] = -1;
            } else {
                if (empty($aFields['impressions']) || $aFields['impressions'] == '-') {
                    $aFields['impressions'] = 0;
                }
            }
            if (!empty($aFields['click_unlimited']) && $aFields['click_unlimited'] == 't') {
                $aFields['clicks'] = -1;
            } else {
                if (empty($aFields['clicks']) || $aFields['clicks'] == '-') {
                    $aFields['clicks'] = 0;
                }
            }
            if (!empty($aFields['conv_unlimited']) && $aFields['conv_unlimited'] == 't') {
                $aFields['conversions'] = -1;
            } else {
                if (empty($aFields['conversions']) || $aFields['conversions'] == '-') {
                    $aFields['conversions'] = 0;
                }
            }
        }
        //pricing model - reset fields not applicable to model to 0,
        //note that in new flow MAX_FINANCE_CPA allows all limits to be set
        if ($aFields['revenue_type'] == MAX_FINANCE_CPM) {
            $aFields['clicks'] = -1;
            $aFields['conversions'] = -1;
        } else {
            if ($aFields['revenue_type'] == MAX_FINANCE_CPC) {
                $aFields['conversions'] = -1;
            } else {
                if ($aFields['revenue_type'] == MAX_FINANCE_MT) {
                    $aFields['impressions'] = -1;
                    $aFields['clicks'] = -1;
                    $aFields['conversions'] = -1;
                }
            }
        }
        //check type and set priority
        if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT) {
            $aFields['priority'] = 0;
            //low
        } else {
            if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_NORMAL) {
                $aFields['priority'] = isset($aFields['high_priority_value']) ? $aFields['high_priority_value'] : 5;
                //high
            } else {
                if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_EXCLUSIVE) {
                    $aFields['priority'] = -1;
                    //exclusive
                } else {
                    if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_ECPM) {
                        $aFields['priority'] = -2;
                        //ecpm
//.........这里部分代码省略.........
开发者ID:villos,项目名称:tree_admin,代码行数:101,代码来源:campaign-edit.php

示例9: setDefaultValue

 function setDefaultValue($fieldName, $fieldType)
 {
     if (isset($this->defaultValues[$fieldName])) {
         if ($this->defaultValues[$fieldName] === '%DATE_TIME%') {
             return date('Y-m-d H:i:s');
         } else {
             if ($this->defaultValues[$fieldName] === '%NO_DATE_TIME%') {
                 return OA_Dal::noDateValue();
             }
         }
         return $this->defaultValues[$fieldName];
     } else {
         if ($fieldName == 'updated') {
             return date('Y-m-d H:i:s');
         }
     }
     return NULL;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:18,代码来源:DB_DataObjectCommon.php

示例10: isValidDate

 /**
  * Returns true if $sqlDate is not an 'empty' date, false otherwise.
  *
  * @static
  * @param string $sqlDate
  */
 function isValidDate($sqlDate)
 {
     $dbh = OA_DB::singleton();
     return preg_match('#\\d\\d\\d\\d-\\d\\d-\\d\\d#', $sqlDate) && $sqlDate != OA_Dal::noDateValue();
 }
开发者ID:villos,项目名称:tree_admin,代码行数:11,代码来源:Dal.php

示例11: distributeCampaignImpressions

 /**
  * A method to distribute the calculated required campaign impressions between the campaign's
  * children advertisements. Impression allocation takes in to account ad weight, and the number
  * of operations intervals the ad will be active in given date/time delivery limitations, and
  * the pattern of available impressions for the zone(s) the advertisements are linked to.
  *
  * The calculated ad impressions are written to the temporary table tmp_ad_required_impression
  * for later analysis by the {@link OA_Maintenance_Priority_AdServer_Task_AllocateZoneImpressions}
  * class.
  *
  * @param array $aCampaigns An array of {@link OX_Maintenance_Priority_Campaign} objects which require
  *                          that their total required impressions be distributed between the
  *                          component advertisements.
  */
 function distributeCampaignImpressions($aCampaigns)
 {
     // Create an array for storing required ad impressions
     $aRequiredAdImpressions = array();
     // Get the current operation interval start/end dates
     $aCurrentOperationIntervalDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($this->_getDate());
     // For each campaign
     foreach ($aCampaigns as $oCampaign) {
         OA::debug('  - Distributing impression inventory requirements for campaign ID: ' . $oCampaign->id, PEAR_LOG_DEBUG);
         $adsCount = count($oCampaign->aAds);
         if ($adsCount == 1) {
             $adsWord = 'ad';
         } else {
             $adsWord = 'ads';
         }
         OA::debug("    - Campaign has {$adsCount} {$adsWord}.", PEAR_LOG_DEBUG);
         // Get date object to represent campaign expiration date
         if ($oCampaign->impressionTargetDaily > 0 || $oCampaign->clickTargetDaily > 0 || $oCampaign->conversionTargetDaily > 0) {
             // The campaign has a daily target to meet, so treat the
             // campaign as if it expires at the end of "today", regardless
             // of the existance of any activation or expiration dates that
             // may (or may not) be set for the campaign
             $oDate =& $this->_getDate();
             // Get the end of the day from this date
             $oCampaignExpiryDate = new Date($oDate->format('%Y-%m-%d') . ' 23:59:59');
         } else {
             if ($oCampaign->expire != OA_Dal::noDateValue() && ($oCampaign->impressionTargetTotal > 0 || $oCampaign->clickTargetTotal > 0 || $oCampaign->conversionTargetTotal > 0)) {
                 // The campaign has an expiration date, and has some kind of
                 // (total) inventory requirement, so treat the campaign as if
                 // it expires at the end of the expiration date
                 $oCampaignExpiryDate =& $this->_getDate($oCampaign->expire);
                 // Campaign expires at end of expiry date, so add one day less one
                 // second, so we have a date with time portion 23:59:59
                 $oCampaignExpiryDate->addSeconds(SECONDS_PER_DAY - 1);
             } else {
                 // Error! There should not be any other kind of high-priority
                 // campaign in terms of activation/expiration dates and
                 // either (total) inventory requirements or daily targets
                 $message = "- Error calculating the end date for Campaign ID {$oCampaign->id}";
                 OA::debug($message, PEAR_LOG_ERR);
                 continue;
             }
         }
         // Determine number of remaining operation intervals for campaign
         $message = "  - Calculating campaign remaining operation intervals.";
         OA::debug($message, PEAR_LOG_DEBUG);
         $campaignRemainingOperationIntervals = OX_OperationInterval::getIntervalsRemaining($aCurrentOperationIntervalDates['start'], $oCampaignExpiryDate);
         // For all ads in the campaign, determine:
         // - If the ad is capable of delivery in the current operation
         //   interval, or not, based on if it is linked to any zones, and,
         //   if so:
         // - If the ad is capable of delivery in the current operation
         //   interval, or not, based on delivery limitation(s), and if so;
         // - The result of the weight of the ad multiplied by the
         //   number of operation intervals remaining in which the ad
         //   is capable of delivering
         $aAdZones = array();
         $aAdDeliveryLimtations = array();
         $aAdCurrentOperationInterval = array();
         $aAdWeightRemainingOperationIntervals = array();
         $aInvalidAdIds = array();
         reset($oCampaign->aAds);
         while (list($key, $oAd) = each($oCampaign->aAds)) {
             // Only calculate values for active ads
             if ($oAd->active && $oAd->weight > 0) {
                 $message = "    - Calculating remaining operation intervals for ad ID: {$oAd->id}";
                 OA::debug($message, PEAR_LOG_DEBUG);
                 // Get all zones associated with the ad
                 $aAdsZones = $this->oDal->getAdZoneAssociationsByAds(array($oAd->id));
                 $aAdZones[$oAd->id] = @$aAdsZones[$oAd->id];
                 if (is_null($aAdZones[$oAd->id])) {
                     $aInvalidAdIds[] = $oAd->id;
                     $message = "      - Ad ID {$oAd->id} has no linked zones, will skip...";
                     OA::debug($message, PEAR_LOG_ERR);
                     continue;
                 }
                 // Prepare a delivery limitation object for the ad
                 $aAdDeliveryLimtations[$oAd->id] = new OA_Maintenance_Priority_DeliveryLimitation($oAd->getDeliveryLimitations());
                 // Is the ad blocked from delivering in the current operation interval?
                 $aAdCurrentOperationInterval[$oAd->id] = $aAdDeliveryLimtations[$oAd->id]->deliveryBlocked($aCurrentOperationIntervalDates['start']);
                 // Determine how many operation intervals remain that the ad can deliver in
                 $adRemainingOperationIntervals = $aAdDeliveryLimtations[$oAd->id]->getActiveAdOperationIntervals($campaignRemainingOperationIntervals, $aCurrentOperationIntervalDates['start'], $oCampaignExpiryDate);
                 // Determine the value of the ad weight multiplied by the number
                 // of operation intervals remaining that the ad can deliver in
                 if ($oAd->weight > 0) {
                     $aAdWeightRemainingOperationIntervals[$oAd->id] = $oAd->weight * $adRemainingOperationIntervals;
//.........这里部分代码省略.........
开发者ID:villos,项目名称:tree_admin,代码行数:101,代码来源:GetRequiredAdImpressions.php

示例12: sendCampaignImpendingExpiryEmail


//.........这里部分代码省略.........
         $aPrefs['admin'] = $aAdminPrefs;
         // Create a linked user 'special' for the advertiser that will take the admin preferences for advertiser
         $aLinkedUsers['special']['advertiser'] = $doClients->toArray();
         $aLinkedUsers['special']['advertiser']['contact_name'] = $aLinkedUsers['special']['advertiser']['contact'];
         $aLinkedUsers['special']['advertiser']['email_address'] = $aLinkedUsers['special']['advertiser']['email'];
         $aLinkedUsers['special']['advertiser']['language'] = '';
         $aLinkedUsers['special']['advertiser']['user_id'] = 0;
         // Check that every user is not going to receive more than one email if they
         // are linked to more than one account
         $aLinkedUsers = $this->_deleteDuplicatedUser($aLinkedUsers);
         // Create the linked special user preferences from the admin preferences
         // the special user is the client that doesn't have preferences in the database
         $aPrefs['special'] = $aPrefs['admin'];
         $aPrefs['special']['warn_email_special'] = $aPrefs['special']['warn_email_advertiser'];
         $aPrefs['special']['warn_email_special_day_limit'] = $aPrefs['special']['warn_email_advertiser_day_limit'];
         $aPrefs['special']['warn_email_special_impression_limit'] = $aPrefs['special']['warn_email_advertiser_impression_limit'];
         // Store in the client cache
         $this->aClientCache = array($aCampaign['clientid'] => array($aLinkedUsers, $aPrefs, $aAgencyFromDetails));
     } else {
         // Retrieve client cache
         list($aLinkedUsers, $aPrefs, $aAgencyFromDetails) = $this->aClientCache[$aCampaign['clientid']];
     }
     $copiesSent = 0;
     foreach ($aLinkedUsers as $accountType => $aUsers) {
         if ($accountType == 'special' || $accountType == 'advertiser') {
             // Get the agency details and use them for emailing advertisers
             $aFromDetails = $aAgencyFromDetails;
         } else {
             // Use the Admin details
             $aFromDetails = '';
         }
         if ($aPrefs[$accountType]['warn_email_' . $accountType]) {
             // Does the account type want warnings when the impressions are low?
             if ($aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit'] > 0 && $aCampaign['views'] > 0) {
                 // Test to see if the placements impressions remaining are less than the limit
                 $dalCampaigns = OA_Dal::factoryDAL('campaigns');
                 $remainingImpressions = $dalCampaigns->getAdImpressionsLeft($aCampaign['campaignid']);
                 if ($remainingImpressions < $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit']) {
                     // Yes, the placement will expire soon! But did the placement just reach
                     // the point where it is about to expire, or did it happen a while ago?
                     $previousRemainingImpressions = $dalCampaigns->getAdImpressionsLeft($aCampaign['campaignid'], $aPreviousOIDates['end']);
                     if ($previousRemainingImpressions >= $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit']) {
                         // Yes! This is the operation interval that the boundary
                         // was crossed to the point where it's about to expire,
                         // so send that email, baby!
                         foreach ($aUsers as $aUser) {
                             $aEmail = $this->prepareCampaignImpendingExpiryEmail($aUser, $aCampaign['clientid'], $aCampaign['campaignid'], 'impressions', $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit'], $accountType);
                             if ($aEmail !== false) {
                                 if ($this->sendMail($aEmail['subject'], $aEmail['contents'], $aUser['email_address'], $aUser['contact_name'], $aFromDetails)) {
                                     $copiesSent++;
                                     if ($aConf['email']['logOutgoing']) {
                                         phpAds_userlogSetUser(phpAds_userMaintenance);
                                         phpAds_userlogAdd(phpAds_actionWarningMailed, $aPlacement['campaignid'], "{$aEmail['subject']}\n\n\n                                                 {$aUser['contact_name']}({$aUser['email_address']})\n\n\n                                                 {$aEmail['contents']}");
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             // Does the account type want warnings when the days are low?
             if ($aPrefs[$accountType]['warn_email_' . $accountType . '_day_limit'] > 0 && $aCampaign['expire'] != OA_Dal::noDateValue()) {
                 // Calculate the date that should be used to see if the warning needs to be sent
                 $warnSeconds = (int) ($aPrefs[$accountType]['warn_email_' . $accountType . '_day_limit'] + 1) * SECONDS_PER_DAY;
                 $oEndDate = new Date($aCampaign['expire'] . ' 23:59:59');
                 // Convert day to end of Date
                 $oTestDate = new Date();
                 $oTestDate->copy($oDate);
                 $oTestDate->addSeconds($warnSeconds);
                 // Test to see if the test date is after the placement's expiration date
                 if ($oTestDate->after($oEndDate)) {
                     // Yes, the placement will expire soon! But did the placement just reach
                     // the point where it is about to expire, or did it happen a while ago?
                     $oiSeconds = (int) $aConf['maintenance']['operationInterval'] * 60;
                     $oTestDate->subtractSeconds($oiSeconds);
                     if (!$oTestDate->after($oEndDate)) {
                         // Yes! This is the operation interval that the boundary
                         // was crossed to the point where it's about to expire,
                         // so send those emails, baby!
                         foreach ($aUsers as $aUser) {
                             $aEmail = $this->prepareCampaignImpendingExpiryEmail($aUser, $aCampaign['clientid'], $aCampaign['campaignid'], 'date', $oEndDate->format($date_format), $accountType);
                             if ($aEmail !== false) {
                                 if ($this->sendMail($aEmail['subject'], $aEmail['contents'], $aUser['email_address'], $aUser['contact_name'], $aFromDetails)) {
                                     $copiesSent++;
                                     if ($aConf['email']['logOutgoing']) {
                                         phpAds_userlogSetUser(phpAds_userMaintenance);
                                         phpAds_userlogAdd(phpAds_actionWarningMailed, $aPlacement['campaignid'], "{$aEmail['subject']}\n\n\n                                                 {$aUser['contact_name']}({$aUser['email_address']})\n\n\n                                                 {$aEmail['contents']}");
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Restore the default language strings
     Language_Loader::load('default');
     return $copiesSent;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:101,代码来源:Email.php


注:本文中的OA_Dal::noDateValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。