public function executeUserVsSinglePolitician()
 {
     $user_id = $this->user->getId();
     $pol_id = $this->politico->getId();
     $leg = $this->legislatura;
     $arr = array();
     $come = array();
     $contro = array();
     $indice = 0;
     $c = new Criteria();
     $c->add(OppCaricaPeer::POLITICO_ID, $pol_id);
     $c->add(OppCaricaPeer::LEGISLATURA, $leg);
     $cariche = OppCaricaPeer::doSelect($c);
     foreach ($cariche as $carica) {
         $arr[] = $carica->getId();
     }
     $c = new Criteria();
     $c->add(sfVotingPeer::USER_ID, $user_id);
     $voting_objects = sfVotingPeer::doSelect($c);
     foreach ($voting_objects as $voting_object) {
         $c = new Criteria();
         $c->addJoin(OppAttoPeer::ID, OppCaricaHasAttoPeer::ATTO_ID);
         $c->add(OppCaricaHasAttoPeer::CARICA_ID, $arr, Criteria::IN);
         $c->add(OppAttoPeer::ID, $voting_object->getVotableID());
         $c->add(OppAttoPeer::LEGISLATURA, $leg);
         $c->add(OppCaricaHasAttoPeer::TIPO, 'R', Criteria::NOT_EQUAL);
         $firme = OppCaricaHasAttoPeer::doSelect($c);
         foreach ($firme as $firma) {
             $value = $this->calcolaIndice($firma->getOppAtto()->getTipoAttoId(), $firma->getTipo());
             $indice = $indice + $value * $voting_object->getVoting();
             if ($voting_object->getVoting() == 1) {
                 if (!in_array($firma->getAttoId(), $come)) {
                     $come[] = $firma->getAttoId();
                 }
             } else {
                 if (!in_array($firma->getAttoId(), $contro)) {
                     $contro[] = $firma->getAttoId();
                 }
             }
         }
     }
     $this->comes = $come;
     $this->contros = $contro;
     $this->indice = $indice;
 }
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(sfVotingPeer::ID, $pks, Criteria::IN);
         $objs = sfVotingPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * Clear all votings for an object
  *
  * @param  BaseObject  $object
  **/
 public function clearVotings(BaseObject $object)
 {
     $c = new Criteria();
     $c->add(sfVotingPeer::VOTABLE_ID, $object->getReferenceKey());
     $c->add(sfVotingPeer::VOTABLE_MODEL, get_class($object));
     $votes = sfVotingPeer::doSelect($c);
     foreach ($votes as $v) {
         $v->delete();
     }
     self::setVotingToObject($object, 0);
     self::setVotingDetailsToObject($object, null);
     return $ret;
 }