Example #1
0
 /**
  * Class constructor
  *
  * @param string $accountId If null, the current account ID is used
  * @param string $accountType If null, the current account type is used
  * @return OA_Central_M2M
  */
 function OA_Central_M2M($accountId = null)
 {
     parent::OA_Central_Common();
     $currentId = OA_Permission::getAccountId();
     if (is_null($accountId)) {
         $this->accountId = $currentId;
     } else {
         $this->accountId = $accountId;
     }
     if ($this->accountId == $currentId) {
         $this->accountType = OA_Permission::getAccountType();
     } else {
         $doAccounts = OA_Dal::factoryDO('accounts');
         $doAccounts->account_id = $this->accountId;
         $doAccounts->find();
         if ($doAccounts->fetch()) {
             $this->accountType = $doAccounts->account_type;
         } else {
             Max::raiseError('Unexisting account ID', null, PEAR_ERROR_DIE);
         }
     }
     if ($this->accountType == OA_ACCOUNT_ADMIN) {
         $this->accountId = 0;
     }
 }
function processBanners($commit = false)
{
    $doBanners = OA_Dal::factoryDO('banners');
    if (OA_INSTALLATION_STATUS === OA_INSTALLATION_STATUS_INSTALLED && OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        $doBanners->addReferenceFilter('agency', $agencyId = OA_Permission::getEntityId());
    }
    $doBanners->find();
    $different = 0;
    $same = 0;
    $errors = array();
    while ($doBanners->fetch()) {
        // Rebuild filename
        if ($doBanners->storagetype == 'sql' || $doBanners->storagetype == 'web') {
            $doBanners->imageurl = '';
        }
        $GLOBALS['_MAX']['bannerrebuild']['errors'] = false;
        if ($commit) {
            $doBannersClone = clone $doBanners;
            $doBannersClone->update();
            $newCache = $doBannersClone->htmlcache;
        } else {
            $newCache = phpAds_getBannerCache($doBanners->toArray());
        }
        if (empty($GLOBALS['_MAX']['bannerrebuild']['errors'])) {
            if ($doBanners->htmlcache != $newCache && $doBanners->storagetype == 'html') {
                $different++;
            } else {
                $same++;
            }
        } else {
            $errors[] = $doBanners->toArray();
        }
    }
    return array('errors' => $errors, 'different' => $different, 'same' => $same);
}
 function getWebsitesAndZonesByAgencyId($agencyId = null)
 {
     if (is_null($agencyId)) {
         $agencyId = OA_Permission::getAgencyId();
     }
     $prefix = $this->getTablePrefix();
     $oDbh = OA_DB::singleton();
     $tableW = $oDbh->quoteIdentifier($prefix . $this->table, true);
     $tableZ = $oDbh->quoteIdentifier($prefix . 'zones', true);
     // Select out websites only first (to ensure websites with no zones are included in the list)
     $aWebsitesAndZones = array();
     $query = "\n            SELECT\n                w.affiliateid AS website_id,\n                w.website     AS website_url,\n                w.name        AS website_name\n            FROM\n                {$tableW} AS w\n            WHERE\n                w.agencyid = " . DBC::makeLiteral($agencyId) . "\n            ORDER BY w.name";
     $rsAffiliates = DBC::NewRecordSet($query);
     $rsAffiliates->find();
     while ($rsAffiliates->fetch()) {
         $aWebsiteZone = $rsAffiliates->toArray();
         $aWebsitesAndZones[$aWebsiteZone['website_id']]['name'] = $aWebsiteZone['website_name'];
         $aWebsitesAndZones[$aWebsiteZone['website_id']]['url'] = $aWebsiteZone['website_url'];
         $aWebsitesAndZones[$aWebsiteZone['website_id']]['zones'] = array();
     }
     $query = "\n        SELECT\n            w.affiliateid AS website_id,\n            w.website     AS website_url,\n            w.name        AS website_name,\n            z.zoneid      AS zone_id,\n            z.zonename    AS zone_name,\n            z.width       AS zone_width,\n            z.height      AS zone_height\n        FROM\n            {$tableW} AS w,\n            {$tableZ} AS z\n        WHERE\n            z.affiliateid = w.affiliateid\n          AND w.agencyid = " . DBC::makeLiteral($agencyId) . "\n        ORDER BY w.name";
     $rsAffiliatesAndZones = DBC::NewRecordSet($query);
     $rsAffiliatesAndZones->find();
     while ($rsAffiliatesAndZones->fetch()) {
         $aWebsiteZone = $rsAffiliatesAndZones->toArray();
         $aWebsitesAndZones[$aWebsiteZone['website_id']]['name'] = $aWebsiteZone['website_name'];
         $aWebsitesAndZones[$aWebsiteZone['website_id']]['url'] = $aWebsiteZone['website_url'];
         $aWebsitesAndZones[$aWebsiteZone['website_id']]['zones'][$aWebsiteZone['zone_id']] = array('name' => $aWebsiteZone['zone_name'], 'width' => $aWebsiteZone['zone_width'], 'height' => $aWebsiteZone['zone_height']);
     }
     return $aWebsitesAndZones;
 }
