function displayPage($affiliateid, $form, $oPublisherDll = null)
{
    //header and breadcrumbs
    $oHeaderModel = MAX_displayWebsiteBreadcrumbs($affiliateid);
    if ($affiliateid != "") {
        OA_Admin_Menu::setPublisherPageContext($affiliateid, 'affiliate-edit.php');
        addWebsitePageTools($affiliateid);
        phpAds_PageHeader(null, $oHeaderModel);
    } else {
        phpAds_PageHeader("affiliate-edit_new", $oHeaderModel);
    }
    //get template and display form
    $oTpl = new OA_Admin_Template('affiliate-edit.html');
    $oTpl->assign('affiliateid', $affiliateid);
    $oTpl->assign('form', $form->serialize());
    if (isset($oPublisherDll)) {
        $oTpl->assign('error', $oPublisherDll->_errorMessage);
        $oTpl->assign('notice', $oPublisherDll->_noticeMessage);
    }
    $oTpl->assign('showAdDirect', defined('OA_AD_DIRECT_ENABLED') && OA_AD_DIRECT_ENABLED === true ? true : false);
    $oTpl->assign('keyAddNew', $keyAddNew);
    $oTpl->display();
    //footer
    phpAds_PageFooter();
}
// Security check
OA_Permission::enforceAccount(OA_ACCOUNT_MANAGER, OA_ACCOUNT_TRAFFICKER);
OA_Permission::enforceAccountPermission(OA_ACCOUNT_TRAFFICKER, OA_PERM_SUPER_ACCOUNT);
OA_Permission::enforceAccessToObject('affiliates', $affiliateid);
/*-------------------------------------------------------*/
/* Store preferences									 */
/*-------------------------------------------------------*/
$session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['affiliateid'] = $affiliateid;
phpAds_SessionDataStore();
/*-------------------------------------------------------*/
/* HTML framework                                        */
/*-------------------------------------------------------*/
$oHeaderModel = MAX_displayWebsiteBreadcrumbs($affiliateid);
if (!empty($affiliateid)) {
    if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        OA_Admin_Menu::setPublisherPageContext($affiliateid, 'affiliate-access.php');
        addPageTools($affiliateid);
        addWebsitePageTools($affiliateid);
        phpAds_PageHeader("4.2.7", $oHeaderModel);
        phpAds_ShowSections(array("4.2.2", "4.2.3", "4.2.4", "4.2.5", "4.2.7"));
    } else {
        addPageTools($affiliateid);
        phpAds_PageHeader('2.3', $oHeaderModel);
        $sections = array('2.1');
        if (OA_Permission::hasPermission(OA_PERM_ZONE_INVOCATION)) {
            $sections[] = '2.2';
        }
        $sections[] = '2.3';
        phpAds_ShowSections($sections);
    }
} else {