public static function fromOnlineIdentityId($id) { $lOnlineIdentity = OnlineIdentityTable::getInstance()->find($id); $client = self::getClientByCommunityName($lOnlineIdentity->getCommunity()->getCommunity()); $client->setOnlineIdentity($lOnlineIdentity); return $client; }
public function executeDelete_identity(sfWebRequest $request) { $id = $request->getParameter("id"); $online_identity = OnlineIdentityTable::retrieveVerifiedById($this->getUser()->getId(), $id); if (!$online_identity) { $this->getUser()->setFlash("error", "you can't delete this online-identity, perhaps it is not yours"); $this->redirect("profile/index"); } try { $online_identity->delete(); } catch (Exception $e) { $this->getUser()->setFlash("error", $e->getMessage()); $this->redirect("profile/index"); } $this->redirect("profile/index"); }
/** * add identifier * * @author Matthias Pfefferle * @param User $pUser * @param AuthToken $pAuthToken * @return OnlineIdentity */ public function addIdentifier($user, $pOAuthToken) { $lAccessToken = $this->getAccessToken($pOAuthToken); //var_dump($lAccessToken);die(); // get params $lParams = $lAccessToken->params; $lParamsArray = array(); // extract params parse_str($lParams, $lParamsArray); //$lConsumer = new OAuthConsumer(sfConfig::get("app_linkedin_oauth_token"), sfConfig::get("app_linkedin_oauth_secret")); $json = OAuthClient::post($this->getConsumer(), $lParamsArray['oauth_token'], $lParamsArray['oauth_token_secret'], "http://api.tumblr.com/v2/user/info"); $json = json_decode($json, true); foreach ($json['response']['user']['blogs'] as $blog) { $user_name = $blog['name']; $auth_identifier = "http://" . $user_name . ".tumblr.com"; // ask for online identity $online_identity = OnlineIdentityTable::retrieveByAuthIdentifier($auth_identifier); // check if user already exists if ($online_identity) { if ($online_identity->getUserId() && $user->getId() == $online_identity->getUserId()) { if (!$online_identity->getActive()) { $online_identity->setActive(true); } else { //throw new sfException("online identity already added", 1); continue; } } elseif ($online_identity->getUserId() && $user->getId() != $online_identity->getUserId()) { //throw new sfException("online identity already added by someone else", 2); continue; } } else { // check online identity $online_identity = OnlineIdentityTable::addOnlineIdentity($auth_identifier, $user_name, $this->aCommunityId); } $this->completeOnlineIdentity($online_identity, $blog, $user, $auth_identifier); // save new token AuthTokenTable::saveToken($user->getId(), $online_identity->getId(), $lParamsArray['oauth_token'], $lParamsArray['oauth_token_secret'], true); } return $user; }
/** * updates an auth-token * * @author Matthias Pfefferle * @param int $pUserId * @param int $pOnlineIdentityId * @param string $pToken * @param string $pTokenSecret * @param boolean $pActive * @return AuthToken */ public static function saveToken($pUserId, $pOnlineIdentityId, $pToken, $pTokenSecret, $pActive = false) { if ($lCheck = self::getByUserAndOnlineIdentity($pUserId, $pOnlineIdentityId)) { $lToken = $lCheck; } else { $lToken = new AuthToken(); } if ($pActive && $pOnlineIdentityId) { $lIdentity = OnlineIdentityTable::getInstance()->retrieveByPK($pOnlineIdentityId); $lIdentity->save(); } $lToken->setTokenKey($pToken); $lToken->setOnlineIdentityId($pOnlineIdentityId); // get online-identity $lOnlineIdentity = OnlineIdentityTable::getInstance()->find($pOnlineIdentityId); $lToken->setCommunityId($lOnlineIdentity->getCommunityId()); $lToken->setTokenType(self::TOKEN_TYPE_OAUTH); $lToken->setTokenSecret($pTokenSecret); $lToken->setUserId($pUserId); $lToken->save(); return $lToken; }
<?php echo OnlineIdentityTable::getInstance()->find($e->getOiId())->getProfileUri(); ?> <?php if ($user && $user->getEmail()) { echo "<br />" . $user->getEmail(); } ?> </small> <h3> <strong><em><?php echo $user ? $user->getFullname() : 'n/a'; ?> </em></strong>s <strong><em><?php echo OnlineIdentityTable::getInstance()->find($e->getOiId())->getCommunity()->getName(); ?> </em></strong>-account has hiccups </h3> <p>Error: {<?php echo $e->getCode(); ?> } <?php echo $e->getMessage(); ?> </p> </li> <?php } ?> </ul>
/** * returns a list of OI's we need for the query * @param int $pUserId * @param int $pFriendId */ public static function getRelevantOnlineIdentityIdsForQuery($pUserId, $pFriendId) { $pOiArray = array(); if (is_null($pFriendId)) { // get own items and items of all friends $pOiArray = self::getIdsOfFriendsByUserId($pUserId); $pOiArray = array_merge($pOiArray, OnlineIdentityTable::retrieveIdsByUserId($pUserId)); } else { // get all items from a specific friend $pOiArray = OnlineIdentityTable::retrieveIdsByUserId($pFriendId); } return $pOiArray; }
/** * add identifier * * @author Matthias Pfefferle * @param User $pUser * @param AuthToken $pAuthToken * @return OnlineIdentity */ public function addIdentifier($user, $pOAuthToken) { $lAccessToken = $this->getAccessToken($pOAuthToken); // get params $lParams = $lAccessToken->params; $lParamsArray = array(); // extract params parse_str($lParams, $lParamsArray); $json = OAuthClient::get($this->getConsumer(), $lParamsArray['oauth_token'], $lParamsArray['oauth_token_secret'], "https://api.xing.com/v1/users/me"); $json = json_decode($json, true); $xing_user = $json['users'][0]; $auth_identifier = $xing_user["permalink"]; // ask for online identity $online_identity = OnlineIdentityTable::retrieveByOriginalId($xing_user['id'], $this->getCommunity()->getid()); // check if user already exists if ($online_identity) { if ($online_identity->getUserId() && $user->getId() == $online_identity->getUserId()) { if (!$online_identity->getActive()) { $online_identity->setActive(true); } else { throw new sfException("online identity already added", 1); } } elseif ($online_identity->getUserId() && $user->getId() != $online_identity->getUserId()) { throw new sfException("online identity already added by someone else", 2); } } else { // check online identity $online_identity = OnlineIdentityTable::addOnlineIdentity($auth_identifier, $xing_user['id'], $this->aCommunityId); } $this->completeOnlineIdentity($online_identity, $xing_user, $user, $auth_identifier); // save new token AuthTokenTable::saveToken($user->getId(), $online_identity->getId(), $lParamsArray['oauth_token'], $lParamsArray['oauth_token_secret'], true); return $user; }
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]))); }
/** * add identifier * * @author Matthias Pfefferle * @param User $pUser * @param AuthToken $pAuthToken * @return OnlineIdentity */ public function addIdentifier($pUser, $pCode) { $lAccessToken = $this->getAccessToken($pCode); // get params $lParamsArray = array(); // extract params parse_str($lAccessToken, $lParamsArray); $lJsonObject = json_decode(UrlUtils::sendGetRequest("https://graph.facebook.com/me?access_token=" . $lParamsArray['access_token'] . "&locale=en_US")); // facebook identifier $lIdentifier = "http://www.facebook.com/profile.php?id=" . $lJsonObject->id; // ask for online identity $lOnlineIdentity = OnlineIdentityTable::retrieveByAuthIdentifier($lIdentifier); // check if user already exists if ($lOnlineIdentity) { if ($lOnlineIdentity->getUserId() && $pUser->getId() == $lOnlineIdentity->getUserId()) { if (!$lOnlineIdentity->getActive()) { $lOnlineIdentity->setActive(true); } else { throw new sfException("online identity already added", 1); } } elseif ($lOnlineIdentity->getUserId() && $pUser->getId() != $lOnlineIdentity->getUserId()) { throw new sfException("online identity already added by someone else", 2); } } else { // check online identity $lOnlineIdentity = OnlineIdentityTable::addOnlineIdentity($lJsonObject->link, $lJsonObject->id, $this->aCommunityId); } // use api complete informations $this->completeOnlineIdentity($lOnlineIdentity, $lJsonObject, $pUser, $lIdentifier); // signup,add new AuthTokenTable::saveToken($pUser->getId(), $lOnlineIdentity->getId(), $lParamsArray['access_token'], null, true); // signup,add new return $lOnlineIdentity; }
/** * add identifier * * @author Matthias Pfefferle * @param User $pUser * @param AuthToken $pAuthToken * @return OnlineIdentity */ public function addIdentifier($pUser, $pCode) { $lAccessToken = $this->getAccessToken($pCode); // get params $lParamsArray = array(); // extract params $lAccessToken = json_decode($lAccessToken, true); $lJsonObject = json_decode(UrlUtils::sendGetRequest("https://api.flattr.com/rest/v2/user", array("Authorization: Bearer " . $lAccessToken["access_token"]))); // facebook identifier $lIdentifier = $lJsonObject->link; // ask for online identity $lOnlineIdentity = OnlineIdentityTable::retrieveByAuthIdentifier($lIdentifier); // check if user already exists if ($lOnlineIdentity) { if ($lOnlineIdentity->getUserId() && $pUser->getId() == $lOnlineIdentity->getUserId()) { if (!$lOnlineIdentity->getActive()) { $lOnlineIdentity->setActive(true); } else { throw new sfException("online identity already added", 1); } } elseif ($lOnlineIdentity->getUserId() && $pUser->getId() != $lOnlineIdentity->getUserId()) { throw new sfException("online identity already added by someone else", 2); } } else { // check online identity $lOnlineIdentity = OnlineIdentityTable::addOnlineIdentity($lJsonObject->link, $lJsonObject->username, $this->aCommunityId, $lIdentifier); } // use api complete informations $this->completeOnlineIdentity($lOnlineIdentity, $lJsonObject, $pUser, $lIdentifier); // signup,add new AuthTokenTable::saveToken($pUser->getId(), $lOnlineIdentity->getId(), $lAccessToken["access_token"], null, true); // signup,add new return $lOnlineIdentity; }
public function executeShare_section(sfWebRequest $request) { $this->pIdentities = OnlineIdentityTable::getPublishingEnabledByUserId($this->getUser()->getUserId()); $this->domain_profile = DomainProfileTable::getInstance()->retrieveByUrl($request->getParameter("url", null)); }
/** * wrapper for publishing tokens * @param int $pUserId */ public static function getTokensForPublishingByUserId($pUserId) { return OnlineIdentityTable::getPublishingEnabledByUserId($pUserId); }
private static function fillServices($pYiidActivity) { $services = array(); foreach ($pYiidActivity->getOiids() as $lId) { $lOi = OnlineIdentityTable::getInstance()->retrieveByPk($lId); if ($lOi) { $service = self::fillService($pYiidActivity, $lOi); $services[strtolower($lOi->getCommunity()->getCommunity())] = $service; } } return $services; }
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(); }
public function getIdsOfFriends() { return OnlineIdentityTable::getUserIdsOfFriendsByUserId($this->getId()); }
/** * add identifier * * @author Matthias Pfefferle * @param User $pUser * @param AuthToken $pAuthToken * @return OnlineIdentity */ public function addIdentifier($pUser, $pOAuthToken) { $lAccessToken = $this->getAccessToken($pOAuthToken); // get params $lParams = $lAccessToken->params; $lParamsArray = array(); // extract params parse_str($lParams, $lParamsArray); // twitter identifier $lIdentifier = "http://twitter.com/account/profile?user_id=" . $lParamsArray['user_id']; // ask for online identity $lOnlineIdentity = OnlineIdentityTable::retrieveByAuthIdentifier($lIdentifier); // check if user already exists if ($lOnlineIdentity) { if ($lOnlineIdentity->getUserId() && $pUser->getId() == $lOnlineIdentity->getUserId()) { if (!$lOnlineIdentity->getActive()) { $lOnlineIdentity->setActive(true); } else { throw new sfException("online identity already added", 1); } } elseif ($lOnlineIdentity->getUserId() && $pUser->getId() != $lOnlineIdentity->getUserId()) { throw new sfException("online identity already added by someone else", 2); } } else { // check online identity $lOnlineIdentity = OnlineIdentityTable::addOnlineIdentity("http://twitter.com/" . $lParamsArray['screen_name'], $lParamsArray['user_id'], $this->aCommunityId); } // get api informations $lJson = OAuthClient::get($this->getConsumer(), $lParamsArray['oauth_token'], $lParamsArray['oauth_token_secret'], "https://api.twitter.com/1.1/users/show.json?user_id=" . $lParamsArray['user_id']); $lJsonObject = json_decode($lJson); $this->completeOnlineIdentity($lOnlineIdentity, $lJsonObject, $pUser, $lIdentifier); AuthTokenTable::saveToken($pUser->getId(), $lOnlineIdentity->getId(), $lParamsArray['oauth_token'], $lParamsArray['oauth_token_secret'], true); return $lOnlineIdentity; }
/** * add identifier * * @author Matthias Pfefferle * @param User $pUser * @param AuthToken $pAuthToken * @return OnlineIdentity */ public function addIdentifier($pUser, $pOAuthToken) { $lAccessToken = $this->getAccessToken($pOAuthToken); // get api informations $lJson = OAuthClient::get($this->getConsumer(), $lParamsArray['oauth_token'], $lParamsArray['oauth_token_secret'], "http://api.yigg.local/profiles/me"); $lJsonObject = json_decode($lJson); // ask for online identity $lOnlineIdentity = OnlineIdentityTable::retrieveByOriginalId($lJsonObject->id, $this->aCommunityId); // check if user already exists if ($lOnlineIdentity) { if ($lOnlineIdentity->getUserId() && $pUser->getId() == $lOnlineIdentity->getUserId()) { if (!$lOnlineIdentity->getActive()) { $lOnlineIdentity->setActive(true); } else { throw new sfException("online identity already added", 1); } } elseif ($lOnlineIdentity->getUserId() && $pUser->getId() != $lOnlineIdentity->getUserId()) { throw new sfException("online identity already added by someone else", 2); } } else { // get auth identifier foreach ($lJsonObject->urls as $url) { if ($url['type'] == "profile") { $lIdentifier = $url['value']; } } // check online identity $lOnlineIdentity = OnlineIdentityTable::addOnlineIdentity($lIdentifier, $lJsonObject->id, $this->aCommunityId); } $this->completeOnlineIdentity($lOnlineIdentity, $lJsonObject, $pUser, $lIdentifier); AuthTokenTable::saveToken($pUser->getId(), $lOnlineIdentity->getId(), $lParamsArray['oauth_token'], $lParamsArray['oauth_token_secret'], true); return $lOnlineIdentity; }
/** * add identifier * * @author Matthias Pfefferle * @param User $pUser * @param AuthToken $pAuthToken * @return OnlineIdentity */ public function addIdentifier($pUser, $pOAuthToken) { $lAccessToken = $this->getAccessToken($pOAuthToken); // get params $lParams = $lAccessToken->params; $lParamsArray = array(); // extract params parse_str($lParams, $lParamsArray); $lXml = OAuthClient::get($this->getConsumer(), $lParamsArray['oauth_token'], $lParamsArray['oauth_token_secret'], "http://api.linkedin.com/v1/people/~:(id,site-standard-profile-request,summary,picture-url,first-name,last-name,date-of-birth,location)"); $lProfileArray = XmlUtils::XML2Array($lXml); //var_dump($lProfileArray);die(); // identifier $lLinkedInId = $lProfileArray['id']; $lProfileUri = "http://www.linkedin.com/profile/view?id=" . $lLinkedInId; // ask for online identity $lOnlineIdentity = OnlineIdentityTable::retrieveByAuthIdentifier($lProfileUri); // check if user already exists if ($lOnlineIdentity) { if ($lOnlineIdentity->getUserId() && $pUser->getId() == $lOnlineIdentity->getUserId()) { if (!$lOnlineIdentity->getActive()) { $lOnlineIdentity->setActive(true); } else { throw new sfException("online identity already added", 1); } } elseif ($lOnlineIdentity->getUserId() && $pUser->getId() != $lOnlineIdentity->getUserId()) { throw new sfException("online identity already added by someone else", 2); } } else { // new online identity if no exist $lOnlineIdentity = OnlineIdentityTable::addOnlineIdentity($lProfileUri, $lLinkedInId, $this->aCommunityId, $lProfileUri); } $this->completeOnlineIdentity($lOnlineIdentity, $lProfileArray, $pUser); AuthTokenTable::saveToken($pUser->getId(), $lOnlineIdentity->getId(), $lParamsArray['oauth_token'], $lParamsArray['oauth_token_secret'], true); return $lOnlineIdentity; }
/** * save aggregated stat-informations * * @param YiidActivity $pYiidActivity * @param User $pUser * @author Matthias Pfefferle */ public static function createChartData($pYiidActivity) { $lHost = parse_url($pYiidActivity->getUrl(), PHP_URL_HOST); $lDoc = array('url' => $pYiidActivity->getUrl(), 'date' => new MongoDate(strtotime(date("Y-m-d", $pYiidActivity->getC())))); $pUser = $pYiidActivity->getUser(); $lOptions = array(); // set gender switch ($pUser->getGender()) { case "m": $lOptions["d.sex.m"] = 1; break; case "f": $lOptions["d.sex.f"] = 1; break; default: $lOptions["d.sex.u"] = 1; break; } // set relationship switch ($pUser->getRelationshipState()) { case IdentityHelper::USER_RELATIONSHIP_STATUS_COMPLICATED: $lOptions["d.rel.compl"] = 1; break; case IdentityHelper::USER_RELATIONSHIP_STATUS_ENGAGED: $lOptions["d.rel.eng"] = 1; break; case IdentityHelper::USER_RELATIONSHIP_STATUS_IN_OPEN_RELATIONSHIP: $lOptions["d.rel.ior"] = 1; break; case IdentityHelper::USER_RELATIONSHIP_STATUS_IN_RELATIONSHIP: $lOptions["d.rel.rel"] = 1; break; case IdentityHelper::USER_RELATIONSHIP_STATUS_MARRIED: $lOptions["d.rel.mar"] = 1; break; case IdentityHelper::USER_RELATIONSHIP_STATUS_SINGLE: $lOptions["d.rel.singl"] = 1; break; case IdentityHelper::USER_RELATIONSHIP_STATUS_WIDOWED: $lOptions["d.rel.wid"] = 1; break; default: $lOptions["d.rel.u"] = 1; break; } // set age $a = $pUser->getAge(); if ($a < 18) { $lOptions["d.age.u_18"] = 1; } elseif ($a >= 18 && $a <= 24) { $lOptions["d.age.b_18_24"] = 1; } elseif ($a >= 25 && $a <= 34) { $lOptions["d.age.b_25_34"] = 1; } elseif ($a >= 35 && $a <= 54) { $lOptions["d.age.b_35_54"] = 1; } elseif ($a >= 55) { $lOptions["d.age.o_55"] = 1; } else { $lOptions["d.age.u"] = 1; } // set tags if ($lTags = $pYiidActivity->getTags()) { // add each tag with counts foreach ($lTags as $lTag) { $lOptions["t." . $lTag . ".cnt"] = 1; // set score if ($pYiidActivity->getScore() > 0) { $lOptions["t." . $lTag . ".pos"] = 1; } else { $lOptions["t." . $lTag . ".neg"] = 1; } // clickbacks if ($pYiidActivity->isClickback()) { $lOptions["s." . $lTag . ".cb"] = 1; } } } $lUpdate = false; // add online identities foreach ($pYiidActivity->getOiids() as $lId) { $lOi = OnlineIdentityTable::getInstance()->retrieveByPk($lId); if ($lOi) { $lUpdate = true; if ($pYiidActivity->getScore() > 0) { $lOptions["s." . $lOi->getCommunity()->getCommunity() . ".pos"] = 1; } else { $lOptions["s." . $lOi->getCommunity()->getCommunity() . ".neg"] = 1; } $lOptions["s." . $lOi->getCommunity()->getCommunity() . ".cnt"] = intval($lOi->getFriendCount()); // clickbacks if ($pYiidActivity->isClickback()) { $lOptions["s." . $pYiidActivity->getCbService() . ".cb"] = 1; } } } if ($lUpdate) { // check if activity is a deal if ($lDealId = $pYiidActivity->getDId()) { // add deal id $lChart = 'deals'; $lDoc['d_id'] = intval($lDealId); } else { $lChart = 'charts'; } // mongo collection $lCollection = self::getMongoCollection(str_replace('.', '_', $lHost) . ".analytics." . $lChart); // update analytics $lCollection->update($lDoc, array('$inc' => $lOptions), array("upsert" => true)); } }