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


PHP Admin_DA::addAdZone方法代码示例

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


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

示例1: testGetLinkedEmailZoneIds

 /**
  * A method to test the getLinkedEmailZoneIds() method.
  *
  * Note that the banner/zone association in this test is
  * performed via the Admin_DA class, as a result of the fact
  * that neither the "zone" or "banner" Entity Service
  * classes support this functionality at the time of writing.
  */
 function testGetLinkedEmailZoneIds()
 {
     $oDataGenerator = new DataGenerator();
     $dalZones = OA_Dal::factoryDAL('zones');
     // Test with invalid input
     $aResult = $this->oDalCampaigns->getLinkedEmailZoneIds('foo');
     $this->assertTrue(is_array($aResult));
     $this->assertTrue(empty($aResult));
     // Test with invalid campaign IDs
     $aResult = $this->oDalCampaigns->getLinkedEmailZoneIds(-1);
     $this->assertTrue(is_array($aResult));
     $this->assertTrue(empty($aResult));
     $aResult = $this->oDalCampaigns->getLinkedEmailZoneIds(0);
     $this->assertTrue(is_array($aResult));
     $this->assertTrue(empty($aResult));
     $aResult = $this->oDalCampaigns->getLinkedEmailZoneIds(2);
     $this->assertTrue(is_array($aResult));
     $this->assertTrue(empty($aResult));
     // Generate an owning manager account
     $doAgency = OA_Dal::factoryDO('agency');
     $managerId = $oDataGenerator->generateOne($doAgency);
     // Generate an advertiser account within the manager account
     $doClients = OA_Dal::factoryDO('clients');
     $doClients->agencyid = $managerId;
     $advertiserId = $oDataGenerator->generateOne($doClients);
     // Generate a website account within the manager account
     $doAffiliates = OA_Dal::factoryDO('affiliates');
     $doAffiliates->agencyid = $managerId;
     $websiteId = $oDataGenerator->generateOne($doAffiliates);
     // Generate a campaign, with start and end dates
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->clientid = $advertiserId;
     $doCampaigns->activate_time = '2009-02-23 00:00:00';
     $doCampaigns->expire_time = '2009-02-24 23:59:59';
     $campaignId = $oDataGenerator->generateOne($doCampaigns);
     // Generate a banner in the campaign generated above
     $doBanners = OA_Dal::factoryDO('banners');
     $doBanners->campaignid = $campaignId;
     $bannerId = $oDataGenerator->generateOne($doBanners);
     // Test with no linked zones
     $aResult = $this->oDalCampaigns->getLinkedEmailZoneIds($campaignId);
     $this->assertTrue(is_array($aResult));
     $this->assertTrue(empty($aResult));
     // Add two non-email zones, and link the campaign to the zones
     $doZones = OA_Dal::factoryDO('zones');
     $doZones->affiliateid = $websiteId;
     $doZones->delivery = phpAds_ZoneBanner;
     $zoneId1 = $oDataGenerator->generateOne($doZones);
     $result = $dalZones->linkZonesToCampaign(array($zoneId1), $campaignId);
     $this->assertEqual($result, 1);
     $doZones = OA_Dal::factoryDO('zones');
     $doZones->affiliateid = $websiteId;
     $doZones->delivery = phpAds_ZonePopup;
     $zoneId2 = $oDataGenerator->generateOne($doZones);
     $result = $dalZones->linkZonesToCampaign(array($zoneId2), $campaignId);
     $this->assertEqual($result, 1);
     // Test with linked zones that are not email zones
     $aResult = $this->oDalCampaigns->getLinkedEmailZoneIds($campaignId);
     $this->assertTrue(is_array($aResult));
     $this->assertTrue(empty($aResult));
     // Add an email zone, and link the campaign's banner to the zone
     $doZones = OA_Dal::factoryDO('zones');
     $doZones->affiliateid = $websiteId;
     $doZones->delivery = MAX_ZoneEmail;
     $zoneId3 = $oDataGenerator->generateOne($doZones);
     $aParameters = array('zone_id' => $zoneId3, 'ad_id' => $bannerId);
     $result = Admin_DA::addAdZone($aParameters);
     $this->assertTrue($result);
     // Test with linked zones, one of which is an email zone
     $aResult = $this->oDalCampaigns->getLinkedEmailZoneIds($campaignId);
     $this->assertTrue(is_array($aResult));
     $this->assertTrue(!empty($aResult));
     $this->assertEqual(count($aResult), 1);
     $this->assertEqual($aResult[0], $zoneId3);
     // Add another email zone, and link the campaign's banner to the zone
     $doZones = OA_Dal::factoryDO('zones');
     $doZones->affiliateid = $websiteId;
     $doZones->delivery = MAX_ZoneEmail;
     $zoneId4 = $oDataGenerator->generateOne($doZones);
     $aParameters = array('zone_id' => $zoneId4, 'ad_id' => $bannerId);
     $result = Admin_DA::addAdZone($aParameters);
     $this->assertTrue($result);
     // Test with linked zones, some of which are email zones
     $aResult = $this->oDalCampaigns->getLinkedEmailZoneIds($campaignId);
     $this->assertTrue(is_array($aResult));
     $this->assertTrue(!empty($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult[0], $zoneId3);
     $this->assertEqual($aResult[1], $zoneId4);
 }
开发者ID:Jaree,项目名称:revive-adserver,代码行数:98,代码来源:Campaigns.dal.test.php

示例2: testdeleteAdZones

 function testdeleteAdZones()
 {
     $this->_generateStats();
     $ret = Admin_DA::addAdZone(array('zone_id' => $this->zoneId, 'ad_id' => $this->bannerId));
     $this->assertTrue(is_int($ret));
     $this->assertTrue($ret > 0);
     Admin_DA::deleteAdZones(array('zone_id' => $this->zoneId, 'ad_id' => $this->adId));
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:8,代码来源:AdminDA.dal.test.php

示例3: linkBanner

 /**
  * A method to link a banner to a zone
  *
  * @param int $zoneId
  * @param int $bannerId
  * @return bool
  */
 function linkBanner($zoneId, $bannerId)
 {
     if ($this->checkIdExistence('zones', $zoneId)) {
         $doZones = OA_Dal::staticGetDO('zones', $zoneId);
         if (!$this->checkPermissions(null, 'affiliates', $doZones->affiliateid, OA_PERM_ZONE_LINK)) {
             return false;
         }
         if ($this->checkIdExistence('banners', $bannerId)) {
             $aLinkedAds = Admin_DA::getAdZones(array('zone_id' => $zoneId), false, 'ad_id');
             if (!isset($aLinkedAds[$bannerId])) {
                 $result = Admin_DA::addAdZone(array('zone_id' => $zoneId, 'ad_id' => $bannerId));
                 if (PEAR::isError($result)) {
                     $this->raiseError($result->getMessage());
                     return false;
                 }
                 return true;
             } else {
                 // Already linked
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:Jaree,项目名称:revive-adserver,代码行数:31,代码来源:Zone.php

示例4: MAX_duplicateAdZones

function MAX_duplicateAdZones($fromAdId, $toAdId)
{
    $aAdZones = Admin_DA::getAdZones(array('ad_id' => $fromAdId), true, 'zone_id');
    if (!empty($aAdZones)) {
        foreach ($aAdZones as $zoneId => $adId) {
            Admin_DA::addAdZone(array('ad_id' => $toAdId, 'zone_id' => $zoneId));
        }
    }
}
开发者ID:villos,项目名称:tree_admin,代码行数:9,代码来源:common.php

示例5: insert

 function insert($autoLinkMatchingZones = true)
 {
     $this->_rebuildCache();
     $id = parent::insert();
     if ($id) {
         // add default zone
         $aVariables = array('ad_id' => $id, 'zone_id' => 0);
         Admin_DA::addAdZone($aVariables);
         if ($autoLinkMatchingZones) {
             MAX_addDefaultPlacementZones($id, $this->campaignid);
         }
     }
     return $id;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:14,代码来源:Banners.php

示例6: insertDefaultData

 /**
  * A method to insert the default data into the database.
  *
  * The default data are:
  *
  *  - Test Advertiser 1
  *    - Placement 11
  *      - High Priority
  *      - Daily target of 120 impressions (5 per
  *        hour assuming even delivery each hour)
  *        - Advertisement 111
  *          - Banner Weight 1
  *    - Placement 12
  *      - High Priority
  *      - Runs from 2005-01-01 to 2005-12-31
  *      - Total target of 87,600 (10 per hour
  *        assuming even delivery each hour)
  *        - Advertisement 121
  *          - Banner Weight 2
  *        - Advertisement 122
  *          - Banner Weight 1
  *
  *  - Test Advertiser 2
  *    - Placement 21
  *    - Placement 22
  *
  *  - Test Publisher 1
  *    - Zone 11
  *    - Zone 12
  *
  *  - Test Publisher 2
  *    - Zone 21
  *    - Zone 22
  *
  * - Advertisement 111 is linked to Zone 11
  * - Advertisement 121 is linked to Zone 21
  * - Advertisement 122 is linked to Zone 21 AND Zone 22
  *
  * @static
  * @access public
  * @TODO Complete the specification of the default data and the implementation
  *       of the creation thereof.
  */
 function insertDefaultData()
 {
     $oDbh =& OA_DB::singleton();
     // Set now
     $oServiceLocator =& OA_ServiceLocator::instance();
     $oldNow = $oServiceLocator->get('now');
     $oServiceLocator->register('now', new Date('2005-03-01'));
     // Add a default agency
     $agencyID = Admin_DA::addAgency(array('name' => 'Test Agency', 'contact' => 'Contact Name', 'username' => 'agency', 'email' => 'agency@example.com', 'active' => 1));
     // Add two advertisers for the agency
     $advertiserOneID = Admin_DA::addAdvertiser(array('agencyid' => $agencyID, 'clientname' => 'Test Advertiser 1', 'contact' => 'Contact Name 1', 'clientusername' => 'advertiser1', 'email' => 'advertiser1@example.com'));
     $advertiserTwoID = Admin_DA::addAdvertiser(array('agencyid' => $agencyID, 'clientname' => 'Test Advertiser 2', 'contact' => 'Contact Name 2', 'clientusername' => 'advertiser2', 'email' => 'advertiser2@example.com'));
     // Add the advertiser's placements (campaigns) & advertisements
     $campaignOneOneID = Admin_DA::addPlacement(array('campaignname' => 'Campaign 11 - Manual Daily Target of 120', 'clientid' => $advertiserOneID, 'views' => -1, 'clicks' => -1, 'conversions' => -1, 'status' => OA_ENTITY_STATUS_RUNNING, 'priority' => 2, 'target_impression' => 120, 'target_click' => -1, 'target_conversion' => -1));
     $adOneOneOneID = Admin_DA::addAd(array('campaignid' => $campaignOneOneID, 'description' => 'Advertisement 111', 'active' => 't', 'weight' => 1, 'htmltemplate' => '', 'url' => '', 'bannertext' => '', 'compiledlimitation' => '', 'append' => ''));
     $campaignOneTwoID = Admin_DA::addPlacement(array('campaignname' => 'Campaign 22 - Auto Distribution of 87,600 Impressions', 'clientid' => $advertiserOneID, 'views' => 87600, 'clicks' => -1, 'conversions' => -1, 'status' => OA_ENTITY_STATUS_RUNNING, 'priority' => 2, 'target_impression' => -1, 'target_click' => -1, 'target_conversion' => -1, 'activate_time' => '2005-01-01 00:00:00', 'expire_time' => '2005-12-31 23:59:59'));
     $adOneTwoOneID = Admin_DA::addAd(array('campaignid' => $campaignOneTwoID, 'description' => 'Advertisement 121', 'active' => 't', 'weight' => 2, 'htmltemplate' => '', 'url' => '', 'bannertext' => '', 'compiledlimitation' => '', 'append' => ''));
     $adOneTwoTwoID = Admin_DA::addAd(array('campaignid' => $campaignOneTwoID, 'description' => 'Advertisement 122', 'active' => 't', 'weight' => 1, 'htmltemplate' => '', 'url' => '', 'bannertext' => '', 'compiledlimitation' => '', 'append' => ''));
     // Add two publishers for the agency
     $publisherOneID = Admin_DA::addPublisher(array('agencyid' => $agencyID, 'name' => 'Test Publisher 1', 'contact' => 'Contact Name 1', 'username' => 'publisher1', 'email' => 'publisher1@example.com'));
     $publisherTwoID = Admin_DA::addPublisher(array('agencyid' => $agencyID, 'name' => 'Test Publisher 1', 'contact' => 'Contact Name 1', 'username' => 'publisher1', 'email' => 'publisher1@example.com'));
     // Add the publisher's zones
     $zoneOneOneID = Admin_DA::addZone(array('affiliateid' => $publisherOneID, 'zonename' => 'Zone 11', 'type' => 0, 'category' => '', 'ad_selection' => '', 'chain' => '', 'prepend' => '', 'append' => '', 'what' => ''));
     $zoneOneTwoID = Admin_DA::addZone(array('affiliateid' => $publisherOneID, 'zonename' => 'Zone 12', 'type' => 0, 'category' => '', 'ad_selection' => '', 'chain' => '', 'prepend' => '', 'append' => '', 'what' => ''));
     $zoneTwoOneID = Admin_DA::addZone(array('affiliateid' => $publisherOneID, 'zonename' => 'Zone 21', 'type' => 0, 'category' => '', 'ad_selection' => '', 'chain' => '', 'prepend' => '', 'append' => '', 'what' => ''));
     $zoneTwoTwoID = Admin_DA::addZone(array('affiliateid' => $publisherOneID, 'zonename' => 'Zone 22', 'type' => 0, 'category' => '', 'ad_selection' => '', 'chain' => '', 'prepend' => '', 'append' => '', 'what' => ''));
     // Link the ads to the zones
     Admin_DA::addAdZone(array('ad_id' => $adOneOneOneID, 'zone_id' => $zoneOneOneID, 'link_type' => 1));
     Admin_DA::addAdZone(array('ad_id' => $adOneTwoOneID, 'zone_id' => $zoneTwoOneID, 'link_type' => 1));
     Admin_DA::addAdZone(array('ad_id' => $adOneTwoTwoID, 'zone_id' => $zoneTwoOneID, 'link_type' => 1));
     Admin_DA::addAdZone(array('ad_id' => $adOneTwoTwoID, 'zone_id' => $zoneTwoTwoID, 'link_type' => 1));
     // Restore "now"
     if ($oldNow) {
         $oServiceLocator->register('now', $oldNow);
     } else {
         $oServiceLocator->remove('now');
     }
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:81,代码来源:DefaultData.php

示例7: addPlacementZone

 function addPlacementZone($aVariables, $autoLinkMatchingBanners = true)
 {
     if (!($pzaId = Admin_DA::_addEntity('placement_zone_assoc', $aVariables))) {
         return false;
     }
     if (!$autoLinkMatchingBanners) {
         return $pzaId;
     }
     // Selects ads which belongs to the campaign (placement) and fit into
     // the zone. Then links all those ads to the zone if they are not linked already.
     $azParams = Admin_DA::getLinkedAdParams($aVariables['zone_id']);
     $azParams['placement_id'] = $aVariables['placement_id'];
     $azParams['market_ads_include'] = true;
     $azAds = Admin_DA::getAds($azParams);
     $azLinkedAds = Admin_DA::getAdZones(array('zone_id' => $aVariables['zone_id']), false, 'ad_id');
     foreach ($azAds as $adId => $azAd) {
         if (!isset($azLinkedAds[$adId])) {
             Admin_DA::addAdZone(array('zone_id' => $aVariables['zone_id'], 'ad_id' => $adId));
         }
     }
     return $pzaId;
 }
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:22,代码来源:Admin_DA.php

示例8: processForm


//.........这里部分代码省略.........
            // Reset append codes which called this zone
            $doZones = OA_Dal::factoryDO('zones');
            $doZones->appendtype = phpAds_ZoneAppendZone;
            if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
                $doZones->addReferenceFilter('agency', OA_Permission::getEntityId());
            } elseif (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
                $doZones->addReferenceFilter('affiliates', OA_Permission::getEntityId());
            }
            $doZones->find();
            while ($doZones->fetch() && ($row = $doZones->toArray())) {
                $append = phpAds_ZoneParseAppendCode($row['append']);
                if ($append[0]['zoneid'] == $aFields['zoneid']) {
                    $doZonesClone = clone $doZones;
                    $doZonesClone->appendtype = phpAds_ZoneAppendRaw;
                    $doZonesClone->append = '';
                    $doZonesClone->update();
                }
            }
            if ($type_changed && $aFields['delivery'] == MAX_ZoneEmail) {
                // Unlink all campaigns/banners linked to this zone
                $aPlacementZones = Admin_DA::getPlacementZones(array('zone_id' => $aFields['zoneid']), true, 'placement_id');
                if (!empty($aPlacementZones)) {
                    foreach ($aPlacementZones as $placementId => $aPlacementZone) {
                        Admin_DA::deletePlacementZones(array('zone_id' => $aFields['zoneid'], 'placement_id' => $placementId));
                    }
                }
                $aAdZones = Admin_DA::getAdZones(array('zone_id' => $aFields['zoneid']), false, 'ad_id');
                if (!empty($aAdZones)) {
                    foreach ($aAdZones as $adId => $aAdZone) {
                        Admin_DA::deleteAdZones(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId));
                    }
                }
            } else {
                if ($size_changed) {
                    $aZone = Admin_DA::getZone($aFields['zoneid']);
                    // Loop through all appended banners and make sure that they still fit...
                    $aAds = Admin_DA::getAdZones(array('zone_id' => $aFields['zoneid']), false, 'ad_id');
                    if (!empty($aAds)) {
                        foreach ($aAds as $adId => $aAd) {
                            $aAd = Admin_DA::getAd($adId);
                            if ($aZone['type'] == phpAds_ZoneText && $aAd['type'] != 'txt' || $aAd['width'] != $aZone['width'] && $aZone['width'] > -1 || $aAd['height'] != $aZone['height'] && $aZone['height'] > -1) {
                                Admin_DA::deleteAdZones(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId));
                            }
                        }
                    }
                    // Check if any campaigns linked to this zone have ads that now fit.
                    // If so, link them to the zone.
                    $aPlacementZones = Admin_DA::getPlacementZones(array('zone_id' => $aFields['zoneid']), true);
                    if (!empty($aPlacementZones)) {
                        foreach ($aPlacementZones as $aPlacementZone) {
                            // get ads in this campaign
                            $aAds = Admin_DA::getAds(array('placement_id' => $aPlacementZone['placement_id']), true);
                            foreach ($aAds as $adId => $aAd) {
                                Admin_DA::addAdZone(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId));
                            }
                        }
                    }
                }
            }
            // Queue confirmation message
            $translation = new OX_Translation();
            $translated_message = $translation->translate($GLOBALS['strZoneHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "zone-edit.php?affiliateid=" . $aFields['affiliateid'] . "&zoneid=" . $aFields['zoneid']), htmlspecialchars($aFields['zonename'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            OX_Admin_Redirect::redirect("zone-edit.php?affiliateid=" . $aFields['affiliateid'] . "&zoneid=" . $aFields['zoneid']);
        } else {
            $doZones = OA_Dal::factoryDO('zones');
            $doZones->affiliateid = $aFields['affiliateid'];
            $doZones->zonename = $aFields['zonename'];
            $doZones->zonetype = phpAds_ZoneCampaign;
            $doZones->description = $aFields['description'];
            $doZones->comments = $aFields['comments'];
            $doZones->width = $aFields['width'];
            $doZones->height = $aFields['height'];
            $doZones->delivery = $aFields['delivery'];
            $doZones->oac_category_id = $aFields['oac_category_id'];
            // The following fields are NOT NULL but do not get values set in the form.
            // Should these fields be changed to NULL in the schema or should they have a default value?
            $doZones->category = '';
            $doZones->ad_selection = '';
            $doZones->chain = '';
            $doZones->prepend = '';
            $doZones->append = '';
            $aFields['zoneid'] = $doZones->insert();
            // Ad  Networks
            $doPublisher = OA_Dal::factoryDO('affiliates');
            $doPublisher->get($aFields['affiliateid']);
            $anWebsiteId = $doPublisher->as_website_id;
            if ($anWebsiteId) {
                $oAdNetworks = new OA_Central_AdNetworks();
                $oAdNetworks->updateZone($doZones, $anWebsiteId);
            }
            // Queue confirmation message
            $translation = new OX_Translation();
            $translated_message = $translation->translate($GLOBALS['strZoneHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'zone-edit.php?affiliateid=' . $aFields['affiliateid'] . '&zoneid=' . $aFields['zoneid']), htmlspecialchars($aFields['zonename'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            OX_Admin_Redirect::redirect("affiliate-zones.php?affiliateid=" . $aFields['affiliateid']);
        }
    }
    return $errors;
}
开发者ID:villos,项目名称:tree_admin,代码行数:101,代码来源:zone-edit.php

示例9: unset

                    Admin_DA::deleteAdZones($aParameters);
                }
            } else {
                // Remove this key, because it is already there and does not need to be added again.
                unset($aCurrent[$id]);
            }
        }
    }
    $addResult = true;
    if (!empty($aCurrent)) {
        foreach ($aCurrent as $id => $value) {
            $aVariables = array('zone_id' => $zoneId, $key => $id);
            if ($view == 'placement') {
                $addResult = Admin_DA::addPlacementZone($aVariables);
            } else {
                $addResult = Admin_DA::addAdZone($aVariables);
            }
        }
    }
    if (!$addResult) {
        Header("Location: zone-include.php?affiliateid={$publisherId}&zoneid={$zoneId}");
        exit;
    }
    // Move on to the next page
    Header("Location: zone-probability.php?affiliateid={$publisherId}&zoneid={$zoneId}");
    exit;
}
// Display initial parameters...
$tabIndex = 1;
$aOtherPublishers = Admin_DA::getPublishers(array('agency_id' => $agencyId));
$aOtherZones = Admin_DA::getZones(array('publisher_id' => $publisherId));
开发者ID:villos,项目名称:tree_admin,代码行数:31,代码来源:zone-include.php

