Example #1
0
 public function executeIndex(sfWebRequest $request)
 {
     $culture = $this->getUser()->getCulture();
     $cpos = new Criteria();
     $cpos->add(SfReviewPeer::VALUE, 1);
     $cpos->add(SfReviewPeer::IS_ACTIVE, 1);
     //$cpos->add(SfReviewPeer::CULTURE, $culture);
     $this->totalUpReviews = SfReviewPeer::doCount($cpos);
     $cneg = new Criteria();
     $cneg->add(SfReviewPeer::VALUE, -1);
     $cneg->add(SfReviewPeer::IS_ACTIVE, 1);
     //$cneg->add(SfReviewPeer::CULTURE, $culture);
     $this->totalDownReviews = SfReviewPeer::doCount($cneg);
     $exclude = "";
     $this->reviewables = EntityManager::getTopEntities(6, $exclude, "WebEntity", true);
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PoliticoPeer::SUMU);
     $c->addAscendingOrderByColumn(PoliticoPeer::SUMD);
     $c->setLimit(5);
     $this->topPoliticos = PoliticoPeer::doSelect($c);
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PartidoPeer::SUMU);
     $c->addAscendingOrderByColumn(PartidoPeer::SUMD);
     $c->setLimit(5);
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $this->partidosMasVotados = PartidoPeer::doSelect($c);
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PropuestaPeer::SUMU);
     $c->addAscendingOrderByColumn(PropuestaPeer::SUMD);
     $c->setLimit(5);
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $this->propuestasMasVotadas = PropuestaPeer::doSelect($c);
     //Totales
     /*
     $c = new Criteria();
     $this->totalPoliticos = PoliticoPeer::doCount($c);
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $this->totalPartidos = PartidoPeer::doCount($c);
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $this->totalPropuestas = PropuestaPeer::doCount($c);
     */
     $this->response->addMeta('Description', sfContext::getInstance()->getI18N()->__('Comparte opiniones sobre políticos y partidos de España. Ranking de los políticos y partidos más votados.'));
     // Ultimos comentarios
     $filter = array();
     $filter['culture'] = $culture;
     //$this->topReviews = SfReviewManager::getReviews($filter, 1, 5);
     $this->activities = SfReviewManager::getActivities($filter, 1, 5);
     // elecciones destacadas
     $convocatoriaActiva = sfConfig::get('sf_convocatoria_activa');
     $this->convocatoria = ConvocatoriaPeer::retrieveByPk($convocatoriaActiva);
 }
Example #2
0
 private function propuesta($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(PropuestaPeer::ID, $options['minid'], Criteria::GREATER_EQUAL);
     $propuestas = PropuestaPeer::doSelect($c);
     foreach ($propuestas as $propuesta) {
         if ($propuesta->getImagen() != '') {
             echo "Creating " . $propuesta->getImagen() . " ...\n";
             $s3->createFromOri("propuestas", $propuesta->getImagen());
         }
     }
 }
