function testCheckBannerZoneAdAssoc()
 {
     // sql banner with an email zone
     $aZone = array('type' => 4);
     $bannerType = 'sql';
     $contentType = 'gif';
     $ret = Admin_DA::_checkBannerZoneAdAssoc($aZone, $bannerType, $contentType);
     $this->assertFalse(PEAR::isError($ret));
     // web banner (png) with an email zone
     $aZone = array('type' => 4);
     $bannerType = 'web';
     $contentType = 'png';
     $ret = Admin_DA::_checkBannerZoneAdAssoc($aZone, $bannerType, $contentType);
     $this->assertFalse(PEAR::isError($ret));
     // url banner (jpg) with an email zone
     $aZone = array('type' => 4);
     $bannerType = 'url';
     $contentType = 'jpeg';
     $ret = Admin_DA::_checkBannerZoneAdAssoc($aZone, $bannerType, $contentType);
     $this->assertFalse(PEAR::isError($ret));
     // html banner (swf) with an email zone
     $aZone = array('type' => 4);
     $bannerType = 'html';
     PEAR::pushErrorHandling(null);
     $ret = Admin_DA::_checkBannerZoneAdAssoc($aZone, $bannerType);
     PEAR::popErrorHandling();
     $this->assertTrue(PEAR::isError($ret));
     // url banner (swf) with an email zone
     $aZone = array('type' => 4);
     $bannerType = 'url';
     $contentType = 'swf';
     PEAR::pushErrorHandling(null);
     $ret = Admin_DA::_checkBannerZoneAdAssoc($aZone, $bannerType, $contentType);
     PEAR::popErrorHandling();
     $this->assertTrue(PEAR::isError($ret));
 }
 function _isValidAdZoneAssoc($aVariables)
 {
     $aAdZone = Admin_DA::getAdZones($aVariables);
     if (empty($aAdZone)) {
         if (!$aVariables['zone_id']) {
             // Direct selection zone, always allow
             return true;
         }
         $azParams = Admin_DA::getLinkedAdParams($aVariables['zone_id']);
         $azParams['ad_id'] = $aVariables['ad_id'];
         $azParams['market_ads_include'] = true;
         $azAds = Admin_DA::getAds($azParams);
         if (!empty($azAds)) {
             // Ad seems OK to link, check if this is an email zone, and enforce only a single active linked ad at a time
             $aZone = Admin_DA::getZone($aVariables['zone_id']);
             if ($aZone['type'] == MAX_ZoneEmail) {
                 $aAd = Admin_DA::getAd($azParams['ad_id']);
                 $okToLink = Admin_DA::_checkEmailZoneAdAssoc($aZone['zone_id'], $aAd['placement_id']);
                 if (PEAR::isError($okToLink)) {
                     return $okToLink;
                 }
                 PEAR::pushErrorHandling(null);
                 $okToLink = Admin_DA::_checkBannerZoneAdAssoc($aZone, $aAd['type'], $aAd['contenttype']);
                 PEAR::popErrorHandling();
                 if (PEAR::isError($okToLink)) {
                     return $okToLink;
                 }
             }
             if ($aZone['type'] != phpAds_ZoneText && $azAds[$azParams['ad_id']]['type'] == 'txt') {
                 return PEAR::raiseError('Text banner can be linked only to text zone', MAX_ERROR_INVALIDBANNERSIZE);
             }
             return true;
         } else {
             return PEAR::raiseError('This banner is the wrong size for this zone', MAX_ERROR_INVALIDBANNERSIZE);
         }
     } else {
         // If already linked...
         return PEAR::raiseError('This banner is already linked to this zone', MAX_ERROR_ALREADYLINKED);
     }
 }