Example #4
0
 /**
  * The method to generate a plugin-style report XLS from an already
  * prepared statistics page OA_Admin_Statistics_Common object.
  */
 function export()
 {
     // Prepare the report name
     // Get system navigation
     $oMenu = OA_Admin_Menu::singleton();
     // Get section by pageId
     $oCurrentSection = $oMenu->get($this->oStatsController->pageId);
     if ($oCurrentSection == null) {
         phpAds_Die($GLOBALS['strErrorOccurred'], 'Menu system error: <strong>' . OA_Permission::getAccountType(true) . '::' . htmlspecialchars($ID) . '</strong> not found for the current user');
     }
     // Get name
     $reportName = $oCurrentSection->getName();
     $this->_name = $reportName;
     // Prepare the output writer for generation
     $reportFileName = 'Exported Statistics - ' . $reportName;
     if (!empty($this->oStatsController->aDates['day_begin'])) {
         $oStartDate = new Date($this->oStatsController->aDates['day_begin']);
         $reportFileName .= ' from ' . $oStartDate->format($GLOBALS['date_format']);
     }
     if (!empty($this->oStatsController->aDates['day_end'])) {
         $oEndDate = new Date($this->oStatsController->aDates['day_end']);
         $reportFileName .= ' to ' . $oEndDate->format($GLOBALS['date_format']);
     }
     $reportFileName .= '.xls';
     $this->_oReportWriter->openWithFilename($reportFileName);
     // Get the header and data arrays from the same statistics controllers
     // that prepare stats for the user interface stats pages
     list($aHeaders, $aData) = $this->getHeadersAndDataFromStatsController(null, $this->oStatsController);
     // Add the worksheet
     $name = ucfirst($this->oStatsController->entity) . ' ' . ucfirst($this->oStatsController->breakdown);
     $this->createSubReport($reportName, $aHeaders, $aData);
     // Close the report writer and send the report to the user
     $this->_oReportWriter->closeAndSend();
 }
 /**
  * Merge aggregate stats with entity properties (name, children, etc)
  *
  * The overridden method also takes care to remove inactive entities
  * and to enforce the anonymous properties when logged in as advertiser
  * or publisher
  *
  * @param array Query parameters
  * @param string Key name
  * @return array Full entity stats with entity data
  */
 function mergeData($aParams, $key)
 {
     $aEntitiesData = parent::mergeData($aParams, $key);
     if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER) || OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
         if (is_null($this->aAnonAdvertisers)) {
             $this->aAnonAdvertisers = array();
             $this->aAnonPlacements = array();
             $aPlacements = Admin_DA::fromCache('getPlacements', array('placement_anonymous' => 't'));
             foreach ($aPlacements as $placementId => $placement) {
                 $this->aAnonAdvertisers[$placement['advertiser_id']] = true;
                 $this->aAnonPlacements[$placementId] = true;
             }
         }
     }
     foreach (array_keys($aEntitiesData) as $entityId) {
         if (!isset($this->data[$key][$entityId])) {
             unset($aEntitiesData[$entityId]);
         } elseif ($key == 'advertiser_id' && isset($this->aAnonAdvertisers[$entityId])) {
             $aEntitiesData[$entityId]['hidden'] = true;
         } elseif ($key == 'placement_id' && isset($this->aAnonPlacements[$entityId])) {
             $aEntitiesData[$entityId]['hidden'] = true;
         } elseif ($key == 'ad_id' && isset($this->aAnonPlacements[$aEntitiesData[$entityId]['placement_id']])) {
             $aEntitiesData[$entityId]['hidden'] = true;
         } elseif (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
             if (isset($aParams['placement_id'])) {
                 $aEntitiesData[$entityId]['hidden'] = isset($this->aAnonPlacements[$aParams['placement_id']]);
             } else {
                 $aEntitiesData[$entityId]['hidden'] = isset($this->aAnonAdvertisers[OA_Permission::getEntityId()]);
             }
         }
     }
     return $aEntitiesData;
 }