示例10: subscribeWebsites


//.........这里部分代码省略.........
             $publisherName = $this->oDal->getUniquePublisherName($aWebsite['url']);
             $publisher = array('name' => $publisherName, 'website' => 'http://' . $aWebsite['url'], 'mnemonic' => '', 'contact' => $aPref['admin_name'], 'email' => $aPref['admin_email'], 'oac_country_code' => $aWebsites[$websiteIdx]['country'], 'oac_language_id' => $aWebsites[$websiteIdx]['language'], 'oac_category_id' => $aWebsites[$websiteIdx]['category']);
         }
         // an_website_id equal as_website_id
         //            if ($aWebsites[$websiteIdx]['adnetworks']) {
         //                $publisher += array(
         //                    'an_website_id'   => $aWebsite['website_id'],
         //                );
         //            }
         if ($aWebsites[$websiteIdx]['advsignup']) {
             $publisher += array('as_website_id' => $aWebsite['website_id']);
         }
         $doPublishers->setFrom($publisher);
         if ($existingPublisher) {
             $publisherId = $doPublishers->update() ? $aWebsites[$websiteIdx]['id'] : '';
         } else {
             $publisherId = $doPublishers->insert();
             $aWebsites[$websiteIdx]['id'] = $publisherId;
         }
         if (!empty($publisherId)) {
             if (!$existingPublisher) {
                 $aCreated['publishers'][] = $publisherId;
             }
             // Lookup the existing zone sizes for this publisher
             $aZones = array();
             $doZones = OA_Dal::factoryDO('zones');
             $doZones->affiliateid = $publisherId;
             $doZones->find();
             while ($doZones->fetch()) {
                 $zoneSize = $doZones->width . 'x' . $doZones->height;
                 $aZones[$zoneSize][] = $doZones->zoneid;
             }
         } else {
             $ok = false;
         }
         for (reset($aWebsite['campaigns']); $ok && ($aCampaign = current($aWebsite['campaigns'])); next($aWebsite['campaigns'])) {
             // Create campaign
             if (!isset($aAdNetworks[$aCampaign['adnetwork_id']])) {
                 $ok = false;
                 break;
             }
             $advertiserId = $aAdNetworks[$aCampaign['adnetwork_id']]['clientid'];
             $advertiserName = $aAdNetworks[$aCampaign['adnetwork_id']]['clientname'];
             $campaignName = $this->oDal->getUniqueCampaignName("{$advertiserName} - {$aCampaign['name']} - {$publisherName}");
             $campaignStatus = !empty($aCampaign['status']) ? OA_ENTITY_STATUS_PENDING : OA_ENTITY_STATUS_RUNNING;
             $campaign = array('campaignname' => $campaignName, 'clientid' => $advertiserId, 'weight' => $aCampaign['weight'], 'block' => $aCampaign['block'], 'capping' => $aCampaign['capping'], 'session_capping' => $aCampaign['session_capping'], 'an_campaign_id' => $aCampaign['campaign_id'], 'status' => $campaignStatus, 'an_status' => empty($aCampaign['status']) ? OA_ENTITY_ADNETWORKS_STATUS_RUNNING : $aCampaign['status']);
             $doCampaigns = OA_Dal::factoryDO('campaigns');
             $doCampaigns->setFrom($campaign);
             $campaignId = $doCampaigns->insert();
             if (!empty($campaignId)) {
                 $aCreated['campaigns'][] = $campaignId;
             } else {
                 $ok = false;
             }
             for (reset($aCampaign['banners']); $ok && ($aBanner = current($aCampaign['banners'])); next($aCampaign['banners'])) {
                 // Create banner
                 $bannerName = $this->oDal->getUniqueBannerName("{$advertiserName} - {$aBanner['name']}");
                 $banner = array('description' => $bannerName, 'campaignid' => $campaignId, 'width' => $aBanner['width'], 'height' => $aBanner['height'], 'block' => $aBanner['block'], 'capping' => $aBanner['capping'], 'session_capping' => $aBanner['session_capping'], 'storagetype' => 'html', 'contenttype' => 'html', 'htmltemplate' => $aBanner['html'], 'adserver' => $aBanner['adserver'], 'an_banner_id' => $aBanner['banner_id']);
                 $doBanners = OA_Dal::factoryDO('banners');
                 $doBanners->setFrom($banner);
                 $bannerId = $doBanners->insert();
                 if (!empty($bannerId)) {
                     $aCreated['banners'][] = $bannerId;
                     $zoneSize = "{$aBanner['width']}x{$aBanner['height']}";
                     if (!empty($aZones[$zoneSize])) {
                         $zoneIds = $aZones[$zoneSize];
                     } else {
                         // Create zone
                         $zoneName = $this->oDal->getUniqueZoneName("{$publisherName} - {$zoneSize}");
                         $zone = array('zonename' => $zoneName, 'affiliateid' => $publisherId, 'width' => $aBanner['width'], 'height' => $aBanner['height']);
                         $doZones = OA_Dal::factoryDO('zones');
                         $doZones->setFrom($zone);
                         $zoneId = $doZones->insert();
                         $aZones[$zoneSize][] = $zoneId;
                     }
                     foreach ($aZones[$zoneSize] as $idx => $zoneId) {
                         // Link banner to zone
                         $aVariables = array('ad_id' => $bannerId, 'zone_id' => $zoneId);
                         $result = Admin_DA::addAdZone($aVariables);
                         if (PEAR::isError($result)) {
                             $ok = false;
                         }
                     }
                 } else {
                     $ok = false;
                 }
             }
         }
         // Add zones to central.
         $this->updateZones($publisherId);
     }
     if (!$ok) {
         if (!$this->oDal->rollback()) {
             $this->oDal->undoEntities($aCreated);
         }
         return new PEAR_Error('There was an error storing the data on the database');
     }
     $return = array('commit' => $this->oDal->commit(), 'isAlexaDataFailed' => $isAlexaDataFailed);
     return $return;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:101,代码来源:AdNetworks.php


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