Пример #1
0
 /**
  * returns the matching PostApiClient
  *
  * @author Matthias Pfefferle
  * @param mixed $pCommunity the community name or the community id
  * @param array $pParams
  * @return Object
  */
 public static function factory($pCommunity, $pParams = null)
 {
     // check if $pCommunity is the name or the id
     if (is_numeric($pCommunity)) {
         $lCommunityObject = CommunityTable::getInstance()->retrieveByPk($pCommunity);
         $lCommunity = $lCommunityObject->getCommunity();
     } else {
         $lCommunity = $pCommunity;
     }
     // return matching object
     switch ($lCommunity) {
         case "facebook":
             return new FacebookImportClient();
             break;
         case "twitter":
             return new TwitterImportClient();
             break;
         case "linkedin":
             return new LinkedinImportClient();
             break;
         case "xing":
             return new XingImportClient();
             break;
         case "tumblr":
             return new TumblrImportClient();
             break;
         case "flattr":
             return new FlattrImportClient();
             break;
         default:
             return null;
     }
 }
Пример #2
0
 public function testRetrieveByDomain()
 {
     $result = CommunityTable::retrieveByDomain("google");
     $this->assertTrue(3 <= count($result));
     $lastCommunity = $result[count($result) - 1];
     $this->assertEquals("website", $lastCommunity->getCommunity());
 }
Пример #3
0
 /**
  * get all communitys which support social publishing
  *
  * @author weyandch
  */
 public static function retrieveCommunitysForSocialPublishing()
 {
     $lReturn = array();
     $lCommunityIds = self::retrieveCommunityIdsForSocialPublishing();
     foreach ($lCommunityIds as $id) {
         $lReturn[] = CommunityTable::getInstance()->retrieveByPK($id);
     }
     return $lReturn;
 }
Пример #4
0
$t->ok(!$community4->isAdmin($member1->getId()));
$t->ok($community4->isAdmin($member2->getId()));
$cm1 = Doctrine::getTable('CommunityMember')->retrieveByMemberIdAndCommunityId($member1->getId(), $community4->getId());
$cm1->addPosition('admin');
$cm2 = Doctrine::getTable('CommunityMember')->retrieveByMemberIdAndCommunityId($member2->getId(), $community4->getId());
$cm2->addPosition('admin_confirm');
$cm2->removePosition('admin');
$event = new sfEvent('subject', 'name', array('member' => $member2, 'id' => $community4->getId(), 'is_accepted' => false));
$t->ok($community4->isAdmin($member1->getId()));
$t->ok(!$community4->isAdmin($member2->getId()));
$t->ok(CommunityTable::processAdminConfirm($event));
$t->ok($community4->isAdmin($member1->getId()));
$t->ok(!$community4->isAdmin($member2->getId()));
$event = new sfEvent('subject', 'name', array('member' => $member2, 'id' => 999, 'is_accepted' => false));
$t->ok(!CommunityTable::processAdminConfirm($event));
//------------------------------------------------------------
$t->diag('CommunityTable::processSubAdminConfirm()');
$event = new sfEvent('subject', 'name', array('member' => $member3, 'id' => $community5->getId(), 'is_accepted' => true));
$t->ok(!Doctrine::getTable('CommunityMember')->isSubAdmin($member3->id, $community5->id));
$t->ok(CommunityTable::processSubAdminConfirm($event));
$t->ok(Doctrine::getTable('CommunityMember')->isSubAdmin($member3->id, $community5->id));
$cm = Doctrine::getTable('CommunityMember')->retrieveByMemberIdAndCommunityId($member3->id, $community5->id);
$cm->removeAllPosition();
$cm->addPosition('sub_admin_confirm');
$event = new sfEvent('subject', 'name', array('member' => $member3, 'id' => $community5->getId(), 'is_accepted' => false));
$t->ok(!Doctrine::getTable('CommunityMember')->isSubAdmin($member3->id, $community5->id));
$t->ok(CommunityTable::processSubAdminConfirm($event));
$t->ok(!Doctrine::getTable('CommunityMember')->isSubAdmin($member3->id, $community5->id));
$event = new sfEvent('subject', 'name', array('member' => $member3, 'id' => 999, 'is_accepted' => false));
$t->ok(!CommunityTable::processSubAdminConfirm($event));
Пример #5
0
 public function getCommunity()
 {
     return CommunityTable::getInstance()->retrieveByPk($this->getCommunityId());
 }
Пример #6
0
 public function testGetIdentitysConnectedToOi()
 {
     $lCommunity = CommunityTable::getInstance()->findBy("community", "google");
     $lCommunity = $lCommunity[0];
     $result = OnlineIdentityTable::retrieveByIdentifier("hugo", $lCommunity->getId(), OnlineIdentityTable::TYPE_IDENTITY);
     $this->assertEquals("hugo", $result->getIdentifier());
     $lConnectedIds = OnlineIdentityConTable::getIdentitysConnectedToOi($result->getId());
     $this->assertTrue(is_array($lConnectedIds));
     $this->assertEquals('OnlineIdentity', get_class(OnlineIdentityTable::getInstance()->find($lConnectedIds[0])));
 }
Пример #7
0
 /**
  * get matching community-object
  *
  * @author Matthias Pfefferle
  * @return Community
  */
 public function getCommunity()
 {
     $lCommunity = CommunityTable::getInstance()->retrieveByPk($this->aCommunityId);
     return $lCommunity;
 }
    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();
    }