function buildWebsiteForm($affiliate)
{
    $form = new OA_Admin_UI_Component_Form("affiliateform", "POST", $_SERVER['SCRIPT_NAME']);
    $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']);
    $form->addElement('text', 'contact', $GLOBALS['strContact']);
    $form->addElement('text', 'email', $GLOBALS['strEMail']);
    $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);
    return $form;
}
Example #2
0
function buildAgencyForm($aAgency)
{
    $form = new OA_Admin_UI_Component_Form("agencyform", "POST", $_SERVER['PHP_SELF']);
    $form->forceClientValidation(true);
    $form->addElement('hidden', 'agencyid', $aAgency['agencyid']);
    $form->addElement('header', 'header_basic', $GLOBALS['strBasicInformation']);
    $form->addElement('text', 'name', $GLOBALS['strName']);
    $form->addElement('text', 'contact', $GLOBALS['strContact']);
    $form->addElement('text', 'email', $GLOBALS['strEMail']);
    //we want submit to be the last element in its own separate section
    $form->addElement('controls', 'form-controls');
    $form->addElement('submit', 'submit', $GLOBALS['strSaveChanges']);
    //Form validation rules
    $translation = new OX_Translation();
    $nameRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strName']));
    $form->addRule('name', $nameRequiredMsg, 'required');
    $contactRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strContact']));
    $form->addRule('contact', $contactRequiredMsg, '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($aAgency);
    return $form;
}
function buildTrackerForm($tracker)
{
    $form = new OA_Admin_UI_Component_Form("trackerform", "POST", $_SERVER['SCRIPT_NAME']);
    $form->forceClientValidation(true);
    $form->addElement('hidden', 'trackerid', $tracker['trackerid']);
    $form->addElement('hidden', 'clientid', $tracker['clientid']);
    $form->addElement('hidden', 'move', $tracker['move']);
    $form->addElement('header', 'basic_info', $GLOBALS['strTrackerInformation']);
    $form->addElement('text', 'trackername', $GLOBALS['strName']);
    $form->addElement('text', 'description', $GLOBALS['strDescription']);
    $types = $GLOBALS['_MAX']['CONN_TYPES'];
    foreach ($types as $typeId => $typeName) {
        $aTypes[$typeId] = $GLOBALS[$typeName];
    }
    $form->addElement('select', 'type', $GLOBALS['strConversionType'], $aTypes);
    $statuses = $GLOBALS['_MAX']['STATUSES'];
    $startStatusesIds = array(1, 2, 4);
    foreach ($statuses as $statusId => $statusName) {
        if (in_array($statusId, $startStatusesIds)) {
            $activeStatuses[$statusId] = $GLOBALS[$statusName];
        }
    }
    $form->addElement('select', 'status', $GLOBALS['strDefaultStatus'], $activeStatuses);
    $form->addElement('advcheckbox', 'linkcampaigns', null, $GLOBALS['strLinkCampaignsByDefault'], null, array("f", "t"));
    $form->addElement('controls', 'form-controls');
    $form->addElement('submit', 'submit', $GLOBALS['strSaveChanges']);
    //set form values
    $form->setDefaults($tracker);
    //validation rules
    $translation = new OX_Translation();
    $nameRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strName']));
    $form->addRule('trackername', $nameRequiredMsg, 'required');
    return $form;
}
Example #4
0
function buildChannelForm($channel)
{
    $form = new OA_Admin_UI_Component_Form("channelform", "POST", $_SERVER['PHP_SELF']);
    $form->forceClientValidation(true);
    $form->addElement('hidden', 'agencyid', OA_Permission::getAgencyId());
    $form->addElement('hidden', 'affiliateid', $channel['affiliateid']);
    $form->addElement('hidden', 'channelid', $channel['channelid']);
    $form->addElement('header', 'header_basic', $GLOBALS['strBasicInformation']);
    $form->addElement('text', 'name', $GLOBALS['strName']);
    $form->addElement('text', 'description', $GLOBALS['strDescription']);
    $form->addElement('textarea', 'comments', $GLOBALS['strComments']);
    $form->addElement('controls', 'form-controls');
    $form->addElement('submit', 'submit', $GLOBALS['strSaveChanges']);
    //set form values
    $form->setDefaults($channel);
    //validation rules
    $translation = new OX_Translation();
    $nameRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strName']));
    $form->addRule('name', $nameRequiredMsg, 'required');
    return $form;
}
Example #5
0
 private function decoratorsToArray($elementName)
 {
     $elDecorators = $this->_form->getDecorators($elementName);
     if (empty($elDecorators)) {
         return null;
     }
     foreach ($elDecorators as $decorator) {
         $elPrepend .= $decorator->prepend();
         $elAppend = $decorator->append() . $elAppend;
     }
     $result['prepend'] = $elPrepend;
     $result['append'] = $elAppend;
     $result['list'] = $elDecorators;
     return $result;
 }
function buildZoneForm($aZone, $oComponent = null)
{
    $form = new OA_Admin_UI_Component_Form("zoneform", "POST", $_SERVER['SCRIPT_NAME']);
    $form->forceClientValidation(true);
    $form->addElement('hidden', 'zoneid', $aZone['zoneid']);
    $form->addElement('hidden', 'affiliateid', $aZone['affiliateid']);
    buildChainSettingsFormSection($form, $aZone);
    if ($oComponent && method_exists($oComponent, 'extendZoneAdvancedForm')) {
        $oComponent->extendZoneAdvancedForm($form, $aZone);
    }
    buildDeliveryCappingFormSection($form, $GLOBALS['strCappingZone'], $aZone);
    buildAppendFormSection($form, $aZone);
    buildAlgorithmFormSection($form, $aZone);
    //we want submit to be the last element in its own separate section
    $form->addElement('controls', 'form-controls');
    $form->addElement('submit', 'submit', $GLOBALS['strSaveChanges']);
    //set form  values
    $form->setDefaults($aZone);
    $form->setDefaults(array('chaintype' => $aZone['chain'] == '' ? 0 : 1));
    //appendinterstitial i appendpopup
    if ($appendid == $k) {
        return $form;
    }
}
 /**
  * Process input from user and creates admin saves path in config file
  *
  * @param OA_Admin_UI_Component_Form $oForm
  * @param OX_Admin_UI_Install_Wizard $oWizard
  */
 protected function processConfigurationAction($oForm, $oWizard, $isUpgrade)
 {
     if ($isUpgrade) {
         $aConfig['config'] = $this->getUpgrader()->getConfig();
         $aUpgradeConfig = $oForm->populateConfig();
         //not much here, just previous path
         $previousInstallationPath = $aUpgradeConfig['config']['previousInstallationPath'];
     } else {
         $aConfig = $oForm->populateConfig();
     }
     $oUpgrader = $this->getUpgrader();
     $isUpgrade = $this->getInstallStatus()->isUpgrade();
     $configStepSuccess = true;
     $syncEnabled = true;
     // 1) Import any plugins present from the previous install
     $path = isset($previousInstallationPath) ? $previousInstallationPath : '';
     $path = get_magic_quotes_gpc() ? stripslashes($path) : $path;
     if ($path && $path != MAX_PATH) {
         $importOK = OX_Admin_UI_Install_InstallUtils::importPlugins($path);
         if (!$importOK) {
             $errMessage = $GLOBALS['strPathToPreviousError'];
             $configStepSuccess = false;
         }
     }
     // 2) Save config (if previous task was fine)
     if ($configStepSuccess) {
         if ($oUpgrader->saveConfig($aConfig['config'])) {
             $configStepSuccess = true;
             if (!OX_Admin_UI_Install_InstallUtils::checkFolderPermissions($aConfig['config']['store']['webDir'])) {
                 $errMessage = $GLOBALS['strImageDirLockedDetected'];
                 $configStepSuccess = false;
             }
         } else {
             if ($isUpgrade) {
                 $errMessage = $GLOBALS['strUnableUpdateConfFile'];
             } else {
                 $errMessage = $GLOBALS['strUnableCreateConfFile'];
             }
         }
     }
     //3) config saved, go ahead and save admin when new install
     if ($configStepSuccess && !$isUpgrade) {
         OA_Permission::switchToSystemProcessUser('Installer');
         // we set the default from: in OpenX emails to the administrator's email
         if (empty($GLOBALS['_MAX']['CONF']['email']['fromAddress'])) {
             $oUpgrader->oConfiguration->setValue('email', 'fromAddress', $aConfig['admin']['email']);
             $oUpgrader->oConfiguration->writeConfig(true);
         }
         // Save admin credentials
         $adminSaved = $oUpgrader->putAdmin($aConfig['admin'], $aConfig['prefs']);
         if (!$adminSaved) {
             $errMessage = $GLOBALS['strUnableToCreateAdmin'];
             $configStepSuccess = false;
         }
         OA_Permission::switchToSystemProcessUser();
         //get back to normal user previously logged in
     }
     $configStepSuccess = $configStepSuccess && empty($errMessage);
     if ($errMessage) {
         $this->setModelProperty('aMessages', array('error' => array($errMessage)));
     }
     return $configStepSuccess;
 }
Example #8
0
 /**
  * Builds Database details form.
  * @param OX_Translation $oTranslation  instance
  */
 public function __construct($formName = '', $method = 'POST', $action = '', $attributes = null, $oTranslation = null)
 {
     parent::__construct($formName, $method, $action, '', $attributes, true);
     $this->forceClientValidation(true);
     $this->oTranslation = $oTranslation;
 }
function buildAdvertiserForm($aAdvertiser)
{
    $form = new OA_Admin_UI_Component_Form("clientform", "POST", $_SERVER['SCRIPT_NAME']);
    $form->forceClientValidation(true);
    $form->addElement('hidden', 'clientid', $aAdvertiser['clientid']);
    $form->addElement('header', 'header_basic', $GLOBALS['strBasicInformation']);
    $nameElem = $form->createElement('text', 'clientname', $GLOBALS['strName']);
    if (!OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        $nameElem->freeze();
    }
    $form->addElement($nameElem);
    $form->addElement('text', 'contact', $GLOBALS['strContact']);
    $form->addElement('text', 'email', $GLOBALS['strEMail']);
    $form->addElement('header', 'header_adv_report', $GLOBALS['strMailSubject']);
    $form->addElement('hidden', 'reportlastdate', $aAdvertiser['reportlastdate']);
    $form->addElement('hidden', 'reportprevious', $aAdvertiser['report']);
    $form->addElement('advcheckbox', 'reportdeactivate', null, $GLOBALS['strSendDeactivationWarning'], null, array("f", "t"));
    $form->addElement('advcheckbox', 'report', null, $GLOBALS['strSendAdvertisingReport'], null, array("f", "t"));
    $form->addElement('text', 'reportinterval', $GLOBALS['strNoDaysBetweenReports'], array('class' => 'x-small'));
    $form->addElement('header', 'header_misc', $GLOBALS['strMiscellaneous']);
    $form->addElement('advcheckbox', 'advertiser_limitation', null, $GLOBALS['strAdvertiserLimitation'], null, array("0", "1"));
    $form->addElement('textarea', 'comments', $GLOBALS['strComments']);
    //we want submit to be the last element in its own separate section
    $form->addElement('controls', 'form-controls');
    $form->addElement('submit', 'submit', $GLOBALS['strSaveChanges']);
    //Form validation rules
    $translation = new OX_Translation();
    if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        $nameRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strName']));
        $form->addRule('clientname', $nameRequiredMsg, 'required');
    }
    $contactRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strContact']));
    $form->addRule('contact', $contactRequiredMsg, 'required');
    $emailRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strEMail']));
    $form->addRule('email', $emailRequiredMsg, 'required');
    $form->addRule('email', $GLOBALS['strEmailField'], 'email');
    $form->addRule('reportinterval', $GLOBALS['strNumericField'], 'numeric');
    $form->addRule('reportinterval', $GLOBALS['strGreaterThanZeroField'], 'min', 1);
    //set form  values
    $form->setDefaults($aAdvertiser);
    return $form;
}
/**
 * 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();
    if (!empty($aFields['start'])) {
        $oDate = new Date(date('Y-m-d 00:00:00', strtotime($aFields['start'])));
        $oDate->toUTC();
        $activate = $oDate->getDate();
    } else {
        $oDate = new Date(date('Y-m-d 00:00:00'));
        $oDate->toUTC();
        $activate = $oDate->getDate();
    }
    if (!empty($aFields['end'])) {
        $oDate = new Date(date('Y-m-d 23:59:59', strtotime($aFields['end'])));
        $oDate->toUTC();
        $expire = $oDate->getDate();
    } else {
        $expire = null;
    }
    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 (!empty($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
                    }
                }
            }
        }
        // Set target
        $target_impression = 0;
        $target_click = 0;
        $target_conversion = 0;
        if ($aFields['priority'] > 0) {
            // Daily targets need to be set only if the campaign doesn't have both expiration and lifetime targets
            $hasExpiration = !empty($expire);
            $hasLifetimeTargets = $aFields['impressions'] != -1 || $aFields['clicks'] != -1 || $aFields['conversions'] != -1;
            if (!($hasExpiration && $hasLifetimeTargets) && isset($aFields['target_value']) && $aFields['target_value'] != '-') {
                switch ($aFields['target_type']) {
                    case 'target_impression':
                        $target_impression = $aFields['target_value'];
                        break;
                    case 'target_click':
                        $target_click = $aFields['target_value'];
                        break;
                    case 'target_conversion':
                        $target_conversion = $aFields['target_value'];
                        break;
                }
            }
            $aFields['weight'] = 0;
        } else {
            // Set weight
            if (!isset($aFields['weight']) || $aFields['weight'] == '-' || $aFields['weight'] == '') {
                $aFields['weight'] = 0;
            }
        }
        if ($aFields['anonymous'] != 't') {
            $aFields['anonymous'] = 'f';
        }
        if ($aFields['companion'] != 1) {
            $aFields['companion'] = 0;
        }
        if ($aFields['show_capped_no_cookie'] != 1) {
            $aFields['show_capped_no_cookie'] = 0;
        }
        $new_campaign = $aFields['campaignid'] == 'null';
        if (empty($aFields['revenue']) || $aFields['revenue'] <= 0) {
            // No revenue information, set to null
            $aFields['revenue'] = OX_DATAOBJECT_NULL;
        }
        if (empty($aFields['ecpm']) || $aFields['ecpm'] <= 0) {
            // No ecpm information, set to null
            $aFields['ecpm'] = OX_DATAOBJECT_NULL;
        }
        // Get the capping variables
        $block = _initCappingVariables($aFields['time'], $aFields['capping'], $aFields['session_capping']);
        $doCampaigns = OA_Dal::factoryDO('campaigns');
        $doCampaigns->campaignname = $aFields['campaignname'];
        $doCampaigns->clientid = $aFields['clientid'];
        $doCampaigns->views = $aFields['impressions'];
        $doCampaigns->clicks = $aFields['clicks'];
        $doCampaigns->conversions = $aFields['conversions'];
        $doCampaigns->priority = $aFields['priority'];
        $doCampaigns->weight = $aFields['weight'];
        $doCampaigns->target_impression = $target_impression;
        $doCampaigns->target_click = $target_click;
        $doCampaigns->target_conversion = $target_conversion;
        $doCampaigns->min_impressions = $aFields['min_impressions'];
        $doCampaigns->ecpm = $aFields['ecpm'];
        $doCampaigns->anonymous = $aFields['anonymous'];
        $doCampaigns->companion = $aFields['companion'];
        $doCampaigns->show_capped_no_cookie = $aFields['show_capped_no_cookie'];
        $doCampaigns->comments = $aFields['comments'];
        $doCampaigns->revenue = $aFields['revenue'];
        $doCampaigns->revenue_type = $aFields['revenue_type'];
        $doCampaigns->block = $block;
        $doCampaigns->capping = $aFields['capping'];
        $doCampaigns->session_capping = $aFields['session_capping'];
        // Activation and expiration
        $doCampaigns->activate_time = isset($activate) ? $activate : OX_DATAOBJECT_NULL;
        $doCampaigns->expire_time = isset($expire) ? $expire : OX_DATAOBJECT_NULL;
        if (!empty($aFields['campaignid']) && $aFields['campaignid'] != "null") {
            $doCampaigns->campaignid = $aFields['campaignid'];
            $doCampaigns->setEcpmEnabled();
            $doCampaigns->update();
        } else {
            $doCampaigns->setEcpmEnabled();
            $aFields['campaignid'] = $doCampaigns->insert();
        }
        if ($oComponent) {
            $oComponent->processCampaignForm($aFields);
        }
        // Recalculate priority only when editing a campaign
        // or moving banners into a newly created, and when:
        //
        // - campaign changes status (activated or deactivated) or
        // - the campaign is active and target/weight are changed
        //
        if (!$new_campaign) {
            $doCampaigns = OA_Dal::staticGetDO('campaigns', $aFields['campaignid']);
            $status = $doCampaigns->status;
            switch (true) {
                case (bool) $status != (bool) $aFields['status_old']:
                    // Run the Maintenance Priority Engine process
                    OA_Maintenance_Priority::scheduleRun();
                    break;
                case $status == OA_ENTITY_STATUS_RUNNING:
                    if (!empty($aFields['target_type']) && ${$aFields['target_type']} != $aFields['target_old'] || !empty($aFields['target_type']) && $aFields['target_type_old'] != $aFields['target_type'] || $aFields['weight'] != $aFields['weight_old'] || $aFields['clicks'] != $aFields['previousclicks'] || $aFields['conversions'] != $aFields['previousconversions'] || $aFields['impressions'] != $aFields['previousimpressions']) {
                        // Run the Maintenance Priority Engine process
                        OA_Maintenance_Priority::scheduleRun();
                    }
                    break;
            }
        }
        // Rebuild cache
        // include_once MAX_PATH . '/lib/max/deliverycache/cache-'.$conf['delivery']['cache'].'.inc.php';
        // phpAds_cacheDelete();
        // Delete channel forecasting cache
        include_once 'Cache/Lite.php';
        $options = array('cacheDir' => MAX_CACHE);
        $cache = new Cache_Lite($options);
        $group = 'campaign_' . $aFields['campaignid'];
        $cache->clean($group);
        $translation = new OX_Translation();
        if ($new_campaign) {
            // Queue confirmation message
            $translated_message = $translation->translate($GLOBALS['strCampaignHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid']), htmlspecialchars($aFields['campaignname']), MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            OX_Admin_Redirect::redirect("advertiser-campaigns.php?clientid=" . $aFields['clientid']);
        } else {
            $translated_message = $translation->translate($GLOBALS['strCampaignHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid']), htmlspecialchars($aFields['campaignname'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            OX_Admin_Redirect::redirect("campaign-edit.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid']);
        }
    }
    //return processing errors
    return $errors;
}
Example #11
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;
}
Example #12
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;
}
function buildBannerForm($type, $aBanner, &$oComponent = null, $formDisabled = false)
{
    $form = new OA_Admin_UI_Component_Form("bannerForm", "POST", $_SERVER['SCRIPT_NAME'], null, array("enctype" => "multipart/form-data"));
    $form->forceClientValidation(true);
    $form->addElement('hidden', 'clientid', $aBanner['clientid']);
    $form->addElement('hidden', 'campaignid', $aBanner['campaignid']);
    $form->addElement('hidden', 'bannerid', $aBanner['bannerid']);
    $form->addElement('hidden', 'type', 'txt');
    $form->addElement('hidden', 'status', $aBanner['status']);
    $translation = new OX_Translation();
    $pluginConf = $GLOBALS['conf']['oxMarkedText'];
    $bannerTextMaxLength = $pluginConf['textMaxLength'];
    $regularLinkMaxLength = $pluginConf['anchor1MaxLength'];
    $highlightedLinkMaxLength = $pluginConf['anchor2MaxLength'];
    $form->addElement('header', 'header_b_links', "Banner content");
    $form->addElement('text', 'description', "Name");
    $fieldwithdescr[] = $form->createElement('textarea', 'bannertext', '<label for="bannertext" style="display: block; float: left; width: 170px;">Banner text</label>');
    $fieldwithdescr[] = $form->createElement('static', 'descr', str_replace(array('XX', 'YY', 'ZZ'), array($bannerTextMaxLength, $regularLinkMaxLength, $highlightedLinkMaxLength), '<p>Type your ad text, mark any blocks with brackets to add link. Example: <i>My [super ads] for only [[123$]]</i>.</p> Single brackets will show regular link and double brackets means highlighted link. You can use <ul><li>- up to XX chars for whole ad text</li><li>- 1 regular link, up to YY chars </li><li>- 1 highlighted link, up to ZZ chars</li></ul>'));
    $form->addGroup($fieldwithdescr, 'bannertext', null, '<br />');
    $form->addElement('text', 'url', $GLOBALS['strURL']);
    $form->addElement('hidden', 'ext_bannertype', 'bannerTypeText:oxMarkedText:oxMarkedTextComponent');
    $weightfield[] = $form->createElement('text', 'weight', '<label for="weight" style="display: block; float: left; width: 170px;">' . $GLOBALS['strWeight'] . '</label>');
    $weightfield[] = $form->createElement('static', 'weightdescr', '<p>If you want to show this ad more frequently, adjust its weight.</p>');
    $form->addGroup($weightfield, 'weight', null, '<br />');
    $weightPositiveRule = $translation->translate($GLOBALS['strXPositiveWholeNumberField'], array($GLOBALS['strWeight']));
    $form->addRule('weight', $weightPositiveRule, 'numeric');
    $form->addRule('bannertext', "Maximum {$bannerTextMaxLength} characters", 'maxlength', $bannerTextMaxLength);
    $form->addElement('controls', 'form-controls');
    $form->addElement('submit', 'submit', 'Save changes');
    $form->setDefaults($aBanner);
    if ($formDisabled) {
        $form->freeze();
    }
    return $form;
}
Example #14
0
function buildBannerForm($type, $aBanner, &$oComponent = null, $formDisabled = false)
{
    //-- Build forms
    $form = new OA_Admin_UI_Component_Form("bannerForm", "POST", $_SERVER['SCRIPT_NAME'], null, array("enctype" => "multipart/form-data"));
    $form->forceClientValidation(true);
    $form->addElement('hidden', 'clientid', $aBanner['clientid']);
    $form->addElement('hidden', 'campaignid', $aBanner['campaignid']);
    $form->addElement('hidden', 'bannerid', $aBanner['bannerid']);
    $form->addElement('hidden', 'type', $type);
    $form->addElement('hidden', 'status', $aBanner['status']);
    if ($type == 'sql' || $type == 'web') {
        $form->addElement('custom', 'banner-iab-note', null, null);
    }
    if ($aBanner['contenttype'] == 'swf' && empty($aBanner['alt_contenttype']) && empty($aBanner['alt_imageurl'])) {
        $form->addElement('custom', 'banner-backup-note', null, null);
    }
    $form->addElement('header', 'header_basic', $GLOBALS['strBasicInformation']);
    if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN) || OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        $form->addElement('text', 'description', $GLOBALS['strName']);
    } else {
        $form->addElement('static', 'description', $GLOBALS['strName'], $aBanner['description']);
    }
    //local banners
    if ($type == 'sql' || $type == 'web') {
        if ($type == 'sql') {
            $header = $form->createElement('header', 'header_sql', $GLOBALS['strMySQLBanner'] . " -  banner creative");
        } else {
            $header = $form->createElement('header', 'header_sql', $GLOBALS['strWebBanner'] . " -  banner creative");
        }
        $header->setAttribute('icon', 'icon-banner-stored.gif');
        $form->addElement($header);
        $imageName = _getContentTypeIconImageName($aBanner['contenttype']);
        $size = _getBannerSizeText($type, $aBanner['filename']);
        addUploadGroup($form, $aBanner, array('uploadName' => 'upload', 'radioName' => 'replaceimage', 'imageName' => $imageName, 'fileName' => $aBanner['filename'], 'fileSize' => $size, 'newLabel' => $GLOBALS['strNewBannerFile'], 'updateLabel' => $GLOBALS['strUploadOrKeep'], 'handleSWF' => true));
        $altImageName = null;
        $altSize = null;
        if ($aBanner['contenttype'] == 'swf') {
            $altImageName = _getContentTypeIconImageName($aBanner['alt_contenttype']);
            $altSize = _getBannerSizeText($type, $aBanner['alt_filename']);
        }
        $aUploadParams = array('uploadName' => 'uploadalt', 'radioName' => 'replacealtimage', 'imageName' => $altImageName, 'fileSize' => $altSize, 'fileName' => $aBanner['alt_filename'], 'newLabel' => $GLOBALS['strNewBannerFileAlt'], 'updateLabel' => $GLOBALS['strUploadOrKeep'], 'handleSWF' => false);
        if ($aBanner['contenttype'] != 'swf') {
            $aUploadParams = array_merge($aUploadParams, array('decorateId' => 'swfAlternative'));
        }
        addUploadGroup($form, $aBanner, $aUploadParams);
        $form->addElement('header', 'header_b_links', "Banner link");
        if (count($aBanner['hardcoded_links']) == 0) {
            $form->addElement('text', 'url', $GLOBALS['strURL']);
            $targetElem = $form->createElement('text', 'target', $GLOBALS['strTarget']);
            $targetElem->setAttribute('maxlength', '16');
            $form->addElement($targetElem);
        } else {
            foreach ($aBanner['hardcoded_links'] as $key => $val) {
                $link['text'] = $form->createElement('text', "alink[" . $key . "]", null);
                $link['text']->setAttribute("style", "width:330px");
                $link['radio'] = $form->createElement('radio', "alink_chosen", null, null, $key);
                $form->addGroup($link, 'url_group', $GLOBALS['strURL'], "", false);
                if (isset($aBanner['hardcoded_targets'][$key])) {
                    $targetElem = $form->createElement('text', "atar[" . $key . "]", $GLOBALS['strTarget']);
                    $targetElem->setAttribute('maxlength', '16');
                    $form->addElement($targetElem);
                }
                if (count($aBanner['hardcoded_links']) > 1) {
                    $form->addElement('text', "asource[" . $key . "]", $GLOBALS['strOverwriteSource']);
                }
            }
            $form->addElement('hidden', 'url', $aBanner['url']);
        }
        $form->addElement('header', 'header_b_display', 'Banner display');
        $form->addElement('text', 'alt', $GLOBALS['strAlt']);
        $form->addElement('text', 'statustext', $GLOBALS['strStatusText']);
        $form->addElement('text', 'bannertext', $GLOBALS['strTextBelow']);
        if (!empty($aBanner['bannerid'])) {
            $sizeG['width'] = $form->createElement('text', 'width', $GLOBALS['strWidth'] . ":");
            $sizeG['width']->setAttribute('onChange', 'oa_sizeChangeUpdateMessage("warning_change_banner_size");');
            $sizeG['width']->setSize(5);
            $sizeG['height'] = $form->createElement('text', 'height', $GLOBALS['strHeight'] . ":");
            $sizeG['height']->setAttribute('onChange', 'oa_sizeChangeUpdateMessage("warning_change_banner_size");');
            $sizeG['height']->setSize(5);
            $form->addGroup($sizeG, 'size', $GLOBALS['strSize'], "&nbsp;", false);
            //validation rules
            $translation = new OX_Translation();
            $widthRequiredRule = array($translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strWidth'])), 'required');
            $widthPositiveRule = array($translation->translate($GLOBALS['strXGreaterThanZeroField'], array($GLOBALS['strWidth'])), 'min', 1);
            $heightRequiredRule = array($translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strHeight'])), 'required');
            $heightPositiveRule = array($translation->translate($GLOBALS['strXGreaterThanZeroField'], array($GLOBALS['strHeight'])), 'min', 1);
            $numericRule = array($GLOBALS['strNumericField'], 'numeric');
            $form->addGroupRule('size', array('width' => array($widthRequiredRule, $numericRule, $widthPositiveRule), 'height' => array($heightRequiredRule, $numericRule, $heightPositiveRule)));
        }
        if (!isset($aBanner['contenttype']) || $aBanner['contenttype'] == 'swf') {
            $form->addElement('checkbox', 'transparent', $GLOBALS['strSwfTransparency'], $GLOBALS['strSwfTransparency']);
        }
        //TODO $form->addRule("size", 'Please enter a number', 'numeric'); //this should make all fields in group size are numeric
    }
    //external banners
    if ($type == "url") {
        $header = $form->createElement('header', 'header_txt', $GLOBALS['strURLBanner']);
        $header->setAttribute('icon', 'icon-banner-url.gif');
        $form->addElement($header);
        $form->addElement('text', 'imageurl', $GLOBALS['strNewBannerURL']);
        if ($aBanner['contenttype'] == 'swf') {
            $altImageName = _getContentTypeIconImageName($aBanner['alt_contenttype']);
            $altSize = _getBannerSizeText($type, $aBanner['alt_filename']);
            $form->addElement('text', 'alt_imageurl', $GLOBALS['strNewBannerFileAlt']);
        }
        $form->addElement('header', 'header_b_links', "Banner link");
        $form->addElement('text', 'url', $GLOBALS['strURL']);
        $targetElem = $form->createElement('text', 'target', $GLOBALS['strTarget']);
        $targetElem->setAttribute('maxlength', '16');
        $form->addElement($targetElem);
        $form->addElement('header', 'header_b_display', 'Banner display');
        $form->addElement('text', 'alt', $GLOBALS['strAlt']);
        $form->addElement('text', 'statustext', $GLOBALS['strStatusText']);
        $form->addElement('text', 'bannertext', $GLOBALS['strTextBelow']);
        $sizeG['width'] = $form->createElement('text', 'width', $GLOBALS['strWidth'] . ":");
        $sizeG['width']->setAttribute('onChange', 'oa_sizeChangeUpdateMessage("warning_change_banner_size");');
        $sizeG['width']->setSize(5);
        $sizeG['height'] = $form->createElement('text', 'height', $GLOBALS['strHeight'] . ":");
        $sizeG['height']->setAttribute('onChange', 'oa_sizeChangeUpdateMessage("warning_change_banner_size");');
        $sizeG['height']->setSize(5);
        $form->addGroup($sizeG, 'size', $GLOBALS['strSize'], "&nbsp;", false);
        if (!isset($aBanner['contenttype']) || $aBanner['contenttype'] == 'swf') {
            $form->addElement('checkbox', 'transparent', $GLOBALS['strSwfTransparency'], $GLOBALS['strSwfTransparency']);
        }
        //validation rules
        $translation = new OX_Translation();
        $widthRequiredRule = array($translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strWidth'])), 'required');
        $widthPositiveRule = array($translation->translate($GLOBALS['strXGreaterThanZeroField'], array($GLOBALS['strWidth'])), 'min', 1);
        $heightRequiredRule = array($translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strHeight'])), 'required');
        $heightPositiveRule = array($translation->translate($GLOBALS['strXGreaterThanZeroField'], array($GLOBALS['strHeight'])), 'min', 1);
        $numericRule = array($GLOBALS['strNumericField'], 'numeric');
        $form->addGroupRule('size', array('width' => array($widthRequiredRule, $numericRule, $widthPositiveRule), 'height' => array($heightRequiredRule, $numericRule, $heightPositiveRule)));
    }
    //html & text banners
    if ($oComponent) {
        $oComponent->buildForm($form, $aBanner);
    }
    $translation = new OX_Translation();
    //common for all banners
    if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN) || OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        $form->addElement('header', 'header_additional', "Additional data");
        $form->addElement('text', 'keyword', $GLOBALS['strKeyword']);
        $weightElem = $form->createElement('text', 'weight', $GLOBALS['strWeight']);
        $weightElem->setSize(6);
        $form->addElement($weightElem);
        $form->addElement('textarea', 'comments', $GLOBALS['strComments']);
        $weightPositiveRule = $translation->translate($GLOBALS['strXPositiveWholeNumberField'], array($GLOBALS['strWeight']));
        $form->addRule('weight', $weightPositiveRule, 'numeric');
    }
    //we want submit to be the last element in its own separate section
    $form->addElement('controls', 'form-controls');
    $form->addElement('submit', 'submit', 'Save changes');
    //validation rules
    if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN) || OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        $urlRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strName']));
        $form->addRule('description', $urlRequiredMsg, 'required');
    }
    //set banner values
    $form->setDefaults($aBanner);
    foreach ($aBanner['hardcoded_links'] as $key => $val) {
        $swfLinks["alink[" . $key . "]"] = phpAds_htmlQuotes($val);
        if ($val == $aBanner['url']) {
            $swfLinks['alink_chosen'] = $key;
        }
        if (isset($aBanner['hardcoded_targets'][$key])) {
            $swfLinks["atar[" . $key . "]"] = phpAds_htmlQuotes($aBanner['hardcoded_targets'][$key]);
        }
        if (count($aBanner['hardcoded_links']) > 1) {
            $swfLinks["asource[" . $key . "]"] = phpAds_htmlQuotes($aBanner['hardcoded_sources'][$key]);
        }
    }
    $form->setDefaults($swfLinks);
    if ($formDisabled) {
        $form->freeze();
    }
    return $form;
}
function &buildForm()
{
    global $oTrans;
    $form = new OA_Admin_UI_Component_Form("oxToolBoxForm", "POST", $_SERVER['SCRIPT_NAME'], null, array("enctype" => "multipart/form-data"));
    $form->forceClientValidation(true);
    $form->addElement('header', 'header', $oTrans->translate("New Plugin"));
    $form->addElement('text', 'name', $oTrans->translate("Plugin Name"), array('class' => 'medium'));
    $form->addElement('text', 'email', $oTrans->translate("Author Email"));
    $form->addElement('text', 'author', $oTrans->translate("Author Name"));
    $form->addElement('text', 'url', $oTrans->translate("Author URL"));
    $form->addElement('text', 'licence', $oTrans->translate("Licence Info"));
    $form->addElement('text', 'description', $oTrans->translate("Description"));
    $version['major'] = $form->createElement('text', 'version[major]', $oTrans->translate("Major"));
    $version['minor'] = $form->createElement('text', 'version[minor]', $oTrans->translate("Minor"));
    $version['build'] = $form->createElement('text', 'version[build]', $oTrans->translate("Build"));
    // for new plugins status is -dev only
    //$aStatus = array('-dev','-beta','-beta-rc');
    $aStatus = array('-dev' => '-dev');
    $version['status'] = $form->createElement('select', 'version[status]', $oTrans->translate("Status"), $aStatus);
    //$version['rc']     = $form->createElement('text', 'version[rc]', 'rc#');
    $form->addGroup($version, 'version', $oTrans->translate("Version"), "", false);
    //$form->addElement('text', 'versionMajor', 'Version',  array('class'=>'small'));
    $aGroups = getExtensionList();
    foreach ($aGroups as $extension) {
        $group['name'] = $form->createElement('text', 'group[' . $extension . '][groupname]', $oTrans->translate("Group Name"), array('class' => 'medium'));
        $group['schema'] = $form->createElement('checkbox', 'group[' . $extension . '][schema]', $oTrans->translate("Has Schema"));
        $form->addGroup($group, 'group_' . $extension, $oTrans->translate("Extends %s", array($extension)), "", false);
    }
    $form->addElement('controls', 'form-controls');
    $form->addElement('submit', 'submit', $oTrans->translate("Submit"));
    return $form;
}