Example #6
0
 /**
  * A method to check for permissions to display the widget
  *
  */
 function checkAccess()
 {
     if (empty($this->accessList)) {
         $this->accessList = array(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER);
     }
     OA_Permission::enforceAccount($this->accessList);
 }
 public function beforePageHeader(OX_Admin_UI_Event_EventContext $oEventContext)
 {
     $pageId = $oEventContext->data['pageId'];
     $pageData = $oEventContext->data['pageData'];
     $oHeaderModel = $oEventContext->data['headerModel'];
     $agencyId = $pageData['agencyid'];
     $campaignId = $pageData['campaignid'];
     $advertiserId = $pageData['clientid'];
     $oEntityHelper = $this->oMarkedTextAdvertiserComponent->getEntityHelper();
     if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         switch ($pageId) {
             case 'campaign-banners':
                 $oDalZones = OA_Dal::factoryDAL('zones');
                 $linkedWebsites = $oDalZones->getWebsitesAndZonesListByCategory($agencyId, null, $campaignId, true);
                 $arraylinkedWebsitesKeys = array_keys($linkedWebsites);
                 $linkedWebsitesKey = $arraylinkedWebsitesKeys[0];
                 $arraylinkedZonesKeys = array_keys($linkedWebsites[$linkedWebsitesKey]['zones']);
                 $zoneId = $arraylinkedZonesKeys[0];
                 $aZone = Admin_DA::getZone($zoneId);
                 if ($aZone['type'] == 3) {
                     if (OA_Permission::hasAccessToObject('clients', $clientid) && OA_Permission::hasAccessToObject('campaigns', $campaignid)) {
                         OX_Admin_Redirect::redirect('plugins/' . $this->oMarkedTextAdvertiserComponent->group . "/oxMarkedTextAdvertiser-index.php?campaignid={$campaignId}&clientid={$advertiserId}");
                     }
                 }
                 break;
         }
     }
 }
 /**
  * The final "child" implementation of the parental abstract method.
  *
  * @see OA_Admin_Statistics_Common::start()
  */
 function start()
 {
     // Get parameters
     $advertiserId = $this->_getId('advertiser');
     // Security check
     OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER, OA_ACCOUNT_ADVERTISER);
     $this->_checkAccess(array('advertiser' => $advertiserId));
     // Add standard page parameters
     $this->aPageParams = array('clientid' => $advertiserId);
     // Load the period preset and stats breakdown parameters
     $this->_loadPeriodPresetParam();
     $this->_loadStatsBreakdownParam();
     // Load $_GET parameters
     $this->_loadParams();
     // HTML Framework
     if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN) || OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $this->pageId = '2.1.1';
         $this->aPageSections = array('2.1.1', '2.1.2', '2.1.3');
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         $this->pageId = '1.1';
         $this->aPageSections = array('1.1', '1.2', '1.3');
     }
     // Add breadcrumbs
     $this->_addBreadcrumbs('advertiser', $advertiserId);
     // Add context
     $this->aPageContext = array('advertisers', $advertiserId);
     // Add shortcuts
     if (!OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         $this->_addShortcut($GLOBALS['strClientProperties'], 'advertiser-edit.php?clientid=' . $advertiserId, 'images/icon-advertiser.gif');
     }
     // Prepare the data for display by output() method
     $aParams = array('advertiser_id' => $advertiserId);
     $this->prepare($aParams, 'stats.php');
 }
 private function parseEntityParams($aEntityParams)
 {
     $aMap = array('advertiser' => array('clientid'), 'campaign' => array('clientid', 'campaignid'), 'banner' => array('clientid', 'campaignid', 'bannerid'), 'affiliate' => array('affiliateid'), 'zone' => array('affiliateid', 'zoneid'));
     if (empty($aEntityParams['entity'])) {
         if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
             $aEntityParams['entity'] = 'advertiser';
         } elseif (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
             $aEntityParams['entity'] = 'affiliate';
         } else {
             $aEntityParams['entity'] = 'global';
         }
     }
     if ($aEntityParams['entity'] != 'global') {
         $allowed = implode('|', array_keys($aMap));
         if (!preg_match('/^(' . $allowed . ')(?:-(' . $allowed . '))?$/D', $aEntityParams['entity'], $aMatches)) {
             throw new exception("Unsupported entity breakdown");
         }
         array_shift($aMatches);
         $this->entity = join('-', $aMatches);
         foreach ($aMatches as $type) {
             foreach ($aMap[$type] as $inputVar) {
                 $this->aEntityParams[$inputVar] = !empty($aEntityParams[$inputVar]) ? (int) $aEntityParams[$inputVar] : 0;
             }
         }
     } else {
         $this->entity = 'global';
     }
 }
function OA_footerNavigation()
{
    echo "\n    <script language='JavaScript'>\n    <!--\n    ";
    if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        echo "function MMM_cascadePermissionsChange()\n        {\n            var e = findObj('permissions_" . OA_PERM_ZONE_EDIT . "');\n            var a = findObj('permissions_" . OA_PERM_ZONE_ADD . "');\n            var d = findObj('permissions_" . OA_PERM_ZONE_DELETE . "');\n\n            a.disabled = d.disabled = !e.checked;\n            if (!e.checked) {\n                a.checked = d.checked = false;\n            }\n        }\n        MMM_cascadePermissionsChange();\n        //-->";
    }
    echo "</script>";
}
Example #11
0
 /**
  * A method to launch and display the widget
  *
  */
 function display()
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     $oTpl = new OA_Admin_Template('dashboard/disabled.html');
     $oDashboard = new OA_Central_Dashboard();
     $oTpl->assign('isAdmin', OA_Permission::isAccount(OA_ACCOUNT_ADMIN));
     $oTpl->display();
 }
 /**
  * The final "child" implementation of the parental abstract method.
  *
  * @see OA_Admin_Statistics_Common::start()
  */
 function start()
 {
     // Get the preferences
     $aPref = $GLOBALS['_MAX']['PREF'];
     // Get parameters
     $advertiserId = $this->_getId('advertiser');
     $placementId = $this->_getId('placement');
     // Security check
     OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER, OA_ACCOUNT_ADVERTISER);
     $this->_checkAccess(array('advertiser' => $advertiserId, 'placement' => $placementId));
     // Add standard page parameters
     $this->aPageParams = array('clientid' => $advertiserId, 'campaignid' => $placementId);
     // Load the period preset and stats breakdown parameters
     $this->_loadPeriodPresetParam();
     $this->_loadStatsBreakdownParam();
     // Load $_GET parameters
     $this->_loadParams();
     // HTML Framework
     if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN) || OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $this->pageId = '2.1.2.2';
         $this->aPageSections = array('2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4');
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         $this->pageId = '1.2.2';
         $this->aPageSections = array('1.2.1', '1.2.2', '1.2.3');
     }
     // Add breadcrumbs
     $this->_addBreadcrumbs('campaign', $placementId);
     // Add context
     $this->aPageContext = array('campaigns', $placementId);
     // Add shortcuts
     if (!OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         $this->_addShortcut($GLOBALS['strClientProperties'], 'advertiser-edit.php?clientid=' . $advertiserId, 'images/icon-advertiser.gif');
     }
     $this->_addShortcut($GLOBALS['strCampaignProperties'], 'campaign-edit.php?clientid=' . $advertiserId . '&campaignid=' . $placementId, 'images/icon-campaign.gif');
     $this->hideInactive = MAX_getStoredValue('hideinactive', $aPref['ui_hide_inactive'] == true, null, true);
     $this->showHideInactive = true;
     $this->startLevel = 0;
     // Init nodes
     $this->aNodes = MAX_getStoredArray('nodes', array());
     $expand = MAX_getValue('expand', '');
     $collapse = MAX_getValue('collapse');
     // Adjust which nodes are opened closed...
     MAX_adjustNodes($this->aNodes, $expand, $collapse);
     $aParams = $this->coreParams;
     $aParams['placement_id'] = $placementId;
     $this->aEntitiesData = $this->getBanners($aParams, $this->startLevel, $expand);
     // Summarise the values into a the totals array, & format
     $this->_summariseTotalsAndFormat($this->aEntitiesData);
     $this->showHideLevels = array();
     $this->hiddenEntitiesText = "{$this->hiddenEntities} {$GLOBALS['strInactiveBannersHidden']}";
     // Save prefs
     $this->aPagePrefs['startlevel'] = $this->startLevel;
     $this->aPagePrefs['nodes'] = implode(",", $this->aNodes);
     $this->aPagePrefs['hideinactive'] = $this->hideInactive;
     $this->aPagePrefs['startlevel'] = $this->startLevel;
 }
