public function getApps() { if ($this->apps == null) { $this->apps = AppUtil::getAppsByUid($this->id); } return $this->networks; }
public function __default() { $this->user->postGet(); $b = $this->user->getPref('msg_003'); if (empty($b)) { $msg_003 = "<span class='msg'>NEW! AdWhirl now explicitly supports Millennial Media on Android – download the new <a target='_newtab' href='http://code.google.com/p/adwhirl/downloads/list'>AdWhirl Android SDK</a></span>"; $this->smarty->assign('message', $msg_003); $this->smarty->assign('msg_id', 'msg_003'); } else { $a = $this->user->getPref('msg_001'); if (empty($a)) { $msg_001 = "<span class='msg'>Learn about how you can add unlimited additional networks with <a target='_newtab' href='http://helpcenter.adwhirl.com/content/custom-events-and-generic-notifications'>Custom Events</a></span>"; $this->smarty->assign('message', $msg_001); $this->smarty->assign('msg_id', 'msg_001'); } } $this->smarty->assign('returnPage', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null); $this->displayFinalArrowInBreadcrumbs = true; $o = isset($_REQUEST['o']) ? $_REQUEST['o'] : 0; $o = intval($o); $apps = AppUtil::getAppsByUid($this->user->id); $missingApp = false; $notMissingApp = false || empty($_REQUEST['n_aid']); if (!empty($_REQUEST['n_aid'])) { foreach ($apps as $app) { $missingApp |= $app->id != $_REQUEST['n_aid']; $notMissingApp |= $app->id == $_REQUEST['n_aid']; // echo $notMissingApp . "- " . $missingApp .'-'. $app->id . '-'. $_REQUEST['n_aid'] . '--'.($app->id == $_REQUEST['n_aid']) .'<br>'; } } if (!empty($_REQUEST['del_aid'])) { foreach ($apps as $idx => $app) { if ($app->id == $_REQUEST['del_aid']) { unset($apps[$idx]); } } } // fb('missingApp',$missingApp); // echo "NotMissingApp $notMissingApp <br>"; if (!$notMissingApp) { $app = new App(); $app->id = $_REQUEST['n_aid']; $app->name = $_REQUEST['n_name']; $app->platform = intval($_REQUEST['n_platform']); $apps[] = $app; fb("App", $app); } usort($apps, "sortAppsByName"); fb('apps', $apps); $total = count($apps); $itemsPerPage = 10; fb('apps', $apps); $apps = array_slice($apps, $o, $itemsPerPage); fb('apps', $apps); // array_pop($this->breadcrumbs); // $this->breadcrumbs[] = array("text"=>"App List","link"=>"/apps/apps"); $this->subtitle = "App List"; $this->smarty->assign('apps', $apps); $this->smarty->assign('current_offset', $o); $this->smarty->assign('total', $total); $this->smarty->assign('itemsPerPage', $itemsPerPage); fb("smarty", $this->smarty->get_template_vars()); return $this->smarty->fetch('../tpl/www/apps/apps.tpl'); }
public function edit() { $this->jsFiles[] = "/js/jqsm135.js"; $this->jsFiles[] = "/js/jquery.validate.min.js"; $this->needsHouseAd(); $this->jsFiles[] = "/js/ajaxupload.js"; $this->smarty->assign('returnPage', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null); $apps = AppUtil::getAppsByUid($this->user->id); $appHouseAds = array(); foreach (AppHouseAdUtil::getAppHouseAdsByCid($this->houseAd->id) as $appHouseAd) { $appHouseAds[$appHouseAd->aid] = $appHouseAd; } foreach ($apps as $app) { if (array_key_exists($app->id, $appHouseAds)) { $app->ahid = $appHouseAds[$app->id]->id; } } $this->smarty->assign('apps', $apps); $hasiPhoneApp = false; $hasAndroidApp = false; foreach ($apps as $app) { $hasiPhoneApp |= $app->platform == 1; $hasAndroidApp |= $app->platform == 2; } $this->smarty->assign('hasNoiPhoneApp', !$hasiPhoneApp); $this->smarty->assign('hasNoAndroidApp', !$hasAndroidApp); $this->styleSheets[] = "/css/preview.css"; $this->smarty->assign('linkTypeOptions', HouseAd::$HOUSEAD_LINKTYPES); $this->smarty->assign('typeOptions', HouseAd::$HOUSEAD_TYPES); $this->smarty->assign('createOrEdit', 'edit'); $this->smarty->assign('appHouseAds', $appHouseAds); $this->breadcrumbs[] = array('text' => "Edit", 'link' => '/houseAds/ad/edit'); $this->smarty->assign('houseAd', $this->houseAd); fb("smarty", $this->smarty->get_template_vars()); return $this->smarty->fetch('../tpl/www/houseAds/create.tpl'); }
public function getXML() { $this->printHeader = false; $this->printFooter = false; $apps = AppUtil::getAppsByUid($_SESSION['uid']); fb("app", $apps); $reports = ReportUtil::getReportsByCid($this->cid, $this->startDate, $this->endDate, $this->numCat, $this->platform); fb("reports", $reports); $new_reports = $this->collapseReport($reports); if ($this->metricTypeSelected == "CTR") { $this->calculateCTR($new_reports); } fb("nr", $new_reports); $this->smarty->assign('reports', $new_reports); $this->smarty->assign('nets', $reports['nets']); $this->smarty->assign('dates', $new_reports['dates']); $this->smarty->assign('metric', strtolower($this->metricTypeSelected)); //fb("smarty",$this->smarty->get_template_vars()); return $this->smarty->fetch('../tpl/www/reports/applicationReportsXML.tpl'); // // foreach($houseAds as $houseAd) { // $houseAd->reports = ReportUtil::getReportsByCid($houseAd->id, $this->startDate, $this->endDate); // } // // $totals = array(); // $dates = array(); // for($i=$this->startDate; $i<=$this->endDate; $i=date('Y-m-d', strtotime('+1 day', strtotime($i)))) { // $dates[] = $i; // // foreach($houseAds as $houseAd) { // if(isset($totals[$i])) { // $totals[$i]['impressions'] += $houseAd->reports[$i]['impressions']; // $totals[$i]['clicks'] += $houseAd->reports[$i]['clicks']; // } // else { // $totals[$i]['impressions'] = $houseAd->reports[$i]['impressions']; // $totals[$i]['clicks'] = $houseAd->reports[$i]['clicks']; // } // } // } // // $this->smarty->assign('houseAds', $houseAds); // $this->smarty->assign('dates', $dates); // $this->smarty->assign('totals', $totals); // // return $this->smarty->fetch('../tpl/www/reports/houseAdReportsXML.tpl'); }
public function __default() { $this->user->postGet(); $a = $this->user->getPref('msg_002'); if (empty($a)) { $msg_002 = "<span class='msg'>Learn about our upgraded <a target='_newtab' href='http://helpcenter.adwhirl.com/content/step-6-allocate-your-house-ads'>House Ads</a> functionality</span>"; $this->smarty->assign('message', $msg_002); $this->smarty->assign('msg_id', 'msg_002'); } $this->smarty->assign('returnPage', isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : null); $this->styleSheets[] = "/css/preview.css"; $this->jsFiles[] = "/js/jqsm135.js"; $this->displayFinalArrowInBreadcrumbs = true; $houseAds = HouseAdUtil::getHouseAdsByUid($_SESSION['uid']); $apps = AppUtil::getAppsByUid($this->user->id); $o = isset($_REQUEST['o']) ? $_REQUEST['o'] : 0; $o = intval($o); $haveMissingAd = false; // Assume we don't have the missing ad until we scan them all if (!empty($_REQUEST['n_cid'])) { foreach ($houseAds as $houseAd) { // if the current ad has the same id, we know we have the missing ad $haveMissingAd |= $houseAd->id == $_REQUEST['n_cid']; // Stop if we know we have the missing ad if ($haveMissingAd) { break; } } } else { $haveMissingAd = true; // no new ad id passed in, so all ads should be in the DB } if (!empty($_REQUEST['del_cid'])) { foreach ($houseAds as $idx => $houseAd) { if ($houseAd->id == $_REQUEST['del_cid']) { unset($houseAds[$idx]); } } } fb('haveMissingAd', $haveMissingAd); // Do we have all the ads? If not, let's add the missing one. if (!$haveMissingAd) { $houseAd = new HouseAd(); $houseAd->id = $_REQUEST['n_cid']; $houseAd->name = $_REQUEST['n_name']; $houseAd->type = intval($_REQUEST['n_type']); $houseAd->linkType = intval($_REQUEST['n_linkType']); $houseAds[] = $houseAd; fb("houseAd", $houseAd); } $fields = array('name', 'linkType', 'type'); $total = count($houseAds); if ($total <= 10) { $fields[] = 'numApp'; } $sortBy = isset($_REQUEST['sortBy']) ? $_REQUEST['sortBy'] : 'nameAsc'; if (substr($sortBy, -1) == '?') { $sortBy = substr($sortBy, 0, -1); } $isAsc = substr($sortBy, -3) == 'Asc'; $sortBy = substr($sortBy, 0, strlen($sortBy) - 3); foreach ($fields as $field) { $fname = $field; if ($field == $sortBy) { $val = $fname . ($isAsc ? 'Dsc' : 'Asc'); } else { $val = isset($_REQUEST[$fname]) ? $_REQUEST[$fname] : $field . 'Asc'; } $this->smarty->assign($fname, $val); } $itemsPerPage = 10; if ($sortBy == 'numApp' && $total <= 10) { $fname = 'numApp' . ($isAsc ? 'Asc' : 'Dsc'); foreach ($houseAds as $houseAd) { $houseAd->getApps(); } usort($houseAds, $fname); } else { if ($sortBy == 'numApp') { $sortBy = 'name'; $isAsc = 'true'; } usort($houseAds, makeSortFunction($sortBy, $isAsc)); $houseAds = array_slice($houseAds, $o, $itemsPerPage); foreach ($houseAds as $houseAd) { $houseAd->getApps(); } } $this->smarty->assign('appsCount', count($apps)); $this->smarty->assign('current_offset', $o); $this->smarty->assign('total', $total); $this->smarty->assign('itemsPerPage', $itemsPerPage); $this->subtitle = "House Ads"; $this->smarty->assign('linkLabels', HouseAd::$HOUSEAD_LINKTYPES); fb($houseAds); $this->smarty->assign('houseAds', $houseAds); $this->smarty->assign('houseAdTypes', HouseAd::$HOUSEAD_TYPES); fb("smarty", $this->smarty->get_template_vars()); return $this->smarty->fetch('../tpl/www/houseAds/houseAds.tpl'); }
public function getXML() { $this->printHeader = false; $this->printFooter = false; if ($this->aid != null) { $app = new App($this->aid); } else { $apps = AppUtil::getAppsByUid($this->user->id); $app = $apps['0']; } $reports = ReportUtil::getReportsByAid($app->id, $this->startDate, $this->endDate); fb("reports", $reports); $new_reports = $this->collapseReport($reports); fb("nr", $new_reports); $this->smarty->assign('reports', $new_reports); $this->smarty->assign('nets', $reports['nets']); $this->smarty->assign('dates', $new_reports['dates']); $this->smarty->assign('metric', 'impressions'); return $this->smarty->fetch('../tpl/www/reports/applicationReportsXML.tpl'); }
private function needsApp() { $this->app = AppUtil::getActiveApp($this->user); // $this->app->adjustHouseAdNetwork(null, null); if ($this->app === null) { redirect('/apps/apps'); } $crumb = array('text' => $this->app->name, 'link' => '/apps/oneApp?aid=' . $this->app->id); $this->breadcrumbs[] = $crumb; $this->subtitle = "<span style='display:inline-block;padding-top:7px;padding-right:7px'>" . $this->app->name . "</span><span style='padding-left:10px;font-size:11px;color:#666'>SDK Key:" . $this->app->id . "</span>"; $this->needSwitcher = true; $this->switcherText = 'Switch App'; $switchList = array(); foreach (AppUtil::getAppsByUid($this->user->id) as $app) { if ($app->id != $this->app->id) { $switchList[] = $app; } } $this->switcherList = $switchList; }
public static function getNetworkReportsByUid($uid, $startDate, $endDate) { $sdb = SDB::getInstance(); $apps = AppUtil::getAppsByUid($uid); $reports = array(); foreach ($apps as $app) { $aid = $app->id; $aaa = array($groupBy, 'clicks', 'impressions', 'dateTime'); $sdb->select(Report::$SDBDomain, $aaa, "where `aid` = '{$aid}' and `dateTime` >= '{$startDate}' and `dateTime` <= '{$endDate}'"); if (empty($aaa)) { continue; } foreach ($aaa as $aa) { $dateTime = $aa['dateTime']; $type = $aa[$groupBy]; $clicks = $aa['clicks']; $impressions = $aa['impressions']; $reports['types'][$type] = 1; if (isset($reports[$dateTime][$type])) { $reports[$dateTime][$type]['clicks'] += $clicks; $reports[$dateTime][$type]['impressions'] += $impressions; } else { $reports[$dateTime][$type]['clicks'] = $clicks; $reports[$dateTime][$type]['impressions'] = $impressions; } if (isset($reports[$dateTime][0])) { $reports[$dateTime][0]['clicks'] += $clicks; $reports[$dateTime][0]['impressions'] += $impressions; } else { $reports[$dateTime][0] = array(); $reports[$dateTime][0]['clicks'] = $clicks; $reports[$dateTime][0]['impressions'] = $impressions; } } return $reports; } }