$rs->delete();
                 $number_tagging_no = $number_tagging_no + 1;
             }
         } else {
             echo "non esiste tag con id=" . $tag_new[$k] . "\n";
         }
     }
 }
 //SOSTITUISCI TAG MONITORATI CON NUOVO TAG
 $number_monitor_ok = 0;
 $number_monitor_no = 0;
 foreach ($tag_old as $k => $old) {
     $c = new Criteria();
     $c->add(MonitoringPeer::MONITORABLE_ID, $old);
     $c->add(MonitoringPeer::MONITORABLE_MODEL, 'Tag');
     $results = MonitoringPeer::doSelect($c);
     foreach ($results as $rs) {
         $obj_tag = TagPeer::retrieveByPk($tag_new[$k]);
         if ($obj_tag) {
             $c = new Criteria();
             $c->add(MonitoringPeer::MONITORABLE_ID, $tag_new[$k]);
             $c->add(MonitoringPeer::MONITORABLE_MODEL, 'Tag');
             $c->add(MonitoringPeer::USER_ID, $rs->getUserId());
             $r = MonitoringPeer::doSelectOne($c);
             if (!$r) {
                 $rs->setMonitorableId($tag_new[$k]);
                 $rs->save();
                 echo "Monitoraggio cambiato: " . $old . " con " . $tag_new[$k] . " per utente " . $rs->getUserId() . "\n";
                 $number_monitor_ok = $number_monitor_ok + 1;
             } else {
                 $rs->delete();
 /**
  * Retrieve a list of objects monitored by the user
  *
  * @return array of Objects
  * @param  BaseObject  $user
  * @param  String      $object_model   - define the type of objects
  * @param  Criteria    $criteria an additional criteria
  **/
 public function getMonitoredObjects(BaseObject $user, $object_model = null, $criteria = null)
 {
     // handle criteria
     if (!is_null($criteria)) {
         $c = clone $criteria;
     } else {
         $c = new Criteria();
     }
     $c->add(MonitoringPeer::USER_ID, $this->getReferenceKey($user));
     if (!is_null($object_model)) {
         // get the name of the ID field for this object's model
         $obj_id_field = call_user_func_array(array('Base' . $object_model . "Peer", 'translateFieldName'), array('id', BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME));
         // build the join, using the parametric object_model's id name
         $c->addJoin(MonitoringPeer::MONITORABLE_ID, $obj_id_field);
         $c->add(MonitoringPeer::MONITORABLE_MODEL, $object_model);
         $monitored = call_user_func_array(array($object_model . "Peer", 'doSelect'), array($c));
     } else {
         $monitoring_recs = MonitoringPeer::doSelect($c);
         $monitored = array();
         foreach ($monitoring_recs as $rec) {
             $monitored[] = call_user_func_array(array($rec->getMonitorableModel() . "Peer", 'retrieveByPK'), array($rec->getMonitorableId()));
         }
     }
     return $monitored;
 }
 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(MonitoringPeer::ID, $pks, Criteria::IN);
         $objs = MonitoringPeer::doSelect($criteria, $con);
     }
     return $objs;
 }