Пример #1
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;
     }
 }
Пример #2
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.";
 }