Example #13
0
function phpAds_MaintenanceSelection($subSection, $mainSection = 'maintenance')
{
    global $phpAds_TextDirection, $strBanners, $strCache, $strChooseSection, $strPriority, $strSourceEdit, $strStats, $strStorage, $strMaintenance, $strCheckForUpdates, $strViewPastUpdates, $strEncoding, $strDeliveryLimitations, $strAppendCodes, $strMenus, $strPlugins;
    ?>
<script language="JavaScript">
<!--
function maintenance_goto_section()
{
    s = document.maintenance_selection.section.selectedIndex;

    s = document.maintenance_selection.section.options[s].value;
    document.location = '<?php 
    echo $mainSection;
    ?>
-' + s + '.php';
}
// -->
</script>
<?php 
    $conf =& $GLOBALS['_MAX']['CONF'];
    $pref =& $GLOBALS['_MAX']['PREF'];
    echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
    echo "<tr><form name='maintenance_selection'><td height='35'>";
    echo "<b>" . $strChooseSection . ":&nbsp;</b>";
    echo "<select name='section' onChange='maintenance_goto_section();'>";
    if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
        if ($mainSection == 'updates') {
            echo "<option value='product'" . ($subSection == 'product' ? ' selected' : '') . ">" . $strCheckForUpdates . "</option>";
            echo "<option value='history'" . ($subSection == 'history' ? ' selected' : '') . ">" . $strViewPastUpdates . "</option>";
        } else {
            echo "<option value='maintenance'" . ($subSection == 'maintenance' ? ' selected' : '') . ">" . $strMaintenance . "</option>";
            echo "<option value='banners'" . ($subSection == 'banners' ? ' selected' : '') . ">" . $strBanners . "</option>";
            echo "<option value='priority'" . ($subSection == 'priority' ? ' selected' : '') . ">" . $strPriority . "</option>";
            $login = '******' . $conf['store']['ftpUsername'] . ':' . $conf['store']['ftpPassword'] . '@' . $conf['store']['ftpHost'] . '/' . $conf['store']['ftpPath'];
            if ($conf['allowedBanners']['web'] == true && ($conf['store']['mode'] == 0 && $conf['store']['webDir'] != '' || $conf['store']['mode'] == 1 && $login != '') && $conf['webpath']['images'] != '') {
                echo "<option value='storage'" . ($subSection == 'storage' ? ' selected' : '') . ">" . $strStorage . "</option>";
            }
            //            if (!isset($conf['delivery']['cache']) || $conf['delivery']['cache'] != 'none')
            //                echo "<option value='cache'".($subSection == 'zones' ? ' selected' : '').">".$strCache."</option>";
            if ($conf['delivery']['acls']) {
                echo "<option value='acls'" . ($subSection == 'acls' ? ' selected' : '') . ">" . $strDeliveryLimitations . "</option>";
            }
            echo "<option value='appendcodes'" . ($subSection == 'appendcodes' ? ' selected' : '') . ">" . $strAppendCodes . "</option>";
            echo "<option value='encoding'" . ($subSection == 'encoding' ? ' selected' : '') . ">{$strEncoding}</option>";
            echo "<option value='menus'" . ($subSection == 'menus' ? ' selected' : '') . ">" . $strMenus . "</option>";
            echo "<option value='plugins'" . ($subSection == 'plugins' ? ' selected' : '') . ">" . $strPlugins . "</option>";
        }
    }
    // Switched off
    // echo "<option value='finance'".($subSection == 'finance' ? ' selected' : '').">Finance</option>";
    echo "</select>&nbsp;<a href='javascript:void(0)' onClick='maintenance_goto_section();'>";
    echo "<img src='" . OX::assetPath() . "/images/" . $phpAds_TextDirection . "/go_blue.gif' border='0'></a>";
    echo "</td></form></tr>";
    echo "</table>";
    phpAds_ShowBreak();
}
 private function clearEntitiesInSession()
 {
     global $session;
     $clientid = $session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['clientid'];
     unset($session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['clientid']);
     if ($clientid) {
         unset($session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['campaignid'][$clientid]);
     }
     phpAds_SessionDataStore();
 }
 function getAgencyDetails($agencyId = null)
 {
     if (is_null($agencyId)) {
         $agencyId = OA_Permission::getAgencyId();
     }
     $doAgency =& OA_Dal::factoryDO('agency');
     $doAgency->get($agencyId);
     $aResult = $doAgency->toArray();
     return $aResult;
 }
