/**
  * 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);
 }
 /**
  * Check if the user is monitoring an object
  *
  * @return boolean
  * @param  BaseObject  $user
  * @param  String      $object_model   - define the type of object
  * @param  int         $object_id
  **/
 public function isMonitoring(BaseObject $user, $object_model, $object_id)
 {
     $c = new Criteria();
     $c->add(MonitoringPeer::MONITORABLE_ID, $object_id);
     $c->add(MonitoringPeer::MONITORABLE_MODEL, $object_model);
     $c->add(MonitoringPeer::USER_ID, $this->getReferenceKey($user));
     $n_monitoring = MonitoringPeer::doCount($c);
     if ($n_monitoring == 1) {
         return true;
     }
     if ($n_monitoring > 1) {
         throw new deppPropelActAsMonitorerException('Two records found where one was expected');
     }
     if ($n_monitoring == 0) {
         return false;
     }
 }
 /**
  * Retrieve the number of users monitoring the propel object
  * the number of users is taken from the cache, if possible
  * and read from the DB if specifically asked or if the cache does not exist
  *
  * @return int
  * @param  BaseObject  $object
  * @param  boolean     $override_cache - wether to override the cache or not
  **/
 public function countMonitoringUsers(BaseObject $object, $override_cache = false)
 {
     if ($override_cache == false) {
         try {
             $res = self::getCachedCountMonitoringUsers($object);
         } catch (deppPropelActAsMonitorableException $e) {
             sfLogger::getInstance()->warning($e);
             $override_cache = true;
         }
     }
     if ($override_cache == true) {
         $c = new Criteria();
         $c->add(MonitoringPeer::MONITORABLE_ID, $this->getReferenceKey($object));
         $c->add(MonitoringPeer::MONITORABLE_MODEL, get_class($object));
         $res = MonitoringPeer::doCount($c);
         try {
             self::setCachedCountMonitoringUsers($object, $res);
         } catch (deppPropelActAsMonitorableException $e) {
             sfLogger::getInstance()->warning($e);
         }
     }
     return $res;
 }