public function verify() { $count = $this->getVerificationCount(); $this->setVerificationCount($count + 1); $microids = $this->getMicroIdsFromDomain(); $verified = DomainProfile::ERROR_VERIFICATION; if (is_array($microids)) { if (count($microids) > 0) { foreach ($microids as $microid) { if ($microid === $this->getVerificationToken()) { $verified = true; } } if ($verified === true) { $this->setState('verified'); } else { $verified = DomainProfile::ERROR_INVALID_MICROID; } } else { $verified = DomainProfile::ERROR_NO_MICROID; } } else { $verified = DomainProfile::ERROR_INVALID_URL; } $this->save(); if ($this->getState() == DomainProfileTable::STATE_VERIFIED) { DomainProfileTable::getInstance()->deleteUnverified(); } return $verified; }
public function executeListExportCsv(sfWebRequest $request) { $this->pDomainProfiles = DomainProfileTable::getInstance()->createQuery()->orderBy('created_at DESC')->execute(); $this->pOtherUsers = sfGuardUserTable::getInstance()->createQuery()->from('SfGuardUser s')->leftJoin('s.DomainProfiles d')->where('d.id IS NULL')->execute(); $this->setLayout('csv'); $this->getResponse()->clearHttpHeaders(); $this->getResponse()->setHttpHeader("Content-Type", 'text/plain'); $this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename=DomainProfiles-' . date("Y-m-d") . '.txt;'); }
public function executeCredentials(sfWebRequest $request) { $domainId = $request->getParameter("domainid"); if (!$domainId) { $dealId = $request->getParameter("deal_id"); $deal = DealTable::getInstance()->find($dealId); $domainId = $deal->getDomainProfileId(); } $this->domainProfile = DomainProfileTable::getInstance()->find($domainId); }
public function getNextFromPool($pUser, $pDomain = null) { $nextDeal = $domainProfile = null; if ($pDomain && ($domainProfile = DomainProfileTable::getInstance()->retrieveByUrl($pDomain))) { $nextDeal = $this->findNextFromPool($pUser, $domainProfile); } if (!$nextDeal) { $nextDeal = $this->findNextFromPool($pUser); } if ($nextDeal) { $nextDeal->setPoolHits($nextDeal->getPoolHits() + 1); $nextDeal->save(); } return $nextDeal; }
/** * initialize variables and check authentication * * (non-PHPdoc) * @see cache/frontend/prod/config/sfAction#initialize() */ public function preExecute() { $request = $this->getRequest(); sfContext::getInstance()->getConfiguration()->loadHelpers('Date'); $this->pDomainProfileId = $request->getParameter('domainid', null); // check if user is allowed to see the statistics page if ($this->pDomainProfileId) { $this->pDomainProfile = DomainProfileTable::getInstance()->find($this->pDomainProfileId); $this->forward404Unless($this->pDomainProfile && $this->pDomainProfile->getSfGuardUserId() == $this->getUser()->getUserId()); } $this->pAggregation = $request->getParameter('aggregation', 'daily'); $this->pDateFrom = $request->getParameter('date-from', date('Y-m-d', strtotime("6 days ago"))); $this->pDateTo = $request->getParameter('date-to', date('Y-m-d')); $this->pCommunity = $request->getParameter('com', 'all'); $this->pUrl = str_replace(" ", "+", urldecode($request->getParameter('url', null))); $this->pType = $request->getParameter('type', 'url_activities'); }
public function executeCreate_deal_form(sfWebRequest $request) { $lI18n = sfContext::getInstance()->getI18N(); $lDealId = $this->pDealId; $lDeal = null; if ($lDealId) { $lDeal = DealTable::getInstance()->find($lDealId); $lDealForm = new DealForm($lDeal); $lFirstDomain = DomainProfileTable::getInstance()->find($lDeal->getDomainProfileId()); $this->pFirstDomain = $lFirstDomain; } else { $lDealForm = new DealForm(); $lVerifiedDomains = DomainProfileTable::retrieveVerifiedForUser($this->getUser()->getGuardUser()); $lFirstDomain = $lVerifiedDomains[1]; } $this->pAddtags = 'addnotags'; if ($lDeal) { $this->pCouponType = $lDeal->getCouponType(); $this->pCouponQuantity = $lDeal->getCouponQuantity(); $this->pTags = $lDeal->getTags(); if ($this->pTags != null && $this->pTags != '') { $this->pAddtags = 'addtags'; } $this->pDeal = $lDeal; $lDealForm->setDefaults(array('id' => $lDeal->getId(), 'terms_of_deal' => $lDeal->getTermsOfDeal(), 'button_wording' => $lDeal->getButtonWording(), 'summary' => $lDeal->getSummary(), 'description' => $lDeal->getDescription(), 'terms_of_deal' => $lDeal->getTermsOfDeal(), 'start_date' => $lDeal->getStartDate(), 'end_date' => $lDeal->getEndDate(), 'coupon_quantity' => $lDeal->getCouponQuantity(), 'coupon_type' => $this->pCouponType, 'redeem_url' => $lDeal->getRedeemUrl(), 'tos_accepted' => $lDeal->getTosAccepted(), 'addtags' => $this->pAddtags, 'tags' => $this->pTags)); $lCoupons = $lDeal->getCoupons(); if (count($lCoupons) > 0) { $this->pDefaultCode = $lCoupons[0]->getCode(); } else { $this->pDefaultCode = $lI18n->__('Coupon Code'); } } else { $this->pCouponType = 'single'; $this->pCouponQuantity = '0'; $this->pEdited = false; $lDealForm->setDefaults(array('button_wording' => $lI18n->__('...and win a free trial membership!'), 'summary' => $lI18n->__('Free trial membership'), 'description' => $lI18n->__('Like and win a free one month trial membership'), 'terms_of_deal' => $lI18n->__('Url to Conditions of Participation'), 'start_date' => date('Y-m-d G:i:s'), 'end_date' => date('Y-m-d G:i:s'), 'coupon_type' => 'single', 'addtags' => 'addnotags', 'redeem_url' => $lI18n->__('Your redeem url'))); $this->pDefaultCode = 'Coupon Code'; } $this->pForm = new DomainProfileDealForm(); $this->pForm->setDefaults(array('id' => $lFirstDomain->getId())); $lCouponForm = new CouponCodesForm(); $lCouponForm->setDefaults(array('single_code' => $this->pDefaultCode)); $lDealForm->embedForm('coupon', $lCouponForm); //if single: getcode, if multiple: getcodes $this->pForm->embedForm('deal', $lDealForm); }
public static function verify() { $context = sfContext::getInstance(); $domainid = $context->getRequest()->getParameter("domainid"); if (!$domainid) { $dealid = $context->getRequest()->getParameter("deal_id"); $deal = DealTable::getInstance()->find($dealid); $domainid = $deal->getDomainProfileId(); } $domainProfile = DomainProfileTable::getInstance()->find($domainid); if ($domainProfile && $domainProfile->getSfGuardUserId() == $context->getUser()->getUserId() && $domainProfile->getDetailedAnalytics()) { return; } else { $context->getController()->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); throw new sfStopException(); } }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $lUrl = $request->getParameter("url", null); $lUrl = UrlUtils::narmalizeUrlScheme($lUrl); $request->setParameter("url", $lUrl); $this->url = $lUrl; $this->error = $this->pError = null; if (!$lUrl) { return $this->setTemplate("share"); } if ($request->getMethod() == "POST") { $lParams = $request->getParameter('like'); $lParams['u_id'] = $this->getUser()->getUserId(); $lActivity = new Documents\YiidActivity(); $lActivity->fromArray($lParams); // try to save activity try { $lActivity->save(); $this->redirect("@deal?url=" . urlencode($lUrl)); } catch (Exception $e) { // send error on exception $this->getLogger()->err($e->getMessage()); $this->pError = $e->getMessage(); } } $dm = MongoManager::getDM(); $this->pActivity = $dm->getRepository("Documents\\YiidActivity")->findOneBy(array("url" => $lUrl, "u_id" => intval($this->getUser()->getId()), "d_id" => array('$exists' => false))); // if user has already liked if ($this->pActivity) { $this->redirect("@deal?url=" . urlencode($lUrl)); } $lYiidMeta = new YiidMeta(); $lYiidMeta->fromParams($request->getParameterHolder()); $this->pYiidMeta = SocialObjectParser::fetch($request->getParameter("url"), $lYiidMeta); if ($this->pYiidMeta === false) { $this->error = "the url '{$lUrl}' is not well formed!"; return $this->setTemplate("share"); } $domainProfile = DomainProfileTable::getInstance()->retrieveByUrl($lUrl); $this->trackingUrl = null; if ($domainProfile) { $this->trackingUrl = $domainProfile->getTrackingUrl(); } $this->getResponse()->setSlot('js_document_ready', $this->getPartial('like/js_init_like.js', array('pImgCount' => count($this->pYiidMeta->getImages()), 'pUrl' => $request->getParameter("url")))); }
public function executeAdd_flattr(sfWebRequest $request) { $this->info = $this->error = null; $host_id = $request->getParameter("host_id", null); if (!$host_id) { $this->redirect('domain_profiles/index'); } $domainProfile = DomainProfileTable::getInstance()->find($host_id); if ($request->getMethod() == "POST") { $flattr_account = $request->getParameter("flattr_account", null); if (trim($flattr_account)) { if (UrlUtils::checkUrlAvailability("http://flattr.com/submit/auto?url=" . urlencode($domainProfile->getDomain()) . "&flattr_id=" . $flattr_account)) { $domainProfile->setFlattrAccount($flattr_account); $domainProfile->save(); $this->info = "flattr-account successfully added."; } else { $this->error = "URL is not valid."; } } else { $domainProfile->setFlattrAccount(null); $domainProfile->save(); $this->info = "flattr-account deleted."; } } $this->domainProfile = $domainProfile; }
/** * component for description * * @author KM, HS * * @param sfWebRequest $request */ public function executeChart_column_mediapenetration_clickbacks(sfWebRequest $request) { $lDomainProfile = DomainProfileTable::getInstance()->find($this->pHostId); $this->pData = MongoUtils::getMediaPenetrationData($lDomainProfile->getUrl(), $this->pDateFrom, $this->pDateTo, $this->pAggregation); }
<th class="sf_admin_text">E-Mail</td> <th class="sf_admin_text">Likes</td> <th class="sf_admin_text">Price</td> </tr> </thead> <tbody> <?php foreach ($commissions as $commission) { ?> <tr class="sf_admin_row odd"> <td class="sf_admin_text"><?php echo DomainProfileTable::getInstance()->find($commission['domain_profile_id'])->getDomain(); ?> </td> <td class="sf_admin_text"><?php echo DomainProfileTable::getInstance()->find($commission['domain_profile_id'])->getSfGuardUser()->getEmailAddress(); ?> </td> <td class="sf_admin_text"><?php echo $commission['count']; ?> </td> <td class="sf_admin_text"><?php echo round($commission['sum'], 2, PHP_ROUND_HALF_UP); ?> €</td> </tr> <?php } ?> </tbody>
public function executeGet_domain_profile(sfWebRequest $request) { $this->getResponse()->setContentType('application/json'); $lProfileId = $request->getParameter('dpid'); $lDp = DomainProfileTable::getInstance()->find($lProfileId); //if u need much more from the object return a ldp->toarray jsonfied to the js return $this->renderText(json_encode($lReturn)); }
public function executeShare_section(sfWebRequest $request) { $this->pIdentities = OnlineIdentityTable::getPublishingEnabledByUserId($this->getUser()->getUserId()); $this->domain_profile = DomainProfileTable::getInstance()->retrieveByUrl($request->getParameter("url", null)); }
private function calc($range, $lastRange) { $data = array(); $data['current_user_count'] = UserTable::getInstance()->countByRange($range[0], $range[1]); $data['last_user_count'] = UserTable::getInstance()->countByRange($lastRange[0], $lastRange[1]); $data['user_count_delta'] = $this->delta($data['current_user_count'], $data['last_user_count']); $data['current_stats_user_count'] = SfGuardUserTable::getInstance()->countByRange($range[0], $range[1]); $data['last_stats_user_count'] = SfGuardUserTable::getInstance()->countByRange($lastRange[0], $lastRange[1]); $data['stats_user_count_delta'] = $this->delta($data['current_stats_user_count'], $data['last_stats_user_count']); $data['current_likes_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countByRange($range[0], $range[1]); $data['last_likes_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countByRange($lastRange[0], $lastRange[1]); $data['likes_count_delta'] = $this->delta($data['current_likes_count'], $data['last_likes_count']); $data['current_cbl_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countCBLByRange($range[0], $range[1]); $data['last_cbl_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countCBLByRange($lastRange[0], $lastRange[1]); $data['cbl_count_delta'] = $this->delta($data['current_cbl_count'], $data['last_cbl_count']); $data['current_domain_count'] = DomainProfileTable::getInstance()->countByRange($range[0], $range[1]); $data['last_domain_count'] = DomainProfileTable::getInstance()->countByRange($lastRange[0], $lastRange[1]); $data['domain_count_delta'] = $this->delta($data['current_domain_count'], $data['last_domain_count']); $data['current_verified_domain_count'] = DomainProfileTable::getInstance()->countVerifiedByRange($range[0], $range[1]); $data['last_verified_domain_count'] = DomainProfileTable::getInstance()->countVerifiedByRange($lastRange[0], $lastRange[1]); $data['verified_domain_count_delta'] = $this->delta($data['current_verified_domain_count'], $data['last_verified_domain_count']); $data['current_stats'] = MongoManager::getStatsDm()->getRepository('Documents\\AnalyticsActivity')->findOnlyByRange($range[0], $range[1]); $data['last_stats'] = MongoManager::getStatsDm()->getRepository('Documents\\AnalyticsActivity')->findOnlyByRange($lastRange[0], $lastRange[1]); $data['current_stats'] = $data['current_stats'] && $data['current_stats']->hasNext() ? $data['current_stats']->getNext() : null; $data['last_stats'] = $data['last_stats'] && $data['last_stats']->hasNext() ? $data['last_stats']->getNext() : null; $data['current_clickback_count'] = $data['current_stats'] ? $data['current_stats']['value']['cb'] : 0; $data['last_clickback_count'] = $data['last_stats'] ? $data['last_stats']['value']['cb'] : 0; $data['clickback_count_delta'] = $this->delta($data['current_clickback_count'], $data['last_clickback_count']); $data['current_media_penetration_count'] = $data['current_stats'] ? $data['current_stats']['value']['mp'] : 0; $data['last_media_penetration_count'] = $data['last_stats'] ? $data['last_stats']['value']['mp'] : 0; $data['media_penetration_count_delta'] = $this->delta($data['current_media_penetration_count'], $data['last_media_penetration_count']); $data['share_distribution'] = $data['current_stats'] ? array($data['current_stats']['value']['s']['facebook'] ? $data['current_stats']['value']['s']['facebook']['l'] : 0, $data['current_stats']['value']['s']['twitter'] ? $data['current_stats']['value']['s']['twitter']['l'] : 0, $data['current_stats']['value']['s']['linkedin'] ? $data['current_stats']['value']['s']['linkedin']['l'] : 0, $data['current_stats']['value']['s']['google'] ? $data['current_stats']['value']['s']['google']['l'] : 0) : array(0, 0, 0, 0); $data['share_distribution_labels'] = array('Fb:' . $data['share_distribution'][0], 'Tw:' . $data['share_distribution'][1], 'Li:' . $data['share_distribution'][2], 'Go:' . $data['share_distribution'][3]); if ($this->range == 'today' || $this->range == 'yesterday') { $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\ActivityStats")->findByRangeGroupByDay($range[0], $range[1]); $h = null; if ($lActivityStats && $lActivityStats->hasNext()) { $temp = $lActivityStats->getNext(); $h = $temp['value']['h']; unset($h['php_ckuf']); } $data['current_likes_range'] = $h ? $h : array(); $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\DealStats")->findByRangeGroupByDay($range[0], $range[1]); $h = null; if ($lActivityStats && $lActivityStats->hasNext()) { $temp = $lActivityStats->getNext(); $h = $temp['value']['h']; unset($h['php_ckuf']); } $data['current_deals_range'] = $h ? $h : array(); } else { $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\ActivityStats")->findLikesByRangeGroupByDay($range[0], $range[1]); if ($lActivityStats) { $lActivityStats = $lActivityStats->toArray(); $data['current_likes_range'] = array_values($this->padLikes($lActivityStats, date('c', $range[0]), date('c', $range[1]))); $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\DealStats")->findLikesByRangeGroupByDay($range[0], $range[1]); $lActivityStats = $lActivityStats->toArray(); $data['current_deals_range'] = array_values($this->padLikes($lActivityStats, date('c', $range[0]), date('c', $range[1]))); } } $data['top_users'] = array_slice(MongoManager::getStatsDm()->getRepository("Documents\\AnalyticsActivity")->groupByUsers($range[0], $range[1]), 0, 5); $data['top_hosts'] = array_slice(MongoManager::getStatsDm()->getRepository("Documents\\AnalyticsActivity")->groupByHosts($range[0], $range[1]), 0, 5); $data['top_urls'] = array_slice(MongoManager::getStatsDm()->getRepository("Documents\\AnalyticsActivity")->groupByUrls($range[0], $range[1]), 0, 5); //$cb = new Chartbeat(); //$data['current_popup_visitors_count'] = $cb->getVisitorsByDate($this->range); $data['current_pi_count'] = intval(VisitTable::countPisForDay($range[0])); $data['last_pi_count'] = intval(VisitTable::countPisForDay($lastRange[0])); $data['pi_count_delta'] = $this->delta($data['current_pi_count'], $data['last_pi_count']); $data['current_conversion'] = $this->conversion($data['current_likes_count'], $data['current_pi_count']); $data['last_conversion'] = $this->conversion($data['last_likes_count'], $data['last_pi_count']); $data['conversion_delta'] = $this->delta($data['current_conversion'], $data['last_conversion']); return $data; }
public static function retrieveAllForUser($pUser) { $lQ = DomainProfileTable::getInstance()->createQuery()->where('sf_guard_user_id = ?', array($pUser->getId()))->orderBy('created_at DESC'); return $lQ->execute(); }
if ($pDeal->getType() == 'publisher') { ?> <li><span class="title"><?php echo __('Art des Deals'); ?> :</span><?php echo __("Domain-Deal"); ?> </li> <li class="last"><span class="title"> <?php echo __('Domain'); ?> :</span> <?php $lDp = DomainProfileTable::getInstance()->find($pDeal->getDomainProfileId()); ?> <?php echo $lDp->getUrl(); ?> </li> <?php } elseif ($pDeal->getType() == 'tags') { ?> <li><span class="title"><?php echo __('Art des Deals'); ?> :</span><?php echo __("Tag-Deal"); ?> </li>