/**
  * adds some DomainSettings for testing purposes
  */
 private function createDomainSettings($db)
 {
     $ds = new Documents\DomainSettings();
     $ds->setDomain("blog.local");
     $ds->setMute(0);
     $ds->save();
 }
Exemple #2
0
 /**
  * Executes create action
  *
  * @param sfRequest $request A request object
  */
 public function executeCreate(sfWebRequest $request)
 {
     if ($request->isMethod("POST")) {
         $domain_settings_array = $request->getParameter("domain_settings");
         $domain_settings = new Documents\DomainSettings();
         if ($domain_settings_array["domain"]) {
             $domain_settings->setDomain($domain_settings_array["domain"]);
         } else {
             $this->redirect("domain_settings/index");
         }
         if (array_key_exists("enable_ads", $domain_settings_array)) {
             $domain_settings->setEnableAds(true);
         } else {
             $domain_settings->setEnableAds(false);
         }
         if (array_key_exists("ad_displayer", $domain_settings_array)) {
             $domain_settings->setAdDisplayer("hover");
         } else {
             $domain_settings->setAdDisplayer("scroll");
         }
         if (isset($domain_settings_array["mute"]) && is_numeric($domain_settings_array["mute"])) {
             $domain_settings->setMute($domain_settings_array["mute"]);
         }
         $domain_settings->save();
         $this->redirect("domain_settings/index");
     }
 }
    protected function execute($arguments = array(), $options = array())
    {
        try {
            sfContext::getInstance();
        } catch (Exception $e) {
            // aize the database connection
            $configuration = ProjectConfiguration::getApplicationConfiguration($options['application'], $options['env'], true);
            sfContext::createInstance($configuration);
        }
        $databaseManager = new sfDatabaseManager($this->configuration);
        $databaseManager->loadConfiguration();
        $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
        $originalPostToServicesValue = sfConfig::get('app_settings_post_to_services');
        sfConfig::set('app_settings_post_to_services', 0);
        $this->log("Using mongo host: " . sfConfig::get('app_mongodb_host'));
        $lUserHugo = UserTable::retrieveByUsername('hugo');
        $lHugoOis = $lUserHugo->getOnlineIdentitesAsArray();
        $lUserJames = UserTable::retrieveByUsername('james');
        $lJamesOis = $lUserJames->getOnlineIdentitesAsArray();
        $lCommunityTwitter = CommunityTable::retrieveByCommunity('twitter');
        $lCommunityFb = CommunityTable::retrieveByCommunity('facebook');
        $lOiHugoTwitter = OnlineIdentityTable::retrieveByAuthIdentifier('http://twitter.com/account/profile?user_id=21092406', $lCommunityTwitter->getId());
        $lOiJamesFacebook = OnlineIdentityTable::retrieveByAuthIdentifier('james_fb', $lCommunityFb->getId());
        $urls = array('www.snirgel.de', 'notizblog.org', 'www.missmotz.de');
        $tags = array('geekstuff', 'otherthings', 'schuhe');
        $users = array($lUserHugo, $lUserJames);
        $services = array('facebook', 'twitter', 'linkedin', 'google');
        $deals = array('Campaign No. 1', 'Campaign No. 2', 'Campaign No. 3');
        $dm = MongoManager::getDM();
        for ($i = 0; $i < 100; $i++) {
            $url = $this->oneOfThese($urls);
            $tag = $this->oneOfThese($tags);
            $user = $this->oneOfThese($users);
            $cb_ref = $this->oneOfThese(array('', '', '', '', '', '', 'http://tierscheisse.de'));
            $ra = $this->random(1000);
            $theC = mt_rand(strtotime("3 days ago"), strtotime("today"));
            $array = array('url' => "http://{$url}/{$ra}", 'url_hash' => "hash.{$ra}", 'u_id' => $user->getId(), 'oiids' => $user->getOnlineIdentitesAsArray(), 'tags' => $tag . $ra, 'title' => "{$url} title", 'descr' => "{$url} description", 'comment' => "{$url} comment", 'c' => $theC, 'cb' => $this->randBoolean() ? $this->random(30) : 0, 'cb_referer' => $cb_ref != '' ? $cb_ref : null, 'cb_service' => $cb_ref != '' ? $this->oneOfThese($services) : null);
            $lActivity = new Documents\YiidActivity();
            $lActivity->fromArray($array);
            try {
                $lActivity->skipUrlCheck = true;
                $lActivity->save();
            } catch (Exception $e) {
                $this->log($e->getMessage());
            }
        }
        // same for deals
        for ($i = 0; $i < 100; $i++) {
            $url = $this->oneOfThese($urls);
            $tag = $this->oneOfThese($tags);
            $user = $this->oneOfThese($users);
            $cb_ref = $this->oneOfThese(array('', '', '', '', '', '', 'http://tierscheisse.de'));
            $i_url = $this->oneOfThese(array('http://ard.de', 'http://bild.de', 'http://spiegel.de', 'http://tierscheisse.de'));
            $ra = $this->random(1000);
            $theC = mt_rand(strtotime("3 days ago"), strtotime("today"));
            $deal = DealTable::getInstance()->findOneByName($this->oneOfThese($deals));
            $array = array('url' => "http://{$url}/{$ra}", 'url_hash' => "hash.{$ra}", 'u_id' => $user->getId(), 'oiids' => $user->getOnlineIdentitesAsArray(), 'tags' => $tag . $ra, 'title' => "{$url} title", 'descr' => "{$url} description", 'comment' => "{$url} comment", 'c' => $theC, 'd_id' => $deal->getId(), 'cb' => $this->randBoolean() ? $this->random(30) : 0, 'cb_referer' => $cb_ref != '' ? $cb_ref : null, 'i_url' => $i_url, 'cb_service' => $cb_ref != '' ? $this->oneOfThese($services) : null);
            $lActivity = new Documents\YiidActivity();
            $lActivity->fromArray($array);
            try {
                $lActivity->skipUrlCheck = true;
                $lActivity->save();
            } catch (Exception $e) {
                $this->log($e->getMessage());
            }
        }
        $ds = new Documents\DomainSettings();
        $ds->setDomain("blog.local");
        $ds->setMute(0);
        $ds->save();
        $ds = new Documents\DomainSettings();
        $ds->setDomain("pfefferle.org");
        $ds->setDisableAds(true);
        $ds->save();
        $ad = new Documents\Advertisement();
        $ad->setDomains(array("pfefferle.org", "notizblog.org", "www.spiegel.de", "blog.local"));
        $ad->setAdCode('<script type="text/javascript" src="http://a.ligatus.com/?ids=34548&t=js"></script>');
        $ad->setUpdatedAt(strtotime("now"));
        $ad->setStartingAt(strtotime("now"));
        $ad->setAdHeight(500);
        $ad->setAdWidth(50);
        $ad->save();
        $ad = new Documents\Advertisement();
        $ad->setDomains(array("blog.local"));
        $ad->setAdCode("<script type='text/javascript' src='http://imagesrv.adition.com/js/adition.js'></script>\n<script type='text/javascript' src='http://ad4.adfarm1.adition.com/js?wp_id=744125'></script>");
        $ad->setUpdatedAt(strtotime("now"));
        $ad->setStartingAt(strtotime("now"));
        $ad->setAdHeight(100);
        $ad->setAdWidth(800);
        $ad->save();
        $ad = new Documents\Advertisement();
        $ad->setDomains(array("pfefferle.org", "notizblog.org", "www.spiegel.de", "blog.local"));
        $ad->setAdCode('<script type="text/javascript"><!--
  google_ad_client = "ca-pub-1406192967534280";
  /* spreadly */
  google_ad_slot = "7458728780";
  google_ad_width = 250;
  google_ad_height = 250;
  //-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>');
        $ad->setUpdatedAt(strtotime("now"));
        $ad->setStartingAt(strtotime("now"));
        $ad->setAdHeight(250);
        $ad->setAdWidth(250);
        $ad->save();
        /*
        
        $lActivity = new Documents\YiidActivity();
        $lActivity->fromArray($array);
        $lActivity->save();
        
        $array = array(
          'url' => "http://$url",
          'oiids' => array($lOiJamesFacebook->getId()),
          'title' => "$url deal title",
          'descr' => "$url description",
          'comment' => "$url comment",
          'thumb' => null,
          'clickback' => null,
          'tags' => null,
          'u_id' => $lUserJames->getId()
        );
        
        $lActivity = new Documents\YiidActivity();
        $lActivity->fromArray($array);
        $lActivity->save();
        
        if($deal[0]->canApprove()) {
          $deal[0]->approve();
        }
        
        
        $url = 'notizblog.org';
        $array = array(
          'url' => "http://$url",
          'oiids' => array($lOiHugoTwitter->getId()),
          'title' => "$url deal title",
          'descr' => "$url description",
          'comment' => "$url comment",
          'thumb' => null,
          'clickback' => null,
          'tags' => null,
          'u_id' => $lUserHugo->getId()
        );
        
        $lActivity = new Documents\YiidActivity();
        $lActivity->fromArray($array);
        $lActivity->save();
        
        $deal = DealTable::getInstance()->findByDescription('missmotz approved description');
        if($deal[0]->canApprove()) {
          $deal[0]->approve();
        }
        
        $url = 'www.missmotz.de';
        $array = array(
          'url' => "http://$url",
          'oiids' => array($lOiHugoTwitter->getId()),
          'title' => "$url deal title",
          'descr' => "$url description",
          'comment' => "$url comment",
          'thumb' => null,
          'clickback' => null,
          'tags' => "Schuhe, Hemden",
          'u_id' => $lUserHugo->getId()
        );
        
        $lActivity = new Documents\YiidActivity();
        $lActivity->fromArray($array);
        $lActivity->save();
        */
        sfConfig::set('app_settings_post_to_services', $originalPostToServicesValue);
        $this->generateErrorLog();
    }