/**
  * conta il numero di tag sotto il term, monitorati da un utente (o da tutti gli utenti)
  *
  * @param string $term_id 
  * @param string $user_id - se null, torna il num. di tag monitorati da tutti gli utenti
  * @return void
  * @author Guglielmo Celata
  */
 public static function countTagsUnderTermMonitoredByUser($term_id, $user_id = null)
 {
     // fetch degli id dei tag sotto il term
     $c = new Criteria();
     $c->add(OppTagHasTtPeer::TESEOTT_ID, $term_id);
     $c->addJoin(OppTagHasTtPeer::TAG_ID, TagPeer::ID);
     $c->clearSelectColumns();
     $c->addSelectColumn(TagPeer::ID);
     $tags = array();
     $rs = TagPeer::doSelectRS($c);
     while ($rs->next()) {
         $tags[] = $rs->getInt(1);
     }
     // conteggio dei tag
     $c = new Criteria();
     if (!is_null($user_id)) {
         $c->add(MonitoringPeer::USER_ID, $user_id);
     }
     $c->add(MonitoringPeer::MONITORABLE_MODEL, 'Tag');
     $c->add(MonitoringPeer::MONITORABLE_ID, $tags, Criteria::IN);
     return MonitoringPeer::doCount($c);
 }
 /**
  * Deletes all monitoring record for a Monitorer user (delete cascade emulation)
  * 
  * @param  BaseObject  $user
  */
 public function preDelete(BaseObject $user)
 {
     try {
         // get the objects affected by this user's removal
         $monitored_objects = $this->getMonitoredObjects($user);
         $user_id = $this->getReferenceKey($object);
         $c = new Criteria();
         $c->add(MonitoringPeer::USER_ID, $user_id);
         MonitoringPeer::doDelete($c);
         // updates the cache for the affected objects
         foreach ($monitored_objects as $object) {
             deppPropelActAsMonitorableBehavior::setCachedCountMonitoringUsers($user, $object->countMonitoringUsers($user_id, true));
         }
     } catch (Exception $e) {
         throw new deppPropelActAsMonitorerException('Unable to delete Monitorer object related records');
     }
 }
 //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();
                 $number_monitor_no = $number_monitor_no + 1;
                 echo "!!!! DOPPIONE" . $old . " con " . $tag_new[$k] . " per utente " . $rs->getUserId() . "\n";
             }
         }
     }
 }
 //Cancella tutte le news legate ai vecchi tags
 foreach ($tag_old as $k => $old) {
 public function executeMonitoringusersdo()
 {
     $this->monitorers_pks = $this->item->getAllMonitoringUsersPKs();
     $this->monitored_models_pks = MonitoringPeer::getModelsPKsMonitoredByUsers($this->monitorers_pks);
 }
 /**
  * Deletes all monitoring for a monitorable object (delete cascade emulation)
  * 
  * @param  BaseObject  $object
  */
 public function preDelete(BaseObject $object)
 {
     try {
         $monitoring_users = $this->getMonitoringUsers($object);
         $c = new Criteria();
         $c->add(MonitoringPeer::MONITORABLE_ID, $this->getReferenceKey($object));
         $c->add(MonitoringPeer::MONITORABLE_MODEL, get_class($object));
         MonitoringPeer::doDelete($c);
         // updates the cache
         foreach ($monitoring_users as $user) {
             $nobjects = $user->countMonitoredObjects(get_class($object), null, true);
         }
     } catch (Exception $e) {
         throw new deppPropelActAsMonitorableException('Unable to delete monitorable object related records');
     }
 }
        switch ($model) {
            case 'OppPolitico':
                echo 'i politici';
                break;
            case 'OppAtto':
                echo 'gli atti';
                break;
            case 'Tag':
                echo 'gli argomenti';
                break;
        }
        ?>
    	:</h5>

      <?php 
        $monitored_items = MonitoringPeer::getItemsMonitoredByUsers($monitorers_pks, $model);
        ?>
      <?php 
        uasort($monitored_items, 'MonitoringPeer::compareItemsByMonitoringUsers');
        ?>
      <?php 
        $items = array_slice($monitored_items, 0, 10);
        ?>
    	<div class="topics float-container">
        <?php 
        foreach ($items as $item) {
            ?>
          <?php 
            echo include_component('atto', 'itemshortinline', array('item' => $item));
            ?>
        <?php 
 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;
 }