public function executeActsForType()
 {
     $this->type_id = $this->type->getId();
     $this->type_denominazione = $this->type->getDescrizione();
     // filtri per ramo e stato avanzamento
     $act_filtering_criteria = null;
     if ($this->filters['act_ramo'] != '0') {
         if (is_null($act_filtering_criteria)) {
             $act_filtering_criteria = new Criteria();
         }
         $act_filtering_criteria->add(OppAttoPeer::RAMO, $this->filters['act_ramo']);
     }
     if ($this->filters['act_stato'] != '0') {
         if (is_null($act_filtering_criteria)) {
             $act_filtering_criteria = new Criteria();
         }
         $act_filtering_criteria->add(OppAttoPeer::STATO_COD, $this->filters['act_stato']);
     }
     $blocked_items_pks = sfBookmarkingPeer::getAllNegativelyBookmarkedIds($this->user_id);
     if (array_key_exists('OppAtto', $blocked_items_pks)) {
         if (is_null($act_filtering_criteria)) {
             $act_filtering_criteria = new Criteria();
         }
         $blocked_acts_pks = $blocked_items_pks['OppAtto'];
         $act_filtering_criteria->add(OppAttoPeer::ID, $blocked_acts_pks, Criteria::NOT_IN);
     }
     $indirectly_monitored_acts = OppAttoPeer::doSelectIndirectlyMonitoredByUser($this->user, $this->type, $this->tag_filtering_criteria, $this->my_monitored_tags_pks, $act_filtering_criteria);
     if ($this->filters['tag_id'] == '0') {
         $directly_monitored_acts = OppAttoPeer::doSelectDirectlyMonitoredByUser($this->user, $this->type, $act_filtering_criteria);
     } else {
         $directly_monitored_acts = array();
     }
     $monitored_acts = OppAttoPeer::merge($indirectly_monitored_acts, $directly_monitored_acts);
     $this->n_total_acts = count($monitored_acts);
     if ($this->filters['act_type_id'] == 0) {
         $monitored_acts = array_slice($monitored_acts, 0, sfConfig::get('app_monitored_acts_per_type_limit'));
     }
     $this->monitored_acts = $monitored_acts;
 }
 public function executeRemoveTagFromMyMonitoredTags()
 {
     $isAjax = $this->getRequest()->isXmlHttpRequest();
     // remove the tag from the monitored pool
     $tag_name = $this->getRequestParameter('name');
     $tag = TagPeer::retrieveByTagname($tag_name);
     $tag->removeMonitoringUser($this->getUser()->getId());
     // fetch current user profile and the number of tags the user can still add to the pool
     $opp_user = OppUserPeer::retrieveByPK($this->getUser()->getId());
     $this->remaining_tags = $opp_user->getNMaxMonitoredTags() - $opp_user->countMonitoredObjects('Tag');
     // fetch the monitored pool
     $c = new Criteria();
     $c->add(TagPeer::ID, $opp_user->getMonitoredPks('Tag'), Criteria::IN);
     $this->my_tags = TagPeer::getPopulars($c, array('limit' => 10));
     // a tag was removed, clear the cache for the news, acts and tags page
     $cacheManager = $this->getContext()->getViewCacheManager();
     if (!is_null($cacheManager)) {
         $cacheManager->remove('monitoring/news?user_token=' . $this->getUser()->getToken());
         $cacheManager->remove('monitoring/acts?user_token=' . $this->getUser()->getToken());
         $cacheManager->remove('monitoring/tags?user_token=' . $this->getUser()->getToken());
     }
     // remove the negative bookmarking from objects indirectly monitored thanks to this tag
     $indirectly_monitored_acts = OppAttoPeer::doSelectIndirectlyMonitoredByUser($opp_user, null, null, array($tag_id));
     foreach ($indirectly_monitored_acts as $act) {
         $act->removeNegativeBookmarking($this->getUser()->getId());
     }
     if ($isAjax) {
         $this->setTemplate('ajaxMyTags');
     } else {
         $this->redirect('monitoring/tags?user_token=' . $this->getUser()->getToken());
     }
 }