Example #16
0
 /**
  * This method sets all default values when adding a new channel.
  *
  */
 function setDefaultForAdd()
 {
     if (empty($this->agencyId)) {
         $this->agencyId = OA_Permission::getAgencyId();
     }
     if (empty($this->websiteId)) {
         // Set it to 'global'
         $this->websiteId = 0;
     }
 }
 /**
  * The final "child" implementation of the parental abstract method.
  *
  * @see OA_Admin_Statistics_Common::start()
  */
 function start()
 {
     // Get the preferences
     $aPref = $GLOBALS['_MAX']['PREF'];
     // Security check
     OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER);
     // HTML Framework
     $this->pageId = '2.4';
     $this->aPageSections = array('2.1', '2.4', '2.2');
     $this->hideInactive = MAX_getStoredValue('hideinactive', $aPref['ui_hide_inactive'] == true, null, true);
     $this->showHideInactive = true;
     $this->startLevel = MAX_getStoredValue('startlevel', 0, null, true);
     // Init nodes
     $this->aNodes = MAX_getStoredArray('nodes', array());
     $expand = MAX_getValue('expand', '');
     $collapse = MAX_getValue('collapse');
     // Adjust which nodes are opened closed...
     MAX_adjustNodes($this->aNodes, $expand, $collapse);
     $aParams = $this->coreParams;
     if (!OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
         $aParams['agency_id'] = OA_Permission::getAgencyId();
     }
     // Add module page parameters
     $this->aPageParams['period_preset'] = MAX_getStoredValue('period_preset', 'today');
     $this->aPageParams['statsBreakdown'] = htmlspecialchars(MAX_getStoredValue('statsBreakdown', 'day'));
     $this->_loadParams();
     switch ($this->startLevel) {
         case 1:
             $this->aEntitiesData = $this->getZones($aParams, $this->startLevel, $expand);
             break;
         default:
             $this->startLevel = 0;
             $this->aEntitiesData = $this->getPublishers($aParams, $this->startLevel, $expand);
             break;
     }
     // Summarise the values into a the totals array, & format
     $this->_summariseTotalsAndFormat($this->aEntitiesData);
     $this->showHideLevels = array();
     switch ($this->startLevel) {
         case 1:
             $this->showHideLevels = array(0 => array('text' => $GLOBALS['strShowParentAffiliates'], 'icon' => 'images/icon-affiliate.gif'));
             $this->hiddenEntitiesText = "{$this->hiddenEntities} {$GLOBALS['strInactiveZonesHidden']}";
             break;
         case 0:
             $this->showHideLevels = array(1 => array('text' => $GLOBALS['strHideParentAffiliates'], 'icon' => 'images/icon-affiliate-d.gif'));
             $this->hiddenEntitiesText = "{$this->hiddenEntities} {$GLOBALS['strInactiveAffiliatesHidden']}";
             break;
     }
     // Save prefs
     $this->aPagePrefs['startlevel'] = $this->startLevel;
     $this->aPagePrefs['nodes'] = implode(",", $this->aNodes);
     $this->aPagePrefs['hideinactive'] = $this->hideInactive;
     $this->aPagePrefs['startlevel'] = $this->startLevel;
 }
function OA_HeaderNavigation()
{
    global $agencyid;
    if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
        phpAds_PageHeader("agency-access");
        $doAgency = OA_Dal::staticGetDO('agency', $agencyid);
        MAX_displayInventoryBreadcrumbs(array(array("name" => $doAgency->name)), "agency");
    } else {
        phpAds_PageHeader("agency-user");
    }
}
Example #19
0
 public static function assignModel(OA_Admin_Template $template, $query = '')
 {
     $accounts = OA_Permission::getLinkedAccounts(true, true);
     $remainingCounts = array();
     // Prepare recently used accountName
     $recentlyUsed = array();
     global $session;
     if (empty($query) && !empty($session['recentlyUsedAccounts'])) {
         $allAcountsNoGroups = array();
         foreach ($accounts as $k => $v) {
             foreach ($accounts[$k] as $accountId => $accountName) {
                 $allAcountsNoGroups[$accountId] = $accountName;
             }
         }
         $recentlyUsedAccountIds = $session['recentlyUsedAccounts'];
         $added = 0;
         foreach ($recentlyUsedAccountIds as $k => $recentlyUserAccountId) {
             if (++$added > self::MAX_ACCOUNTS_IN_GROUP) {
                 break;
             }
             $recentlyUsed[$recentlyUserAccountId] = $allAcountsNoGroups[$recentlyUserAccountId];
         }
     }
     // Prepare admin accounts
     if (isset($accounts[OA_ACCOUNT_ADMIN])) {
         $adminAccounts = self::filterByNameAndLimit($accounts[OA_ACCOUNT_ADMIN], $query, $remainingCounts, OA_ACCOUNT_ADMIN);
         unset($accounts[OA_ACCOUNT_ADMIN]);
     } else {
         $adminAccounts = array();
     }
     $showSearchAndRecent = false;
     foreach ($accounts as $k => $v) {
         $workingFor = sprintf($GLOBALS['strWorkingFor'], ucfirst(strtolower($k)));
         $accounts[$workingFor] = self::filterByNameAndLimit($v, $query, $remainingCounts, $workingFor);
         $count = count($accounts[$workingFor]);
         if ($count == 0) {
             unset($accounts[$workingFor]);
         }
         $showSearchAndRecent |= isset($remainingCounts[$workingFor]);
         unset($accounts[$k]);
     }
     // Prepend recently used to the results
     if (!empty($recentlyUsed) && $showSearchAndRecent) {
         $accounts = array_merge(array($GLOBALS['strRecentlyUsed'] => $recentlyUsed), $accounts);
     }
     $template->assign('adminAccounts', $adminAccounts);
     $template->assign('otherAccounts', $accounts);
     $template->assign('remainingCounts', $remainingCounts);
     $template->assign('query', $query);
     $template->assign('noAccountsMessage', sprintf($GLOBALS['strNoAccountWithXInNameFound'], $query));
     $template->assign('currentAccountId', OA_Permission::getAccountId());
     $template->assign('showSearchAndRecent', $showSearchAndRecent);
 }
 function getZones()
 {
     global $list_filters;
     if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
         $aParams = array();
         $aPublishers = Admin_DA::getPublishers($aParams);
         // set publisher id if list is to be filtered by publisher
         if (isset($list_filters['publisher'])) {
             $aParams = array('publisher_id' => $list_filters['publisher']);
         } else {
             // else use all publishers
             $aParams = array('publisher_id' => implode(',', array_keys($aPublishers)));
         }
         if (isset($this->_filter)) {
             $aParams['zone_inventory_forecast_type'] = $this->getForecastType();
         }
         $aZones = Admin_DA::getZones($aParams);
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $aParams = array('agency_id' => OA_Permission::getEntityId());
         $aPublishers = Admin_DA::getPublishers($aParams);
         // set publisher id if list is to be filtered by publisher
         if (isset($list_filters['publisher'])) {
             $aParams = array('publisher_id' => $list_filters['publisher']);
         } else {
             // else use all of this agency's publishers
             $aParams = array('publisher_id' => implode(',', array_keys($aPublishers)));
         }
         if (isset($this->_filter)) {
             $aParams['zone_inventory_forecast_type'] = $this->getForecastType();
         }
         $aZones = Admin_DA::getZones($aParams);
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
         $aParams = array('publisher_id' => OA_Permission::getEntityId());
         $aPublishers = Admin_DA::getPublishers($aParams);
         $aParams = array('publisher_id' => implode(',', array_keys($aPublishers)));
         if (isset($this->_filter)) {
             $aParams['zone_inventory_forecast_type'] = $this->getForecastType();
         }
         $aZones = Admin_DA::getZones($aParams);
     } else {
         $aPublishers = array();
         $aZones = array();
     }
     $aZoneArray = array();
     foreach ($aPublishers as $publisherId => $aPublisher) {
         foreach ($aZones as $zoneId => $aZone) {
             if ($aZone['publisher_id'] == $publisherId) {
                 $aZoneArray[$zoneId] = phpads_buildName($publisherId, MAX_getPublisherName($aPublisher['name'])) . " - " . phpAds_buildName($zoneId, MAX_getZoneName($aZone['name']));
             }
         }
     }
     return $aZoneArray;
 }
