public static function checkAuthorized()
 {
     self::storeInstance();
     if (OAuthRequestVerifier::requestIsSigned()) {
         try {
             $req = new OAuthRequestVerifier();
             $userId = $req->verify();
             // If we have an user_id, then login as that user (for this request)
             if ($userId) {
                 $user = SfGuardUserPeer::retrieveByPK($userId);
                 sfContext::getInstance()->getUser()->signin($user);
             }
         } catch (OAuthException $e) {
             sfContext::getInstance()->getLogger()->err("oauthSecurityManager::checkAuthorized exception");
             sfContext::getInstance()->getLogger()->err("Message: " + $e->getMessage());
             $this->sendNotAuthorized();
         }
     } else {
         sfContext::getInstance()->getLogger()->err("oauthSecurityManager::checkAuthorized request not signed");
         $this->sendNotAuthorized();
     }
     return $userId;
 }
Example #2
0
 public function executeSearch(sfWebRequest $request)
 {
     $culture = $this->getUser()->getCulture();
     $this->page = $this->getRequestParameter('page', 1);
     $tag = $request->getParameter("tag", false);
     $tag = str_replace("_2E_", ".", $tag);
     if ($tag) {
         $this->q = "#{$tag}";
     } else {
         $this->q = $request->getParameter("q");
     }
     $request->setAttribute("q", $this->q);
     $resultsArray = array();
     $cl = $this->resetSphinxClient();
     $needle = $this->q;
     $this->ext = "";
     if (strlen($needle) > 0 && strpos($needle, '#') === 0) {
         $this->ext = "_tag";
         $needle = substr($needle, 1);
     } else {
         $needle = SfVoUtil::stripAccents($this->q);
     }
     $this->politicoCounts = false;
     $this->partidoCounts = false;
     $this->propuestaCounts = false;
     if ($needle) {
         if ($this->ext == "_tag") {
             $cl->SetMatchMode(SPH_MATCH_PHRASE);
             $cl->SetSortMode(SPH_SORT_EXTENDED, "cnt DESC");
             $this->politicoCounts = array();
             $this->partidoCounts = array();
             $this->propuestaCounts = array();
             $indexes = "partido_tag_{$culture}, politico_tag_{$culture}, propuesta_tag_{$culture}";
             $this->res = $cl->Query($needle, $indexes);
             if ($this->res !== false) {
                 $this->total = $this->res['total'];
                 $this->totalFound = $this->res['total_found'];
                 $cl->SetLimits(($this->page - 1) * $this->limit, $this->limit);
                 $this->res = $cl->Query($needle, $indexes);
             }
         } else {
             $cl->SetFieldWeights(array('abreviatura_partido' => 5, 'nombre' => 5, 'apellidos' => 5, 'alias' => 5, 'titulo' => 5, 'nombre_insti' => 8, 'nombre_ele' => 9));
             $cl->SetSortMode(SPH_SORT_EXPR, "@weight + ( 1 * votes/max_votes )");
             $indexes = "politico_{$culture}, partido_{$culture},propuesta_{$culture}, institucion_{$culture}, usuario, eleccion_{$culture}";
             $this->res = $cl->Query($needle, $indexes);
             if ($this->res !== false) {
                 $this->total = $this->res['total'];
                 $this->totalFound = $this->res['total_found'];
                 $cl->SetLimits(($this->page - 1) * $this->limit, $this->limit);
                 $this->res = $cl->Query($needle, $indexes);
             }
         }
         if ($this->res !== false && isset($this->res["matches"]) && is_array($this->res["matches"])) {
             foreach ($this->res["matches"] as $match) {
                 //echo "<pre>";print_r( $match );echo "</pre>";
                 switch ($match['attrs']['type']) {
                     case 1:
                         if ($this->ext == "_tag") {
                             $this->politicoCounts[$match['attrs']['politico_id']] = $match['attrs']['cnt'];
                             $resultsArray[] = PoliticoPeer::retrieveByPK($match['attrs']['politico_id']);
                         } else {
                             $resultsArray[] = PoliticoPeer::retrieveByPK($match['id']);
                         }
                         break;
                     case 2:
                         if ($this->ext == "_tag") {
                             $this->partidoCounts[$match['attrs']['partido_id']] = $match['attrs']['cnt'];
                             $resultsArray[] = PartidoPeer::retrieveByPK($match['attrs']['partido_id']);
                         } else {
                             $resultsArray[] = PartidoPeer::retrieveByPK($match['id']);
                         }
                         break;
                     case 3:
                         if ($this->ext == "_tag") {
                             $this->propuestaCounts[$match['attrs']['propuesta_id']] = $match['attrs']['cnt'];
                             $resultsArray[] = PropuestaPeer::retrieveByPK($match['attrs']['propuesta_id']);
                         } else {
                             $resultsArray[] = PropuestaPeer::retrieveByPK($match['id']);
                         }
                         break;
                     case 101:
                         $resultsArray[] = InstitucionPeer::retrieveByPK($match['id']);
                         break;
                     case 102:
                         $resultsArray[] = SfGuardUserPeer::retrieveByPK($match['id']);
                         break;
                     case 103:
                         $resultsArray[] = ConvocatoriaPeer::retrieveByPK($match['id']);
                         break;
                 }
             }
         }
     }
     $this->results = $resultsArray;
     $this->title = sfContext::getInstance()->getI18N()->__('"%1%" en Voota', array('%1%' => $this->q));
     $descStr = "";
     foreach ($resultsArray as $idx => $result) {
         if ($idx < 3) {
             $descStr .= ($descStr ? ', ' : '') . $result;
         }
     }
     $this->response->addMeta('Description', sfContext::getInstance()->getI18N()->__('Resultados de la búsqueda "%1%" en Voota: %2%, ...', array('%1%' => $this->q, '%2%' => $descStr)));
     $this->response->setTitle($this->title);
 }
