public static function getActiveApp($user) { $aid = isset($_REQUEST['aid']) ? $_REQUEST['aid'] : null; if ($aid === null) { $domain = App::$SDBDomain; $aaa = array(); foreach (App::$SDBFields as $field => $meta) { $aaa[] = $field; } $uid = $user->id; $where = "where `uid` = '{$uid}' limit 1"; $sdb = SDB::getInstance(); if (!$sdb->select($domain, $aaa, $where, false)) { return null; } $app = new App(); foreach (App::$SDBFields as $field => $meta) { $app->{$field} = $aaa[0][$field]; } $app->id = $aaa[0]['id']; } else { $app = new App($aid); } return $app; }
function delete() { $id = $this->id; // fb("sdbo - delete $this->id"); $domain = $this->getSDBDomain(); $this->sdb = SDB::getInstance(); $fields = array('deleted' => date('Y-m-d')); // Soft delete $this->sdb->put($domain, $id, $fields, true); // $this->sdb->delete($domain, $id); }
public static function getNetworksByAidIndexNid($aid) { $sdb = SDB::getInstance(); $domain = Network::$SDBDomain; $aaa = array(); foreach (Network::$SDBFields as $field => $meta) { $aaa[] = $field; } $where = "where `aid` = '{$aid}'"; if (!$sdb->select($domain, $aaa, $where)) { return null; } $appNetworks = array(); foreach ($aaa as $aa) { $appNetwork = new Network(); foreach (Network::$SDBFields as $field => $meta) { $appNetwork->{$field} = $aa[$field]; } $appNetwork->id = $aa['id']; $appNetwork->postGet(); $appNetworks[$appNetwork->id] = $appNetwork; } return $appNetworks; }
public static function getAppHouseAdsByCid($cid) { $sdb = SDB::getInstance(); $domain = self::$SDBDomain; $aaa = array(); foreach (self::$SDBFields as $field => $meta) { $aaa[] = $field; } $where = "where `cid` = '{$cid}'"; if (!$sdb->select($domain, $aaa, $where)) { return null; } $appHouseAds = array(); foreach ($aaa as $aa) { $id = $aa['id']; $appHouseAd = new AppHouseAd($id); if ($appHouseAd != null) { $appHouseAds[] = $appHouseAd; } } return $appHouseAds; }
public static function getAppsByCid($cid) { $sdb = SDB::getInstance(); $domain = self::$SDBDomain_JOIN_AID; $aaa = array(); foreach (self::$SDBFields_JOIN_AID as $field => $meta) { $aaa[] = $field; } $where = "where `cid` = '{$cid}'"; if (!$sdb->select($domain, $aaa, $where)) { return null; } $apps = array(); foreach ($aaa as $aa) { $aid = $aa['aid']; $weight = $aa['weight']; $app = new App($aid); if ($app != null) { $apps[] = $app; } } return $apps; }
protected function getDBConnect() { if ($this->_connect) { return $this->_connect; } $db = new SDB(); $this->_connect = $db->getInstance(); return $this->_connect; }
public function createSubmit() { if (isset($_REQUEST['n_aid']) || !isset($_REQUEST['name'])) { $this->redirect('/apps/apps'); } $this->printHeader = false; $this->printFooter = false; $name = $_POST['name']; $storeUrl = $_POST['storeUrl']; $platform = $_POST['platform']; $fgColor = $_POST['fgColor']; $bgColor = $_POST['bgColor']; $cycleTime = $_POST['cycleTime']; $transition = $_POST['transition']; $locationOn = $_POST['locationOn']; $app = new App(); $app->id = SDB::uuid(); $app->uid = $this->user->id; $app->name = $name; $app->storeUrl = $storeUrl; $app->platform = $platform; $app->fgColor = $fgColor; $app->bgColor = $bgColor; $app->cycleTime = $cycleTime; $app->transition = $transition; $app->locationOn = $locationOn; $app->adsOn = 1; $app->put(); $_POST['aid'] = $app->id; // before finishing, check to see if the new app has been added to th SDB $sdb = SDB::getInstance(); // sleeps for half a second until we see an entry for this id $fields = "name"; while (!$sdb->get($app->getSDBDomain(), $app->id, $fields)) { $fields = "name"; // necessary since get overwrites $fields usleep(500); } }
public static function confirmUser($uid) { $sdb = SDB::getInstance(); $aaa = array('email', 'firstName', 'lastName', 'password', 'allowEmail'); $sdb->select(self::$DOMAIN_USERS_UNVERIFIED, $aaa, "where itemName() = '{$uid}' limit 1", false); if (empty($aaa[0])) { return false; } $user = new User(); $user->id = $uid; $user->email = $aaa[0]['email']; $user->password = $aaa[0]['password']; $user->allowEmail = $aaa[0]['allowEmail']; $user->firstName = $aaa[0]['firstName']; $user->lastName = $aaa[0]['lastName']; $user->put(); return true; }
public static function invalidateCustom($nid) { $sdb = SDB::getInstance(); $aa = array('dateTime' => gmdate('Y-m-d, H:i:s')); $sdb->put(HouseAd::$SDBDomainInvalid, $nid, $aa, true); }
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; } }