Example #21
0
 function getStats()
 {
     // Set time zone to local
     OA_setTimeZoneLocal();
     $oEnd = new Date();
     $oEnd->setHour(0);
     $oEnd->setMinute(0);
     $oEnd->setSecond(0);
     $oEnd->toUTC();
     $oStart = new Date($oEnd);
     $oStart->subtractSpan(new Date_Span('7-0-0-0'));
     $oStart->toUTC();
     $doDsah = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDsah->selectAdd();
     $doDsah->selectAdd("DATE_FORMAT(date_time, '%Y-%m-%d') AS day");
     $doDsah->selectAdd('SUM(' . $doDsah->tableName() . '.impressions) AS total_impressions');
     $doDsah->selectAdd('SUM(' . $doDsah->tableName() . '.clicks) AS total_clicks');
     $doDsah->whereAdd("date_time >= '" . $doDsah->escape($oStart->format('%Y-%m-%d %H:%M:%S')) . "'");
     $doDsah->whereAdd("date_time < '" . $doDsah->escape($oEnd->format('%Y-%m-%d %H:%M:%S')) . "'");
     if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $doBanners = OA_Dal::factoryDO('banners');
         $doCampaigns = OA_Dal::factoryDO('campaigns');
         $doClients = OA_Dal::factoryDO('clients');
         $doClients->agencyid = OA_Permission::getEntityId();
         $doCampaigns->joinAdd($doClients);
         $doBanners->joinAdd($doCampaigns);
         $doBanners->selectAdd();
         $doBanners->selectAdd("bannerid");
         $doBanners->find();
         $ad_ids = array();
         while ($doBanners->fetch()) {
             $ad_ids[] = $doBanners->bannerid;
         }
         if (empty($ad_ids)) {
             return array();
         }
         $doDsah->whereAdd("ad_id IN (" . implode(",", $ad_ids) . ")");
     }
     $doDsah->groupBy('day');
     $doDsah->orderBy('day');
     $doDsah->find();
     $aStats = array();
     while ($doDsah->fetch()) {
         $row = $doDsah->toArray();
         $aStats[0][date('D', strtotime($row['day']))] = $row['total_impressions'];
         $aStats[1][date('D', strtotime($row['day']))] = $row['total_clicks'];
     }
     return $aStats;
 }
 public static function createTemplateWithModel($panel, $single = true)
 {
     $agencyId = OA_Permission::getAgencyId();
     $oDalZones = OA_Dal::factoryDAL('zones');
     $infix = $single ? '' : '-' . $panel;
     phpAds_registerGlobalUnslashed('action', 'campaignid', 'clientid', "text{$infix}", "page{$infix}");
     $campaignId = $GLOBALS['campaignid'];
     $text = $GLOBALS["text{$infix}"];
     $linked = $panel == 'linked';
     $showStats = empty($GLOBALS['_MAX']['CONF']['ui']['zoneLinkingStatistics']) ? false : true;
     $websites = $oDalZones->getWebsitesAndZonesList($agencyId, $campaignId, $linked, $text);
     $matchingZones = 0;
     foreach ($websites as $aWebsite) {
         $matchingZones += count($aWebsite['zones']);
     }
     $aZonesCounts = array('all' => $oDalZones->countZones($agencyId, null, $campaignId, $linked), 'matching' => $matchingZones);
     $pagerFileName = 'campaign-zone-zones.php';
     $pagerParams = array('clientid' => $GLOBALS['clientid'], 'campaignid' => $GLOBALS['campaignid'], 'status' => $panel, 'text' => $text);
     $currentPage = null;
     if (!$single) {
         $currentPage = $GLOBALS["page{$infix}"];
     }
     $oTpl = new OA_Admin_Template('campaign-zone-zones.html');
     $oPager = OX_buildPager($websites, self::WEBSITES_PER_PAGE, true, 'websites', 2, $currentPage, $pagerFileName, $pagerParams);
     $oTopPager = OX_buildPager($websites, self::WEBSITES_PER_PAGE, false, 'websites', 2, $currentPage, $pagerFileName, $pagerParams);
     list($itemsFrom, $itemsTo) = $oPager->getOffsetByPageId();
     $websites = array_slice($websites, $itemsFrom - 1, self::WEBSITES_PER_PAGE, true);
     // Add statistics for the displayed zones if required
     if ($showStats) {
         $oDalZones->mergeStatistics($websites, $campaignId);
     }
     // Count how many zone are displayed
     $showingCount = 0;
     foreach ($websites as $website) {
         $showingCount += count($website['zones']);
     }
     $aZonesCounts['showing'] = $showingCount;
     $oTpl->assign('pager', $oPager);
     $oTpl->assign('topPager', $oTopPager);
     $oTpl->assign('websites', $websites);
     $oTpl->assign('zonescounts', $aZonesCounts);
     $oTpl->assign('text', $text);
     $oTpl->assign('status', $panel);
     $oTpl->assign('page', $oTopPager->getCurrentPageID());
     $oTpl->assign('showStats', $showStats);
     $oTpl->assign('colspan', $showStats ? 6 : 3);
     return $oTpl;
 }
 function _getTrackerArray()
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     $where = "c.clientid = t.clientid";
     if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $where .= " AND c.agencyid = " . OA_Permission::getEntityId();
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         $where .= " AND t.clientid = " . OA_Permission::getEntityId();
     }
     $query = "\n            SELECT\n                c.clientname AS client_name,\n                c.clientid AS client_id,\n                t.trackername AS tracker_name,\n                t.trackerid AS tracker_id\n            FROM\n                {$conf['table']['trackers']} AS t,\n                {$conf['table']['clients']} AS c\n            WHERE\n                {$where}\n            ORDER BY\n                c.clientname,t.trackername\n        ";
     $res = phpAds_dbQuery($query);
     while ($row = phpAds_dbFetchArray($res)) {
         $trackerArray[$row['tracker_id']] = "<span dir='" . $GLOBALS['phpAds_TextDirection'] . "'>[id" . $row['client_id'] . "] " . $row['client_name'] . " - [id" . $row['tracker_id'] . "] " . $row['tracker_name'] . "</span> ";
     }
     return $trackerArray;
 }
 function check($oSection)
 {
     $aAccounts = $this->_getAllowedAccountTypes();
     //no required accounts to show it
     if (empty($aAccounts)) {
         return true;
     }
     $isAllowedAccount = false;
     for ($i = 0; $i < count($aAccounts); $i++) {
         $isAllowedAccount = OA_Permission::isAccount($aAccounts[$i]);
         if ($isAllowedAccount) {
             break;
         }
     }
     return $isAllowedAccount;
 }
 function check($oSection)
 {
     $aPermissions = $this->_getAcceptedPermissions();
     //no required permissions, we can show the section
     if (empty($aPermissions)) {
         return true;
     }
     $hasRequiredPermission = false;
     for ($i = 0; $i < count($aPermissions); $i++) {
         $hasRequiredPermission = OA_Permission::hasPermission($aPermissions[$i]);
         if ($hasRequiredPermission) {
             break;
         }
     }
     return $hasRequiredPermission;
 }