Example #3
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $s3 = new S3Voota();
     $c = new Criteria();
     //$c->add(PoliticoPeer::ID, 1, Criteria::EQUAL);
     $politicos = PoliticoPeer::doSelect($c);
     foreach ($politicos as $politico) {
         $vanity = $politico->getVanity();
         if ($vanity != ($new = SfVoUtil::fixVanityChars($vanity))) {
             while (preg_match("/(.*)-\$/is", $new, $m, PREG_OFFSET_CAPTURE)) {
                 $new = $m[1][0];
             }
             $c2 = new Criteria();
             $c2->add(PoliticoPeer::VANITY, "{$new}%", Criteria::LIKE);
             $c2->add(PoliticoPeer::ID, $politico->getId(), Criteria::NOT_EQUAL);
             $politicosLikeMe = PoliticoPeer::doSelect($c2);
             $counter = 0;
             foreach ($politicosLikeMe as $politicoLikeMe) {
                 $aVanity = str_replace("-", "\\-", $new);
                 if (preg_match(SfVoUtil::voDecode("/^{$new}\\-([0-9]*)\$/is"), SfVoUtil::voDecode($politicoLikeMe->getVanity()), $matches)) {
                     if ($counter < 1 + $matches[1]) {
                         $counter = 1 + $matches[1];
                     } else {
                         $counter++;
                     }
                 } else {
                     $counter++;
                 }
             }
             $new = "{$new}" . ($counter == 0 ? '' : "-{$counter}");
             echo "politico:{$vanity} ";
             echo "cambia a:{$new}\n";
             $politico->setVanity($new);
             $politico->save();
         }
     }
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $vanity = $usuario->getProfile()->getVanity();
         if ($vanity != SfVoUtil::fixVanityChars($vanity)) {
             echo "usuario:{$vanity} ({$usuario})\n";
             $usuario->getProfile()->setVanity(SfVoUtil::fixVanityChars($vanity));
             $usuario->getProfile()->save();
         }
     }
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $vanity = $partido->getAbreviatura();
         if ($vanity != SfVoUtil::fixVanityChars($vanity)) {
             echo "partido:{$vanity}\n";
         }
     }
     // Instituciones
     $instituciones = InstitucionI18nPeer::doSelect($c);
     foreach ($instituciones as $institucion) {
         $vanity = $institucion->getVanity();
         if ($vanity != ($new = SfVoUtil::fixVanityChars($vanity))) {
             echo "institucion:{$vanity}\n";
             $institucion->setVanity($new);
             $institucion->save();
             echo "cambia a:{$new}\n";
         }
     }
 }
