public function executeAntiusersdo()
 {
     $anti_users_pks = $this->item->getVotingUsersPKs(-1);
     $voted_items = sfVotingPeer::getItemsFavouredByUsers($anti_users_pks, 'OppAtto');
     uasort($voted_items, 'sfVotingPeer::compareItemsByProUsers');
     $this->pro_acts = array_slice($voted_items, 0, 10);
     $voted_items = sfVotingPeer::getItemsOpposedByUsers($anti_users_pks, 'OppAtto');
     uasort($voted_items, 'sfVotingPeer::compareItemsByAntiUsers');
     $this->anti_acts = array_slice($voted_items, 0, 10);
 }
 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;
 }
try {
    $databaseManager = new sfDatabaseManager();
    $databaseManager->initialize();
    $con = Propel::getConnection();
} catch (PropelException $e) {
    $t->fail($e->getMessage());
    return 0;
}
$method_getter = TEST_METHOD_GETTER;
$method_setter = TEST_METHOD_SETTER;
// start tests
$t = new lime_test(15, new lime_output_color());
$t->diag('deppPropelActAsVotableBehaviorPlugin API unit test');
$t->diag('Tests beginning');
// clean the database
sfVotingPeer::doDeleteAll();
call_user_func(array(_create_object()->getPeer(), 'doDeleteAll'));
// an object is created and a test on the countVotings and getVoting values is performed
$obj = _create_object();
$t->ok($obj->countVotings() == 0, 'a new object has no votings.');
$t->ok($obj->getVoting() == 0.0, 'a new object has an average vote of 0');
$details = $obj->getVotingDetails();
print_r($details);
$t->ok(is_null($details), 'a new object has no voting details');
$obj->save();
$t->is($obj->getVotingRange(), 1, 'voting range is 1');
// define three users
$user_1_id = 1;
$user_2_id = 4;
$user_3_id = 6;
$obj->setVoting(1, $user_1_id);
 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;
 }
 /**
  * Deletes all voting for a votable object (delete cascade emulation)
  * 
  * @param  BaseObject  $object
  */
 public function preDelete(BaseObject $object)
 {
     try {
         $c = new Criteria();
         $c->add(sfVotingPeer::VOTABLE_ID, $object->getReferenceKey());
         sfVotingPeer::doDelete($c);
     } catch (Exception $e) {
         throw new deppPropelActAsVotableException('Unable to delete votable object related votings records');
     }
 }