Example #26
0
 function display()
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     if (!$conf['audit']['enabled']) {
         $this->oTpl->assign('screen', 'disabled');
         $this->oTpl->assign('siteTitle', $GLOBALS['strAuditTrailSetup']);
         $this->oTpl->assign('siteUrl', MAX::constructUrl(MAX_URL_ADMIN, 'account-settings-debug.php'));
     } else {
         // Account security
         if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
             $aParams['account_id'] = OA_Permission::getAccountId();
         }
         if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
             $aParams['advertiser_account_id'] = OA_Permission::getAccountId();
         }
         if (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
             $aParams['website_account_id'] = OA_Permission::getAccountId();
         }
         $oAudit = new OA_Dll_Audit();
         $aAuditData = $oAudit->getAuditLogForAuditWidget($aParams);
         if (count($aAuditData) > 0) {
             foreach ($aAuditData as $key => $aValue) {
                 $aValue['action'] = $this->oTrans->translate($oAudit->getActionName($aValue['actionid']));
                 $result = $oAudit->getParentContextData($aValue);
                 $str = "{$aValue['username']} {$GLOBALS['strHas']} {$aValue['action']} {$aValue['context']}";
                 if (!empty($aValue['contextid'])) {
                     $str .= " ({$aValue['contextid']})";
                 }
                 if (!empty($aValue['parentcontext'])) {
                     $str .= " {$GLOBALS['strFor']} {$aValue['parentcontext']} ({$aValue['parentcontextid']})";
                 }
                 if (!empty($aValue['hasChildren'])) {
                     $str .= " {$GLOBALS['strAdditionItems']}";
                 }
                 $aAuditData[$key]['desc'] = strlen($str) > 30 ? substr($str, 0, 30) . '...' : $str;
             }
         } else {
             $this->oTpl->assign('noData', $GLOBALS['strAuditNoData']);
         }
         $this->oTpl->assign('screen', 'enabled');
         $this->oTpl->assign('aAuditData', $aAuditData);
         $this->oTpl->assign('siteUrl', MAX::constructUrl(MAX_URL_ADMIN, 'userlog-index.php'));
         $this->oTpl->assign('siteTitle', $GLOBALS['strAuditTrailGoTo']);
     }
     $this->oTpl->display();
 }