Example #4
0
 protected function execute($arguments = array(), $options = array())
 {
     $sfContext = sfContext::createInstance($this->configuration);
     $controller = $sfContext->getController();
     $this->cultures = array('ca' => 'cat', 'es' => 'es');
     $culture = $options['culture'];
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     //foreach($this->cultures as $culture => $ext){
     $sfContext->getUser()->setCulture($culture);
     // **************** HOME **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@homepage", true), $culture);
     // **************** Ultimas opiniones **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_politicos_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_partidos_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_propuestas_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_otras_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_politicos_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_partidos_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_propuestas_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_otras_feed_{$culture}", true), $culture);
     // **************** varias **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@about", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@rules", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@search", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@contact", true), $culture);
     // **************** Fichas POLITICOS **********************
     $c = new Criteria();
     //$c->setLimit(5);
     $politicos = PoliticoPeer::doSelect($c);
     foreach ($politicos as $politico) {
         $this->writeToSitemap("politico-{$culture}", $controller->genUrl("politico/show?id=" . $politico->getVanity(), true), $culture);
     }
     // **************** Fichas PARTIDOS **********************
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("partido-{$culture}", $controller->genUrl("partido/show?id=" . $partido->getAbreviatura(), true), $culture);
     }
     // **************** Fichas PROPUESTAS **********************
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $propuestas = PropuestaPeer::doSelect($c);
     foreach ($propuestas as $propuesta) {
         $this->writeToSitemap("propuesta-{$culture}", $controller->genUrl("propuesta/show?id=" . $propuesta->getVanity(), true), $culture);
     }
     // **************** Fichas USUARIOS **********************
     $c = new Criteria();
     $c->add(SfGuardUserPeer::IS_ACTIVE, true);
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $this->writeToSitemap("usuario-{$culture}", $controller->genUrl("perfil/show?username="******"politico-feed-{$culture}", $controller->genUrl("politico/show?id=" . $politico->getVanity(), true), $culture);
     }
     // **************** feeds PARTIDOS **********************
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("partido-feed-{$culture}", $controller->genUrl("partido/feed?id=" . $partido->getAbreviatura(), true), $culture);
     }
     // **************** feeds PROPUESTAS **********************
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $propuestas = PropuestaPeer::doSelect($c);
     foreach ($propuestas as $propuesta) {
         $this->writeToSitemap("propuesta-feed-{$culture}", $controller->genUrl("propuesta/feed?id=" . $propuesta->getVanity(), true), $culture);
     }
     // **************** feeds USUARIOS **********************
     $c = new Criteria();
     $c->add(SfGuardUserPeer::IS_ACTIVE, true);
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $this->writeToSitemap("usuario-feed-{$culture}", $controller->genUrl("perfil/feed?username="******"propuesta-ranking-{$culture}", $controller->genUrl("propuesta/ranking", true), $culture);
     $pager = EntityManager::getPropuestas($culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
         $idx++;
         $this->writeToSitemap("propuesta-ranking-{$culture}", $controller->genUrl("propuesta/ranking?page={$idx}", true), $culture);
     }
     // **************** ranking POLITICOS **********************
     $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking", true), $culture);
     $pager = EntityManager::getPoliticos(false, false, $culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
         $idx++;
         $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?page={$idx}", true), $culture);
     }
     # ranking de polis filtrados por partido
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura(), true), $culture);
         $pager = EntityManager::getPoliticos($partido->getAbreviatura(), false, $culture);
         $idx = 1;
         while ($idx < $pager->getLastPage()) {
             $idx++;
             $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&page={$idx}", true), $culture);
         }
         # ranking de polis filtrados por partido e insti
         $c = new Criteria();
         $c->add(InstitucionPeer::IS_ACTIVE, true);
         $c->addJoin(PoliticoInstitucionPeer::INSTITUCION_ID, InstitucionPeer::ID);
         $c->addJoin(PoliticoPeer::ID, PoliticoInstitucionPeer::POLITICO_ID);
         $c->add(PoliticoPeer::PARTIDO_ID, $partido->getId());
         $instis = InstitucionPeer::doSelect($c);
         foreach ($instis as $insti) {
             $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&institucion=" . $insti->getVanity(), true), $culture);
             $pager = EntityManager::getPoliticos($partido->getAbreviatura(), $insti->getVanity(), $culture);
             $idx = 1;
             while ($idx < $pager->getLastPage()) {
                 $idx++;
                 $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
             }
         }
     }
     # ranking de polis filtrados por insti
     $c = new Criteria();
     $c->add(InstitucionPeer::IS_ACTIVE, true);
     $instis = InstitucionPeer::doSelect($c);
     foreach ($instis as $insti) {
         $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=all&institucion=" . $insti->getVanity(), true), $culture);
         $pager = EntityManager::getPoliticos(false, $insti->getVanity(), $culture);
         $idx = 1;
         while ($idx < $pager->getLastPage()) {
             $idx++;
             $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=all&institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
         }
     }
     // **************** ranking PARTIDOS **********************
     $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking", true), $culture);
     $pager = EntityManager::getPartidos(false, $culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
         $idx++;
         $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?page={$idx}", true), $culture);
     }
     $c = new Criteria();
     $c->add(InstitucionPeer::IS_ACTIVE, true);
     $instis = InstitucionPeer::doSelect($c);
     foreach ($instis as $insti) {
         $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?institucion=" . $insti->getVanity(), true), $culture);
         $pager = EntityManager::getPartidos($insti->getVanity(), $culture);
         $idx = 1;
         while ($idx < $pager->getLastPage()) {
             $idx++;
             $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
         }
     }
     // **************** elecciones **********************
     $c = new Criteria();
     $convocatorias = ConvocatoriaPeer::doSelect($c);
     foreach ($convocatorias as $convocatoria) {
         $this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('eleccion/show?vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
         $used = array();
         foreach ($convocatoria->getListasJoinCircunscripcion() as $geoLista) {
             if (!in_array($geoLista->getCircunscripcion()->getGeo(), $used)) {
                 $used[] = $geoLista->getCircunscripcion()->getGeo();
                 $this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('eleccion/show?geo=' . $geoLista->getCircunscripcion()->getGeo()->getNombre() . '&vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
             }
             $this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('lista/show?partido=' . $geoLista->getPartido()->getAbreviatura() . '&geo=' . $geoLista->getCircunscripcion()->getGeo()->getNombre() . '&vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
         }
     }
     //}
     $this->closeAll($culture);
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(SfGuardUserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(SfGuardUserPeer::DATABASE_NAME);
         $criteria->add(SfGuardUserPeer::ID, $pks, Criteria::IN);
         $objs = SfGuardUserPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #6
0
 public function executeFeed(sfWebRequest $request)
 {
     $vanity = $request->getParameter('username');
     $this->f = $request->getParameter('f');
     $culture = $this->getUser()->getCulture();
     $c = new Criteria();
     $c->add(SfGuardUserProfilePeer::VANITY, $vanity, Criteria::EQUAL);
     $userProfile = SfGuardUserProfilePeer::doSelectOne($c);
     $this->forward404Unless($userProfile);
     $this->user = $userProfile->getsfGuardUser();
     if (!$this->user->getIsActive() && is_numeric($userProfile->getFacebookUid())) {
         $user = SfGuardUserPeer::retrieveByPK($userProfile->getFacebookUid());
         $this->forward404Unless($user);
         $this->redirect('perfil/show?username='******'%1% en Voota.es', array('%1%' => $this->user));
     $descripcion = SfVoUtil::cutToLength($userProfile->getPresentacion(), 155, '...', true);
     $description = $descripcion ? $descripcion : sfContext::getInstance()->getI18N()->__('Votos y opiniones de %1% sobre políticos y partidos de España', array('%1%' => trim($this->user) ? $this->user : $this->user->getProfile()->getVanity()));
     $feed = new sfRssFeed();
     $feed->setTitle($title);
     $feed->setLanguage($culture);
     $feed->setSubtitle($description);
     $feed->setDescription($description);
     $feed->setLink('perfil/show?username='******'ca' ? "cat" : $culture;
     $feed->setAuthorName("Voota.{$domainExt}");
     $feedImage = new sfFeedImage();
     $feedImage->setLink('perfil/show?username='******'/usuarios/cc_' . $this->user->getProfile()->getImagen());
     $feedImage->setTitle($this->user);
     $feed->setImage($feedImage);
     foreach ($reviews as $review) {
         $item = new sfFeedItem();
         $entityText = "";
         if (!$review->getSfReviewType()) {
             $tmpReview = $review->getSfReviewRelatedBySfReviewId();
             $entityText = sfContext::getInstance()->getI18N()->__('Otra opinión sobre') . ' ';
         } else {
             $tmpReview = $review;
         }
         $sfReviewType = SfReviewTypePeer::retrieveByPk($tmpReview->getSfReviewTypeId());
         $peer = $sfReviewType->getModel() . 'Peer';
         $entity = $peer::retrieveByPk($tmpReview->getEntityId());
         $entityText .= $entity;
         $item->setTitle(sfContext::getInstance()->getI18N()->__('%1%, voota %2%.', array('%1%' => $entityText, '%2%' => $review->getValue() == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'))));
         $item->setLink('sfReviewFront/show?id=' . SfVoUtil::reviewPermalink($review));
         $item->setAuthorName($review->getSfGuardUser());
         $item->setPubdate($review->getCreatedAt('U'));
         $item->setUniqueId($review->getId());
         $avatar = S3Voota::getImagesUrl() . '/usuarios/cc_s_' . $review->getSfGuardUser()->getProfile()->getImagen();
         $text = $culture == $review->getCulture() || !$review->getCulture() ? $review->getText() : '';
         $img = $review->getSfGuardUser()->getProfile()->getImagen() ? "<img src=\"{$avatar}\" alt =\"" . $review->getSfGuardUser() . "\" /> " : "";
         $content = "{$text}";
         $item->setDescription($content);
         $feed->addItem($item);
     }
     $this->feed = $feed;
 }
Example #7
0
 public function executeList(sfWebRequest $request)
 {
     $this->page = $request->getParameter("page", "1");
     $this->entityId = $request->getParameter("entityId", false);
     $this->value = $request->getParameter("value", false);
     $this->sfReviewType = $request->getParameter("type_id", false);
     $this->text = $request->getParameter("t", false);
     $this->entity = false;
     $this->filter = false;
     $culture = $this->getUser()->getCulture();
     $this->culture = $culture;
     $filter = array();
     $filter['culture'] = $culture;
     if ($this->sfReviewType) {
         $filter['type_id'] = $this->sfReviewType;
     }
     if ($this->text) {
         $filter['textFilter'] = 'text';
     }
     $reviewsPager = SfReviewManager::getReviews($filter, $this->page);
     $filter = array();
     $filter['type_id'] = Politico::NUM_ENTITY;
     $this->politicoReviewCount = SfReviewManager::getReviewsCount($filter, $this->page);
     $filter = array();
     $filter['type_id'] = Partido::NUM_ENTITY;
     $this->partidoReviewCount = SfReviewManager::getReviewsCount($filter, $this->page);
     $filter = array();
     $filter['type_id'] = Propuesta::NUM_ENTITY;
     $this->propuestaReviewCount = SfReviewManager::getReviewsCount($filter, $this->page);
     $c = new Criteria();
     $c->addDescendingOrderByColumn(SfGuardUserPeer::ID);
     $c->add(SfGuardUserPeer::IS_ACTIVE, true);
     $c->setLimit(10);
     $this->lastUsers = SfGuardUserPeer::doSelect($c);
     $str = '';
     switch ($this->sfReviewType) {
         case 1:
             $str = sfContext::getInstance()->getI18N()->__("políticos");
             break;
         case 2:
             $str = sfContext::getInstance()->getI18N()->__("partidos");
             break;
         case 3:
             $str = sfContext::getInstance()->getI18N()->__("propuestas");
             break;
         case "null":
             $str = sfContext::getInstance()->getI18N()->__("respuestas a otros comentarios");
             break;
     }
     // Metas
     $this->title = sfContext::getInstance()->getI18N()->__("Últimas opiniones%1% en Voota.", array('%1%' => $str ? " " . sfContext::getInstance()->getI18N()->__("sobre") . " {$str}" : ""));
     $this->response->setTitle($this->title);
     $reviews = $reviewsPager->getResults();
     $description = ($reviews[0]->getAnonymous() ? sfContext::getInstance()->getI18N()->__('anónimo') : (trim($reviews[0]->getSfGuardUser()) ? $reviews[0]->getSfGuardUser() : $reviews[0]->getSfGuardUser()->getProfile())) . " (" . ago(strtotime($reviews[0]->getModifiedAt() ? $reviews[0]->getModifiedAt() : $reviews[0]->getCreatedAt())) . "), " . ($reviews[1]->getAnonymous() ? sfContext::getInstance()->getI18N()->__('anónimo') : (trim($reviews[1]->getSfGuardUser()) ? $reviews[1]->getSfGuardUser() : $reviews[1]->getSfGuardUser()->getProfile())) . " (" . ago(strtotime($reviews[1]->getModifiedAt() ? $reviews[1]->getModifiedAt() : $reviews[1]->getCreatedAt())) . "), " . ($reviews[2]->getAnonymous() ? sfContext::getInstance()->getI18N()->__('anónimo') : (trim($reviews[2]->getSfGuardUser()) ? $reviews[2]->getSfGuardUser() : $reviews[2]->getSfGuardUser()->getProfile())) . " (" . ago(strtotime($reviews[2]->getModifiedAt() ? $reviews[2]->getModifiedAt() : $reviews[2]->getCreatedAt())) . "), " . "...";
     $this->response->addMeta('Description', $description);
     // Feed
     $request->setAttribute('rssTitle', $this->title . " Feed RSS");
     $params = "";
     if ($this->sfReviewType) {
         $params .= ($params ? '&' : '?') . 'type_id=' . $this->sfReviewType;
     }
     if ($this->text) {
         $params .= ($params ? '&' : '?') . 't=' . $this->text;
     }
     $request->setAttribute('rssFeed', "sfReviewFront/feed{$params}");
 }
Example #8
0
 public function executeEditFB(sfWebRequest $request)
 {
     $op = $request->getParameter("op");
     $this->box = $request->getParameter("box");
     $sfGuardUser = $this->getUser()->getGuardUser();
     if ($this->getUser()->isAuthenticated() && $op == 'dis') {
         $this->getUser()->getProfile()->setFacebookUid(null);
         $this->getUser()->getProfile()->save();
     }
     if ($this->getUser()->isAuthenticated() && ($uid = VoFacebook::getUid()) && $op == 'con') {
         // Buscar conflictos: Primero buscar si existe otro usuario con este UID
         $c = new Criteria();
         $c->addJoin(SfGuardUserPeer::ID, SfGuardUserProfilePeer::USER_ID);
         $c->add(SfGuardUserProfilePeer::FACEBOOK_UID, $uid);
         $c->add(SfGuardUserProfilePeer::USER_ID, $this->getUser()->getGuardUser()->getId(), Criteria::NOT_EQUAL);
         $users = SfGuardUserPeer::doSelect($c);
         if (count($users) > 0) {
             $this->faceBookUid = $uid;
             return 'ConfirmMerge';
         }
         // FIN: Buscar conflictos
         $sfGuardUser->getProfile()->setFacebookUid($uid);
         //sfFacebook::getGuardAdapter()->setUserFacebookUid($sfGuardUser, $uid);
         $sfGuardUser->save();
         $sfGuardUser->getProfile()->save();
         //$this->getUser()->signin( $sfGuardUser );
         $sfGuardUser->getProfile()->setFaceBookUID($uid);
     }
     if ($this->getUser()->isAuthenticated()) {
         $formData = sfGuardUserPeer::retrieveByPk($this->getUser()->getGuardUser()->getId());
         $this->profileEditForm = new ProfileEditForm($formData);
         if (isset($sfGuardUser)) {
             $this->lastReview = SfReviewManager::getLastReviewByUserId($sfGuardUser->getId());
             $this->lastReviewOnReview = SfReviewManager::getLastReviewOnReviewByUserId($sfGuardUser->getId());
         }
     }
     if ($this->box == 'lo_fb_conn') {
         die;
     }
 }
Example #9
0
 public function changeGuardUserActivation()
 {
     $guard_user = SfGuardUserPeer::retrieveByPk($this->getUserId());
     $guard_user->setIsActive($this->getIsActive())->save();
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = SfGuardUserPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUsername($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setAlgorithm($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setSalt($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setPassword($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setCreatedAt($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setLastLogin($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setIsActive($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setIsSuperAdmin($arr[$keys[8]]);
     }
 }