Beispiel #1
0
 /**
  * Method gets sub categories IDs and add ID of parent category
  *
  * @return array Array of categories IDs
  */
 function _getParentAndSubCategoriesIds($categoryId)
 {
     if (is_null($this->_oOaCentralAdNetworks)) {
         $this->_oOaCentralAdNetworks = new OA_Central_AdNetworks();
     }
     $aCategories = $this->_oOaCentralAdNetworks->getSubCategoriesIds($categoryId);
     if ($aCategories == false) {
         $aCategories = array();
     }
     $aCategories[] = $categoryId;
     return $aCategories;
 }
Beispiel #2
0
/**
 * Processes submit values of zone form
 *
 * @param OA_Admin_UI_Component_Form $form form to process
 * @return An array of Pear::Error objects if any
 */
function processForm($form)
{
    $aFields = $form->exportValues();
    switch ($aFields['delivery']) {
        case phpAds_ZoneText:
            $aFields['width'] = $aFields['height'] = 0;
            break;
        case OX_ZoneVideoOverlay:
            $aFields['width'] = $aFields['height'] = -2;
            break;
        case OX_ZoneVideoInstream:
            $aFields['width'] = $aFields['height'] = -3;
            break;
        default:
            if ($aFields['sizetype'] == 'custom') {
                if (isset($aFields['width']) && $aFields['width'] == '*') {
                    $aFields['width'] = -1;
                }
                if (isset($aFields['height']) && $aFields['height'] == '*') {
                    $aFields['height'] = -1;
                }
            } else {
                list($aFields['width'], $aFields['height']) = explode('x', $aFields['size']);
            }
            break;
    }
    if (!is_numeric($aFields['oac_category_id']) || $aFields['oac_category_id'] <= 0) {
        $aFields['oac_category_id'] = 'NULL';
    }
    if (empty($errors)) {
        // Edit
        if (!empty($aFields['zoneid'])) {
            // before we commit any changes to db, store whether the size has changed
            $aZone = Admin_DA::getZone($aFields['zoneid']);
            $size_changed = $aFields['width'] != $aZone['width'] || $aFields['height'] != $aZone['height'] ? true : false;
            $type_changed = $aFields['delivery'] != $aZone['delivery'] ? true : false;
            $doZones = OA_Dal::factoryDO('zones');
            $doZones->zonename = $aFields['zonename'];
            $doZones->description = $aFields['description'];
            $doZones->width = $aFields['width'];
            $doZones->height = $aFields['height'];
            $doZones->comments = $aFields['comments'];
            $doZones->delivery = $aFields['delivery'];
            if ($aFields['delivery'] != phpAds_ZoneText && $aFields['delivery'] != phpAds_ZoneBanner) {
                $doZones->append = '';
            }
            if ($aFields['delivery'] != phpAds_ZoneText) {
                $doZones->prepend = '';
            }
            $doZones->oac_category_id = $aFields['oac_category_id'];
            $doZones->zoneid = $aFields['zoneid'];
            $doZones->update();
            // Ad  Networks
            $doPublisher = OA_Dal::factoryDO('affiliates');
            $doPublisher->get($aFields['affiliateid']);
            $anWebsiteId = $doPublisher->as_website_id;
            if ($anWebsiteId) {
                $oAdNetworks = new OA_Central_AdNetworks();
                $doZones->get($aFields['zoneid']);
                $oAdNetworks->updateZone($doZones, $anWebsiteId);
            }
            // 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;
}
Beispiel #3
0
|                                                                           |
| You should have received a copy of the GNU General Public License         |
| along with this program; if not, write to the Free Software               |
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA |
+---------------------------------------------------------------------------+
$Id: campaign-zone.php 37157 2009-05-28 12:31:10Z andrew.hill $
*/
// Require the initialisation file
require_once '../../init.php';
// Required files
require_once MAX_PATH . '/www/admin/config.php';
require_once MAX_PATH . '/lib/max/other/html.php';
require_once MAX_PATH . '/lib/OA/Dal.php';
require_once MAX_PATH . '/lib/OA/Central/AdNetworks.php';
// Initialise Ad  Networks
$oAdNetworks = new OA_Central_AdNetworks();
/*-------------------------------------------------------*/
/* HTML framework                                        */
/*-------------------------------------------------------*/
$advertiserId = MAX_getValue('clientid');
$campaignId = MAX_getValue('campaignid');
// Security check
OA_Permission::enforceAccount(OA_ACCOUNT_MANAGER);
OA_Permission::enforceAccessToObject('clients', $clientid);
OA_Permission::enforceAccessToObject('campaigns', $campaignid);
/*-------------------------------------------------------*/
/* Store preferences									 */
/*-------------------------------------------------------*/
$session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['clientid'] = $clientid;
$session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['campaignid'][$clientid] = $campaignid;
phpAds_SessionDataStore();
Beispiel #4
0
function buildWebsiteForm($affiliate)
{
    // Initialise Ad  Networks
    $oAdNetworks = new OA_Central_AdNetworks();
    $form = new OA_Admin_UI_Component_Form("affiliateform", "POST", $_SERVER['PHP_SELF']);
    $form->forceClientValidation(true);
    $form->addElement('hidden', 'affiliateid', $affiliate['affiliateid']);
    $form->addElement('header', 'basic_info', $GLOBALS['strBasicInformation']);
    $form->addElement('text', 'website', $GLOBALS['strWebsiteURL']);
    $form->addElement('text', 'name', $GLOBALS['strName']);
    if (defined('OA_AD_DIRECT_ENABLED') && OA_AD_DIRECT_ENABLED === true) {
        $form->addElement('checkbox', 'advsignup', $GLOBALS['strAdvertiserSignup'], $GLOBALS['strAdvertiserSignupDesc'], array('disabled' => !$GLOBALS['_MAX']['CONF']['sync']['checkForUpdates']));
        $form->addElement('custom', 'advertiser-signup-dialog', null, array('formId' => $form->getId()), false);
    }
    $form->addElement('text', 'contact', $GLOBALS['strContact']);
    $form->addElement('text', 'email', $GLOBALS['strEMail']);
    $form->addElement('select', 'category', $GLOBALS['strCategory'], $oAdNetworks->getCategoriesSelect(), array('style' => 'width: 16em;'));
    $catLangGroup['country'] = $form->createElement('select', 'country', null, $oAdNetworks->getCountriesSelect());
    $catLangGroup['country']->setAttribute('style', 'width: 16em;');
    $catLangGroup['lang'] = $form->createElement('select', 'language', null, $oAdNetworks->getLanguagesSelect());
    $catLangGroup['lang']->setAttribute('style', 'width: 16em;');
    $form->addGroup($catLangGroup, 'catlang_group', $GLOBALS['strCountry'] . ' / ' . $GLOBALS['strLanguage'], array(" "), false);
    $form->addElement('controls', 'form-controls');
    $form->addElement('submit', 'save', 'Save changes');
    //Form validation rules
    $translation = new OX_Translation();
    $urlRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strWebsiteURL']));
    $form->addRule('website', $urlRequiredMsg, 'required');
    $form->addRule('website', $GLOBALS['strInvalidWebsiteURL'], 'regex', '#^http(s?)\\://.+$#');
    $contactRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strContact']));
    $form->addRule('contact', $contactRequiredMsg, 'required');
    $nameRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strName']));
    $form->addRule('name', $nameRequiredMsg, 'required');
    $emailRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strEMail']));
    $form->addRule('email', $emailRequiredMsg, 'required');
    $form->addRule('email', $GLOBALS['strEmailField'], 'email');
    //set form  values
    $form->setDefaults($affiliate);
    $form->setDefaults(array("category" => $affiliate['oac_category_id'], "country" => $affiliate['oac_country_code'], "language" => $affiliate['oac_language_id'], 'advsignup' => !empty($affiliate['as_website_id'])));
    return $form;
}
Beispiel #5
0
 /**
  * A private method to run OpenX Central related tasks.
  *
  * @access private
  */
 function _runOpenadsCentral()
 {
     OA::debug('  Starting OpenX Central process.', PEAR_LOG_DEBUG);
     if ($this->aConf['sync']['checkForUpdates'] && OA_Dal_ApplicationVariables::get('sso_admin')) {
         require_once MAX_PATH . '/lib/OA/Central/AdNetworks.php';
         $oAdNetworks = new OA_Central_AdNetworks();
         $result = $oAdNetworks->getRevenue();
         if (PEAR::isError($result)) {
             OA::debug("  - OpenX Central error (" . $result->getCode() . "): " . $result->getMessage(), PEAR_LOG_INFO);
         }
     }
     OA::debug('  Finished OpenX Central process.', PEAR_LOG_DEBUG);
 }
Beispiel #6
0
 /**
  * This method modifies an existing publisher. Undefined fields do not change
  * and defined fields with a NULL value also remain unchanged.
  *
  * @access public
  *
  * @param OA_Dll_PublisherInfo &$oPublisher <br />
  *          <b>For adding</b><br />
  *          <b>Optional properties:</b> agencyId, publisherName, contactName, emailAddress<br />
  *
  *          <b>For modify</b><br />
  *          <b>Required properties:</b> publisherId<br />
  *          <b>Optional properties:</b> agencyId, publisherName, contactName, emailAddress<br />
  *
  * @return success boolean True if the operation was successful
  *
  */
 function modify(&$oPublisher)
 {
     if (!$this->checkPermissions($this->aAllowTraffickerAndAbovePerm, 'affiliates', $oPublisher->publisherId)) {
         return false;
     }
     if (empty($oPublisher->publisherId)) {
         unset($oPublisher->publisherId);
         $oPublisher->setDefaultForAdd();
     } else {
         $oPublisher->publisherId = (int) $oPublisher->publisherId;
         // Capture the existing data
         /**
          * @todo This needs to be updated to use the getPublisher method, however right now
          *       I need access to properties not referenced by the DLL
          */
         $doPrevPublisher = OA_Dal::factoryDO('affiliates');
         $doPrevPublisher->get($oPublisher->publisherId);
         $publisherPrevData = $doPrevPublisher->toArray();
     }
     $adnetworks_website_id = $publisherPrevData['as_website_id'];
     $publisherData = (array) $oPublisher;
     // Trim input variables
     foreach ($publisherData as $key => $value) {
         $publisherData[$key] = trim($publisherData[$key]);
     }
     // Clear the website if only the pre-filled "http://" is passed
     if (isset($publisherData['website']) && $publisherData['website'] == 'http://') {
         $publisherData['website'] = '';
     }
     // Remap fields where the PublisherInfo object does not map directly to the DataObject.
     $publisherData['name'] = $oPublisher->publisherName;
     $publisherData['contact'] = $oPublisher->contactName;
     $publisherData['email'] = $oPublisher->emailAddress;
     $publisherData['oac_category_id'] = $oPublisher->oacCategoryId;
     $publisherData['oac_language_id'] = $oPublisher->oacLanguageId;
     $publisherData['oac_country_code'] = $oPublisher->oacCountryCode;
     //        $publisherData['an_website_id'] = (!$oPublisher->adNetworks) ? '' : null;
     $publisherData['as_website_id'] = !$oPublisher->advSignup ? '' : null;
     if ($this->_validate($oPublisher)) {
         $doPublisher = OA_Dal::factoryDO('affiliates');
         if (!isset($publisherData['publisherId'])) {
             // Only set agency ID for insert
             $publisherData['agencyid'] = $oPublisher->agencyId;
             $doPublisher->setFrom($publisherData);
             $oPublisher->publisherId = $doPublisher->insert();
             if ($oPublisher->publisherId) {
                 // Set the account ID
                 $doPublisher = OA_Dal::staticGetDO('affiliates', $oPublisher->publisherId);
                 $oPublisher->accountId = (int) $doPublisher->account_id;
             }
         } else {
             $doPublisher->get($publisherData['publisherId']);
             $doPublisher->setFrom($publisherData);
             $doPublisher->update();
         }
         $oAdNetworks = new OA_Central_AdNetworks();
         // Initiate a call to OpenX Central if adnetworks are enabled or if OAC values are changed.
         if ($oPublisher->advSignup) {
             // If adNetworks was not previously selected...
             if (empty($publisherPrevData['as_website_id'])) {
                 $aRpcPublisher = array(array('id' => $oPublisher->publisherId, 'url' => $oPublisher->website, 'country' => $oPublisher->oacCountryCode, 'language' => $oPublisher->oacLanguageId, 'category' => $oPublisher->oacCategoryId, 'advsignup' => $oPublisher->advSignup));
                 $result = $oAdNetworks->subscribeWebsites($aRpcPublisher);
                 if (PEAR::isError($result)) {
                     $this->_errorMessage = $result->getMessage();
                     return false;
                 }
                 $this->_noticeMessage = is_array($result) && $result['isAlexaDataFailed'] ? 'Retrieving Alexa data for one or more websites failed and is scheduled for tomorrow' : false;
                 //                    echo('<pre>');
                 //                    var_dump($result);
             } else {
                 // This publisher was already signed up for adnetworks, only action if OAC related values have changed
                 if ($publisherPrevData['oac_category_id'] != $publisherData['oac_category_id'] || $publisherPrevData['oac_language_id'] != $publisherData['oac_language_id'] || $publisherPrevData['oac_country_code'] != $publisherData['oac_country_code'] || $publisherPrevData['as_website_id'] != $publisherData['as_website_id']) {
                     // OAC related fields have changed, so unsubscribe and resubscribe this publisher
                     $aError = $this->unsubscribePublisher($oAdNetworks, $oPublisher, $adnetworks_website_id);
                     $aRpcPublisher = array(array('id' => $oPublisher->publisherId, 'url' => $oPublisher->website, 'country' => $oPublisher->oacCountryCode, 'language' => $oPublisher->oacLanguageId, 'category' => $oPublisher->oacCategoryId, 'advsignup' => $oPublisher->advSignup));
                     //                        $result = $oAdNetworks->subscribeWebsites($aPublisher);
                     $result = $oAdNetworks->subscribeWebsites($aRpcPublisher);
                 }
             }
         } else {
             if ($adnetworks_website_id) {
                 // User unsubscribed from adnetworks
                 $aError = $this->unsubscribePublisher($oAdNetworks, $oPublisher, $adnetworks_website_id);
             }
         }
         return true;
     }
     return false;
 }
Beispiel #7
0
}
/*-------------------------------------------------------*/
/* Main code                                             */
/*-------------------------------------------------------*/
if (!empty($zoneid)) {
    $ids = explode(',', $zoneid);
    while (list(, $zoneid) = each($ids)) {
        // Security check
        OA_Permission::enforceAccessToObject('zones', $zoneid);
        $doZones = OA_Dal::factoryDO('zones');
        $doZones->zoneid = $zoneid;
        if ($doZones->get($zoneid)) {
            $aZone = $doZones->toArray();
        }
        // Ad  Networks
        $oAdNetworks = new OA_Central_AdNetworks();
        $oAdNetworks->deleteZone($doZones->as_zone_id);
        $doZones->delete();
    }
    // Queue confirmation message
    $translation = new OX_Translation();
    if (count($ids) == 1) {
        $translated_message = $translation->translate($GLOBALS['strZoneHasBeenDeleted'], array(htmlspecialchars($aZone['zonename'])));
    } else {
        $translated_message = $translation->translate($GLOBALS['strZonesHaveBeenDeleted']);
    }
    OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
}
if (!isset($returnurl) && $returnurl == '') {
    $returnurl = 'affiliate-zones.php';
}
Beispiel #8
0
| along with this program; if not, write to the Free Software               |
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA |
+---------------------------------------------------------------------------+
$Id: affiliate-delete.php 37157 2009-05-28 12:31:10Z andrew.hill $
*/
// Require the initialisation file
require_once '../../init.php';
// Required files
require_once MAX_PATH . '/lib/OA/Dal.php';
require_once MAX_PATH . '/www/admin/config.php';
require_once MAX_PATH . '/www/admin/lib-zones.inc.php';
require_once MAX_PATH . '/lib/OA/Central/AdNetworks.php';
// Register input variables
phpAds_registerGlobal('returnurl');
// Initialise Ad  Networks
$oAdNetworks = new OA_Central_AdNetworks();
// Security check
OA_Permission::enforceAccount(OA_ACCOUNT_MANAGER);
/*-------------------------------------------------------*/
/* Main code                                             */
/*-------------------------------------------------------*/
if (!empty($affiliateid)) {
    $ids = explode(',', $affiliateid);
    while (list(, $affiliateid) = each($ids)) {
        // Security check
        OA_Permission::enforceAccessToObject('affiliates', $affiliateid);
        $doAffiliates = OA_Dal::factoryDO('affiliates');
        $doAffiliates->affiliateid = $affiliateid;
        if ($doAffiliates->get($affiliateid)) {
            $aAffiliate = $doAffiliates->toArray();
        }