Example #27
0
function OA_headerNavigation()
{
    $oHeaderModel = buildAdvertiserHeaderModel($GLOBALS['clientid']);
    if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        phpAds_PageHeader("advertiser-access", $oHeaderModel);
        phpAds_ShowSections(array("4.1.2", "4.1.3", "4.1.5", "4.1.5.2"));
    } else {
        $sections = array();
        if (OA_Permission::hasPermission(OA_PERM_BANNER_ACTIVATE) || OA_Permission::hasPermission(OA_PERM_BANNER_EDIT)) {
            $sections[] = '2.2';
        }
        $sections[] = '2.3';
        $sections[] = '2.3.2';
        phpAds_PageHeader('advertiser-access', $oHeaderModel);
        phpAds_ShowSections($sections);
    }
}
 /**
  * The final "child" implementation of the parental abstract method.
  *
  * @see OA_Admin_Statistics_Common::start()
  */
 function start()
 {
     // Get parameters
     $publisherId = $this->_getId('publisher');
     $placementId = $this->_getId('placement', 0);
     // Security check
     OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER, OA_ACCOUNT_TRAFFICKER);
     $this->_checkAccess(array('publisher' => $publisherId));
     // Fetch campaigns
     $aPlacements = $this->getPublisherCampaigns($publisherId);
     // Cross-entity security check
     if (!isset($aPlacements[$placementId])) {
         $this->noStatsAvailable = true;
     }
     // Add standard page parameters
     $this->aPageParams = array('affiliateid' => $publisherId, 'campaignid' => $placementId, 'zoneid' => $zoneId);
     // Load the period preset and stats breakdown parameters
     $this->_loadPeriodPresetParam();
     $this->_loadStatsBreakdownParam();
     // Load $_GET parameters
     $this->_loadParams();
     // HTML Framework
     if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN) || OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $this->pageId = '2.4.3.1';
         $this->aPageSections = array($this->pageId);
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
         $this->pageId = '1.3.1';
         $this->aPageSections = array($this->pageId);
     }
     // Add breadcrumbs
     $this->_addBreadcrumbs('publisher', $publisherId);
     $this->addCrossBreadcrumbs('campaign', $placementId);
     // Add context
     $params = $this->aPageParams;
     foreach ($aPlacements as $k => $v) {
         $params['campaignid'] = $k;
         phpAds_PageContext(MAX_buildName($k, MAX_getPlacementName($v)), $this->_addPageParamsToURI($this->pageName, $params, true), $placementId == $k);
     }
     // Add shortcuts
     if (!OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
         $this->_addShortcut($GLOBALS['strAffiliateProperties'], 'affiliate-edit.php?affiliateid=' . $publisherId, 'images/icon-affiliate.gif');
     }
     // Prepare the data for display by output() method
     $aParams = array('publisher_id' => $publisherId, 'placement_id' => $placementId);
     $this->prepare($aParams, 'stats.php');
 }
Example #29
0
 /**
  * @todo Handle cases where user is not Admin, Agency or Advertiser
  */
 function _getPublisherArray($orderBy = null)
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
         $query = "SELECT affiliateid,name" . " FROM " . $conf['table']['prefix'] . $conf['table']['affiliates'];
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $query = "SELECT affiliateid,name" . " FROM " . $conf['table']['prefix'] . $conf['table']['affiliates'] . " WHERE agencyid=" . OA_Permission::getEntityId();
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         $query = "SELECT affiliateid,name" . " FROM " . $conf['table']['prefix'] . $conf['table']['affiliates'] . " WHERE affiliateid=" . OA_Permission::getEntityId();
     }
     $orderBy ? $query .= " ORDER BY {$orderBy} ASC" : 0;
     $res = phpAds_dbQuery($query);
     while ($row = phpAds_dbFetchArray($res)) {
         $affiliateArray[$row['affiliateid']] = phpAds_buildAffiliateName($row['affiliateid'], $row['name']);
     }
     return $affiliateArray;
 }
 function _getAdvertiserArray($orderBy = null)
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
         $query = "SELECT clientid,clientname" . " FROM " . $conf['table']['prefix'] . $conf['table']['clients'];
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $query = "SELECT clientid,clientname" . " FROM " . $conf['table']['prefix'] . $conf['table']['clients'] . " WHERE agencyid=" . OA_Permission::getEntityId();
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         $query = "SELECT clientid,clientname" . " FROM " . $conf['table']['prefix'] . $conf['table']['clients'] . " WHERE clientid=" . OA_Permission::getEntityId();
     }
     $orderBy ? $query .= " ORDER BY {$orderBy} ASC" : 0;
     $oDbh = OA_DB::singleton();
     $oRes = $oDbh->query($query);
     while ($row = $oRes->fetchRow()) {
         $clientArray[$row['clientid']] = phpAds_buildName($row['clientid'], $row['clientname']);
     }
     return $clientArray;
 }