Exemplo n.º 1
0
 public function executeSendStmt()
 {
     if ($this->reviewType == Politico::NUM_ENTITY) {
         $this->politico = PoliticoPeer::retrieveByPK($this->reviewEntityId);
     } else {
         if ($this->reviewType == Partido::NUM_ENTITY) {
             $this->partido = PartidoPeer::retrieveByPK($this->reviewEntityId);
         } else {
             if ($this->reviewType != null) {
                 $type = SfReviewTypePeer::retrieveByPk($this->reviewType);
                 $peer = $type->getModel() . 'Peer';
                 $this->entity = $peer::retrieveByPK($this->reviewEntityId);
             } else {
                 if ($this->reviewType == null) {
                     $review_ = SfReviewPeer::retrieveByPK($this->reviewEntityId);
                     if ($review_) {
                         $this->review = $review_;
                         if ($this->review->getSfReviewTypeId() == Politico::NUM_ENTITY) {
                             $this->politico = PoliticoPeer::retrieveByPK($this->review->getEntityId());
                         } else {
                             if ($this->review->getSfReviewTypeId() == Partido::NUM_ENTITY) {
                                 $this->partido = PartidoPeer::retrieveByPK($this->review->getEntityId());
                             } else {
                                 $type = SfReviewTypePeer::retrieveByPk($this->review->getSfReviewTypeId());
                                 $peer = $type->getModel() . 'Peer';
                                 $this->entity = $peer::retrieveByPK($this->review->getEntityId());
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public function executeMoreComments(sfWebRequest $request)
 {
     $id = $request->getParameter("id");
     $this->t = $request->getParameter("t");
     $exclude = array();
     if ($this->t == 1) {
         $this->pager = SfReviewManager::getReviewsByEntityAndValue($request, Partido::NUM_ENTITY, $id, 1, BaseSfReviewManager::NUM_REVIEWS);
         $this->pageU = $request->getParameter("pageU") + 1;
         $this->getUser()->setAttribute('pageU', $this->pageU);
     } else {
         $this->pager = SfReviewManager::getReviewsByEntityAndValue($request, Partido::NUM_ENTITY, $id, -1, BaseSfReviewManager::NUM_REVIEWS);
         $this->pageD = $request->getParameter("pageD") + 1;
         $this->getUser()->setAttribute('pageD', $this->pageD);
     }
     $this->partido = PartidoPeer::retrieveByPK($id);
 }
Exemplo n.º 3
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;
     }
 }
Exemplo n.º 4
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.";
 }