Example #3
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this sfGuardUser is new, it will return
  * an empty collection; or if this sfGuardUser has previously
  * been saved, it will retrieve related Propuestas from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in sfGuardUser.
  */
 public function getPropuestasJoinPartidoRelatedByPartidoVideo2Id($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(sfGuardUserPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collPropuestas === null) {
         if ($this->isNew()) {
             $this->collPropuestas = array();
         } else {
             $criteria->add(PropuestaPeer::SF_GUARD_USER_ID, $this->id);
             $this->collPropuestas = PropuestaPeer::doSelectJoinPartidoRelatedByPartidoVideo2Id($criteria, $con, $join_behavior);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(PropuestaPeer::SF_GUARD_USER_ID, $this->id);
         if (!isset($this->lastPropuestaCriteria) || !$this->lastPropuestaCriteria->equals($criteria)) {
             $this->collPropuestas = PropuestaPeer::doSelectJoinPartidoRelatedByPartidoVideo2Id($criteria, $con, $join_behavior);
         }
     }
     $this->lastPropuestaCriteria = $criteria;
     return $this->collPropuestas;
 }
Example #4
0
 /**
  * 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 = PropuestaPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setTitulo($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescripcion($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setCulture($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setImagen($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setDoc($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setDocSize($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setSfGuardUserId($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setSumu($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setSumd($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setIsActive($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setCreatedAt($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setModifiedAt($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setVanity($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setUrlVideo1($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setPartidoVideo1Id($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setUrlVideo2($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setPartidoVideo2Id($arr[$keys[17]]);
     }
 }
 /**
  * Selects a collection of EtiquetaPropuesta objects pre-filled with all related objects except sfGuardUser.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of EtiquetaPropuesta objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptsfGuardUser(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     EtiquetaPropuestaPeer::addSelectColumns($criteria);
     $startcol2 = EtiquetaPropuestaPeer::NUM_COLUMNS - EtiquetaPropuestaPeer::NUM_LAZY_LOAD_COLUMNS;
     EtiquetaPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (EtiquetaPeer::NUM_COLUMNS - EtiquetaPeer::NUM_LAZY_LOAD_COLUMNS);
     PropuestaPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + (PropuestaPeer::NUM_COLUMNS - PropuestaPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(EtiquetaPropuestaPeer::ETIQUETA_ID, EtiquetaPeer::ID, $join_behavior);
     $criteria->addJoin(EtiquetaPropuestaPeer::PROPUESTA_ID, PropuestaPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseEtiquetaPropuestaPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = EtiquetaPropuestaPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = EtiquetaPropuestaPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = EtiquetaPropuestaPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             EtiquetaPropuestaPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Etiqueta rows
         $key2 = EtiquetaPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = EtiquetaPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = EtiquetaPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 EtiquetaPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (EtiquetaPropuesta) to the collection in $obj2 (Etiqueta)
             $obj2->addEtiquetaPropuesta($obj1);
         }
         // if joined row is not null
         // Add objects for joined Propuesta rows
         $key3 = PropuestaPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = PropuestaPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = PropuestaPeer::getOMClass(false);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 PropuestaPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (EtiquetaPropuesta) to the collection in $obj3 (Propuesta)
             $obj3->addEtiquetaPropuesta($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Example #6
0
 public function executeRmtag(sfWebRequest $request)
 {
     $e = $request->getParameter('e', false);
     $id = $request->getParameter('id', false);
     $type = $request->getParameter('type', false);
     TagManager::removeTag($id, $e, $type);
     switch ($type) {
         case Politico::NUM_ENTITY:
             $this->entity = PoliticoPeer::retrieveByPK($e);
             break;
         case Partido::NUM_ENTITY:
             $this->entity = PartidoPeer::retrieveByPK($e);
             break;
         case Propuesta::NUM_ENTITY:
             $this->entity = PropuestaPeer::retrieveByPK($e);
             break;
     }
 }
Example #7
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);
 }
Example #8
0
 /**
  * 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(PropuestaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(PropuestaPeer::DATABASE_NAME);
         $criteria->add(PropuestaPeer::ID, $pks, Criteria::IN);
         $objs = PropuestaPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #9
0
 public function executeShow(sfWebRequest $request)
 {
     $vanity = $request->getParameter('username');
     $this->f = $request->getParameter('f');
     $culture = $this->getUser()->getCulture();
     $this->sfReviewType = $request->getParameter("type_id", false);
     $this->text = $request->getParameter("t", false);
     $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='******'perfil/show?username='******'', Criteria::NOT_EQUAL);
     $this->enlaces = EnlacePeer::doSelect($c);
     $c = new Criteria();
     $c->add(PropuestaPeer::SF_GUARD_USER_ID, $userProfile->getUserId());
     $c->addDescendingOrderByColumn('created_at');
     $this->propuestas = PropuestaPeer::doSelect($c);
     //$this->reviews = SfReviewManager::getReviewsByUser($this->user->getId(), $this->f);
     $filterText = '';
     switch ($this->sfReviewType) {
         case '1':
             $filterText = sfContext::getInstance()->getI18N()->__('políticos');
             break;
         case '2':
             $filterText = sfContext::getInstance()->getI18N()->__('partidos');
             break;
         case '3':
             $filterText = sfContext::getInstance()->getI18N()->__('propuestas políticas');
             break;
         case 'null':
             $filterText = sfContext::getInstance()->getI18N()->__('otros comentarios');
             break;
     }
     //if (!$filterText){
     $this->title = sfContext::getInstance()->getI18N()->__('Página de usuario de %1% en Voota', array('%1%' => trim($this->user) ? $this->user : $this->user->getProfile()->getVanity()));
     /*}
       else {
        $this->title = sfContext::getInstance()->getI18N()->__('Opiniones de %1% sobre %2% en Voota', array(
        	'%1%' => trim($this->user)?$this->user:$this->user->getProfile()->getVanity()
        	, '%2%' => $filterText
        )); 
       }*/
     $this->response->setTitle($this->title);
     $filter = array();
     if (isset($this->sfReviewType)) {
         $filter['type_id'] = $this->sfReviewType;
         $filter['textFilter'] = $this->text ? 'text' : false;
         $filter['userId'] = $userProfile->getUserId();
         $filter['culture'] = $culture;
     }
     $this->reviewsPager = SfReviewManager::getReviews($filter, 1, 3);
     //if (!$filterText){
     $descripcion = SfVoUtil::cutToLength($userProfile->getPresentacion(), 155, '...', true);
     /*}
         else {
     			
         	if ($this->reviewsPager->getNbResults() == 0){
     		    $descripcion = sfContext::getInstance()->getI18N()->__('%1% aún no se ha animado a comentar', trim($this->user)?$this->user:$this->user->getProfile()->getVanity());
            	}   
         	else { 	
     		    $descripcion = sfContext::getInstance()->getI18N()->__('%1% ha comentado sobre', array('%1%' => trim($this->user)?$this->user:$this->user->getProfile()->getVanity())). ': ';
     		    			    
         		foreach ($this->reviewsPager->getResults() as $idx => $review){
         			$type = $review->getSfReviewTypeId();
     	  			if (! $type){
     	  				$parentReview = $review->getSfReviewRelatedBySfReviewId();
     	  				$aEntityId = $parentReview->getEntityId();
     	  				$aTypeId = $parentReview->getSfReviewTypeId();
     	  				
     	  			}
     	  			else {
     	  				$aTypeId = $type;
     	  				$aEntityId = $review->getEntityId();
     	  			}
     	  			
     	  			$reviewType = SfReviewTypePeer::retrieveByPK ( $aTypeId );
     	  			$peer = $reviewType->getModel() .'Peer';
     	  			
     	  			//$entity = $peer::retrieveByPK($aEntityId);
     	  			$entity = call_user_func("$peer::retrieveByPK", $aEntityId);
     
     	  			$descripcion .= ($idx != 0?', ':'').(!$type?sfContext::getInstance()->getI18N()->__('otro comentario sobre'). ' ':'').($aTypeId==Propuesta::NUM_ENTITY?"\"$entity\"":$entity);
     	    	}
         	}
         }*/
     $this->response->addMeta('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
     $request->setAttribute('rssTitle', $this->title . " Feed RSS");
     $request->setAttribute('rssFeed', 'perfil/feed?username=' . $this->user->getProfile()->getVanity());
 }
Example #10
0
 public function executeEdit(sfWebRequest $request)
 {
     $this->redirectUnless($this->getUser()->isAuthenticated(), "@sf_guard_signin");
     $vanity = $request->getParameter('id');
     $op = $request->getParameter("op", "n");
     $c = new Criteria();
     $c->add(PropuestaPeer::VANITY, $vanity);
     $this->propuesta = PropuestaPeer::doSelectOne($c);
     $this->forward404Unless($this->propuesta);
     $this->title = sfContext::getInstance()->getI18N()->__('Edición de la propuesta "%1%" - Voota ', array('%1%' => $this->propuesta->getTitulo()));
     $this->response->setTitle($this->title);
 }
Example #11
0
 private function post_review($data)
 {
     try {
         $userId = oauthSecurityManager::checkAuthorized();
     } catch (Exception $e) {
         throw new NotAuthorizedException($e->getMessage());
     }
     $entityId = $this->getRequestParameter("entity");
     $value = $this->getRequestParameter("value");
     $text = $this->getRequestParameter("text", false);
     $type = $this->getRequestParameter("type");
     $key = oauthSecurityManager::getConsummerKey();
     if (!$entityId || !$value || !$type) {
         throw new BadRequestException("Not enough parameters.");
     }
     if ($value != -1 && $value != 1) {
         throw new BadRequestException("Invalid data for 'value'.");
     }
     $typeId = -1;
     switch ($type) {
         case 'politician':
             $typeId = Politico::NUM_ENTITY;
             $entity = PoliticoPeer::retrieveByPK($entityId);
             break;
         case 'party':
             $typeId = Partido::NUM_ENTITY;
             $entity = PartidoPeer::retrieveByPK($entityId);
             break;
         case 'proposal':
             $typeId = Propuesta::NUM_ENTITY;
             $entity = PropuestaPeer::retrieveByPK($entityId);
             break;
         default:
             throw new BadRequestException('Invalid type.');
     }
     try {
         $this->review = SfReviewManager::postReview($userId, $typeId, $entityId, $value, $text, $entity, false, 0, $key);
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     return "saved.";
 }
Example #12
0
 public function executeEdit(sfWebRequest $request)
 {
     $this->hasDeepUpdates = false;
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $this->propuestasCount = PropuestaPeer::doCount($c);
     $this->isCanonicalVootaUser = SfVoUtil::isCanonicalVootaUser($this->getUser()->getGuardUser());
     if ($this->getUser()->isAuthenticated()) {
         $this->lastReview = SfReviewManager::getLastReviewByUserId($this->getUser()->getGuardUser()->getId());
         $this->lastReviewOnReview = SfReviewManager::getLastReviewOnReviewByUserId($this->getUser()->getGuardUser()->getId());
     }
     $this->redirectUnless($this->getUser()->isAuthenticated(), "@sf_guard_signin");
     $formData = sfGuardUserPeer::retrieveByPk($this->getUser()->getGuardUser()->getId());
     if (!SfVoUtil::isEmail($formData->getUsername())) {
         $formData->setUsername('');
     }
     $this->profileEditForm = new ProfileEditForm($formData);
     $this->politico = false;
     $politicos = $this->getUser()->getGuardUser()->getPoliticos();
     if ($politicos && count($politicos) != 0) {
         $this->politico = $politicos[0];
         unset($this->profileEditForm['nombre'], $this->profileEditForm['apellidos']);
     }
     $imagenOri = $formData->getProfile()->getImagen();
     $criteria = new Criteria();
     $criteria->add(SfReviewPeer::IS_ACTIVE, true);
     $criteria->add(SfReviewPeer::SF_GUARD_USER_ID, $this->getUser()->getGuardUser()->getId());
     $this->numReviews = SfReviewPeer::doCount($criteria);
     if ($request->isMethod('post')) {
         $this->profileEditForm->bind($request->getParameter('profile'), $request->getFiles('profile'));
         if ($this->profileEditForm->isValid()) {
             /*if ($this->politico){
             		  	$cacheManager = $this->getContext()->getViewCacheManager();
             		  	if ($cacheManager != null) {
             		  		$politico = $this->getRoute()->getObject();
             		    	$cacheManager->remove("politico/show?id=".$politico->getVanity()."");
             		  	}				
             		}*/
             $profile = $request->getParameter('profile');
             $this->hasDeepUpdates = $profile['presentacion'] != $formData->getProfile()->getPresentacion();
             if ($this->profileEditForm->getValue('imagen_delete') != "") {
                 // Si se elimina la imagen, hay que recargar el formulario para que se refresque
                 $formData->getProfile()->setImagen("");
                 //$formData->getProfile()->save();
                 $this->profileEditForm->setImageSrc("");
                 $this->profileEditForm->resetImageWidget();
                 //$this->profileEditForm = new ProfileEditForm( $formData );
             } else {
                 $imageOri = $this->profileEditForm->getObject()->getProfile()->getImagen();
                 $imagen = $this->profileEditForm->getValue('imagen');
                 $this->profileEditForm->save();
                 if ($imagen) {
                     $arr = array_reverse(explode(".", $imagen->getOriginalName()));
                     $ext = strtolower($arr[0]);
                     if (!$ext || $ext == "") {
                         $ext = "png";
                     }
                     $imageName = $this->profileEditForm->getValue('nombre') ? $this->profileEditForm->getValue('nombre') : $arr[1];
                     if ($this->profileEditForm->getValue('apellidos') != '') {
                         $imageName .= "-" . $this->profileEditForm->getValue('apellidos');
                     }
                     $imageName .= "-" . sprintf("%04d", rand(0, 999));
                     $imageName .= ".{$ext}";
                     $imagen->save(sfConfig::get('sf_upload_dir') . '/usuarios/' . $imageName);
                     $this->profileEditForm->getObject()->getProfile()->setImagen($imageName);
                     $this->profileEditForm->setImageSrc($imageName);
                     $this->profileEditForm->resetImageWidget();
                     $this->hasDeepUpdates = true;
                 } else {
                     $this->profileEditForm->getObject()->getProfile()->setImagen($imagenOri);
                     $this->profileEditForm->setImageSrc($imagenOri);
                 }
             }
             if ($profile['passwordNew'] != '') {
                 // Check old password
                 if ($this->getUser()->checkPassword($profile['passwordOld'])) {
                     $this->getUser()->setPassword($profile['passwordNew']);
                 } else {
                     $this->getUser()->setFlash('notice_type', 'error', false);
                     $this->getUser()->setFlash('notice', sfVoForm::getMissingPasswordMessage(), false);
                     return;
                 }
             }
             $this->getUser()->setFlash('notice_type', 'notice', false);
             $this->getUser()->setFlash('notice', sfVoForm::getFormSavesMessage(), false);
             $this->profileEditForm->save();
             $profile = $this->profileEditForm->getObject()->getProfile();
             $profile->save();
             $aText = utf8_decode($this->profileEditForm->getValue('presentacion'));
             $aText = strip_tags(substr($aText, 0, 280));
             $aText = utf8_encode($aText);
             $profile->setPresentacion($aText);
             $profile->save();
             if ($profile->isColumnModified(SfGuardUserProfileI18nPeer::PRESENTACION)) {
                 $this->hasDeepUpdates = true;
             }
             $this->presentacionValue = $aText;
         } else {
             $this->getUser()->setFlash('notice_type', 'error', false);
             $this->getUser()->setFlash('notice', sfVoForm::getFormNotValidMessage(), false);
         }
     }
     if (!$this->presentacionValue) {
         $this->presentacionValue = $politicos = $this->getUser()->getGuardUser()->getProfile()->getPresentacion();
     }
 }
Example #13
0
 /**
  * Get the associated Propuesta object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Propuesta The associated Propuesta object.
  * @throws     PropelException
  */
 public function getPropuesta(PropelPDO $con = null)
 {
     if ($this->aPropuesta === null && $this->propuesta_id !== null) {
         $this->aPropuesta = PropuestaPeer::retrieveByPk($this->propuesta_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aPropuesta->addEtiquetaPropuestas($this);
         		 */
     }
     return $this->aPropuesta;
 }
Example #14
0
 public static function countPropuestasReviewed()
 {
     $user = sfContext::getInstance()->getUser();
     $culture = $user->getCulture();
     $cache = sfcontext::getInstance()->getViewCacheManager() ? sfcontext::getInstance()->getViewCacheManager()->getCache() : false;
     if ($cache) {
         $key = md5("propuestas_reviewes_counter_{$culture}");
         $data = unserialize($cache->get($key));
     } else {
         $data = false;
     }
     if (!$data) {
         $user = sfContext::getInstance()->getUser();
         $culture = $user->getCulture();
         $cpro = new Criteria();
         $cpro->addJoin(PropuestaPeer::ID, SfReviewPeer::ENTITY_ID, Criteria::INNER_JOIN);
         $cpro->add(SfReviewPeer::SF_REVIEW_TYPE_ID, Propuesta::NUM_ENTITY);
         $cpro->add(SfReviewPeer::IS_ACTIVE, TRUE);
         $cpro->add(PropuestaPeer::IS_ACTIVE, TRUE);
         //$cpro->add(SfReviewPeer::CULTURE, $culture);
         $cpro->add(PropuestaPeer::CULTURE, $culture);
         $cpro->setDistinct();
         $data = PropuestaPeer::doCount($cpro);
         if ($cache) {
             $cache->set($key, serialize($data), 360);
         }
     }
     return $data;
 }