/**
  * generates a group news, unless the sf_news_cache already has it
  *
  * @return return 1 if the news was created, 0 otherwise
  * @author Guglielmo Celata
  **/
 public function generateUnlessAlreadyHasGroupNews()
 {
     $data = $this->getData();
     $politico_id = $this->getOppCarica()->getPoliticoId();
     $cnt = 0;
     // controllo e scrittura notizie di rilevanza 1 (in un certo giorno c'è stato un intervento su un certo atto)
     $has_group = oppNewsPeer::hasGroupEmendamento($data, 'OppPolitico', $politico_id);
     if (!$has_group) {
         oppNewsPeer::addGroupEmendamento($data, 'OppPolitico', $politico_id);
         $cnt++;
     }
     return $cnt;
 }
 /**
  * generates a group news, unless the sf_news_cache already has it
  *
  * @return return 1 if the news was created, 0 otherwise
  * @author Guglielmo Celata
  **/
 public function generateUnlessAlreadyHasGroupNews()
 {
     $data = $this->getOppEmendamento()->getDataPres();
     $atto_id = $this->getAttoId();
     $cnt = 0;
     // controllo e scrittura notizie di rilevanza 1
     // (in un certo giorno sono stati presentati emendamenti su un certo atto)
     $has_group = oppNewsPeer::hasGroupEmendamento($data, 'OppAtto', $atto_id);
     if (!$has_group) {
         oppNewsPeer::addGroupEmendamento($data, 'OppAtto', $atto_id);
         $cnt++;
     }
     return $cnt;
 }
 /**
  * generates a group news, unless the sf_news_cache already has it
  *
  * @return void
  * @author Guglielmo Celata
  **/
 public function generateUnlessAlreadyHasGroupNews()
 {
     $data = $this->getData();
     $sede_id = $this->getSedeId();
     $tipo_atto_id = $this->getOppAtto()->getTipoAttoId();
     $atto_id = $this->getAttoId();
     $politico_id = $this->getOppCarica()->getPoliticoId();
     $cnt = 0;
     // controllo e scrittura notizie di rilevanza 1 (in un certo giorno c'è stato un intervento su un certo atto)
     $has_group_intervention = oppNewsPeer::hasGroupIntervention($data, $sede_id, $tipo_atto_id, $atto_id);
     if (!$has_group_intervention) {
         oppNewsPeer::addGroupIntervention($data, $sede_id, $tipo_atto_id, $atto_id);
         $cnt++;
     }
     return $cnt;
 }
 /**
  * generates a group news, unless the sf_news_cache already has it
  *
  * @return void
  * @author Guglielmo Celata
  **/
 public function generateUnlessAlreadyHasGroupNews()
 {
     $seduta = $this->getOppVotazione()->getOppSeduta();
     $data = $seduta->getData();
     $ramo = $seduta->getRamo();
     $atto_id = $this->getAttoId();
     $tipo_atto_id = $this->getOppAtto()->getTipoAttoId();
     $cnt = 0;
     // controllo e scrittura notizie di rilevanza 1 (in un certo giorno si è votato un certo tipo di atti)
     $has_group_votation = oppNewsPeer::hasGroupVotation($data, $ramo, $tipo_atto_id);
     if (!$has_group_votation) {
         oppNewsPeer::addGroupVotation($data, $ramo, $tipo_atto_id);
         $cnt++;
     }
     // controllo e scrittura notizie di rilevanza 2 (in un certo giorno si è votato per un atto almeno una volta)
     $has_group_votation_on_atto = oppNewsPeer::hasGroupVotation($data, $ramo, $tipo_atto_id, $atto_id);
     if (!$has_group_votation_on_atto) {
         oppNewsPeer::addGroupVotation($data, $ramo, $tipo_atto_id, $atto_id);
         $cnt++;
     }
     return $cnt;
 }
 public function executeShowAggiornamenti()
 {
     $this->triple_value = $this->getRequestParameter('triple_value');
     $this->getResponse()->setTitle('Tutto quello che succede in Parlamento su ' . strtolower($this->triple_value) . ' - ' . sfConfig::get('app_main_title'));
     $this->response->addMeta('description', 'Le ultime notizie e atti parlamentari su ' . strtolower($this->triple_value), true);
     $this->argomento = TagPeer::retrieveFirstByTripleValue($this->triple_value);
     $this->forward404Unless(isset($this->argomento));
     $this->user = OppUserPeer::retrieveByPK($this->user_id);
     $this->session = $this->getUser();
     // fetch di tutte le notizie legate ad atti taggati con il tag corrente
     $c = oppNewsPeer::getNewsForTagCriteria($this->argomento->getId());
     $c->addDescendingOrderByColumn(NewsPeer::DATE);
     $filters = array();
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         // legge i filtri dalla request e li scrive nella sessione utente
         if ($this->hasRequestParameter('filter_main_all')) {
             $this->session->setAttribute('main_all', $this->getRequestParameter('filter_main_all'), 'news_filter');
         }
         if ($this->getRequestParameter('filter_main_all') == 'main') {
             $this->redirect('@argomento?triple_value=' . $this->triple_value);
         }
     }
     $filters['main_all'] = $this->session->getAttribute('main_all', 'main', 'news_filter');
     if ($filters['main_all'] == 'main') {
         $c->add(NewsPeer::PRIORITY, 1);
     }
     // passa la variabile filters
     $this->filters = $filters;
     if ($this->hasRequestParameter('itemsperpage')) {
         $this->getUser()->setAttribute('itemsperpage', $this->getRequestParameter('itemsperpage'));
     }
     $itemsperpage = $this->getUser()->getAttribute('itemsperpage', sfConfig::get('app_pagination_limit'));
     $this->pager = new deppNewsPager('News', $itemsperpage);
     $this->pager->setCriteria($c);
     $this->pager->setPage($this->getRequestParameter('page', 1));
     $this->pager->init();
 }
 public function executeIndex()
 {
     $this->getResponse()->setTitle('Monitora i tuoi rappresentanti - ' . sfConfig::get('app_main_title'));
     $this->getResponse()->addMeta('description', 'Cosa fanno i tuoi rappresentanti? Tutte le attività parlamentari aggiornate quotidianamente.', true);
     deppFiltersAndSortVariablesManager::resetVars($this->getUser(), 'module', 'module', array('acts_filter', 'sf_admin/opp_atto/sort', 'votes_filter', 'sf_admin/opp_votazione/sort', 'pol_camera_filter', 'pol_senato_filter', 'sf_admin/opp_carica/sort', 'argomento/atti_filter', 'argomento_leggi/sort', 'argomento_nonleg/sort', 'monitoring_filter'));
     // ultime attivita' della community
     $this->latest_activities = CommunityNewsPeer::getLatestActivities(4);
     // ultime news dal parlamento
     $c = oppNewsPeer::getHomeNewsCriteria();
     $c->addDescendingOrderByColumn(NewsPeer::DATE);
     $itemsperpage = 4;
     $pager = new deppNewsPager('News', $itemsperpage);
     $pager->setCriteria($c);
     $pager->setPage($this->getRequestParameter('page', 1));
     $pager->init();
     $this->pager = $pager;
     // atti in evidenza
     $this->lanci = array();
     $c = new Criteria();
     $c->add(sfLaunchingPeer::LAUNCH_NAMESPACE, 'home');
     $c->add(sfLaunchingPeer::OBJECT_MODEL, 'OppAtto');
     $c->setLimit(8);
     $c->addDescendingOrderByColumn(sfLaunchingPeer::PRIORITY);
     $evidences = sfLaunchingPeer::doSelect($c);
     foreach ($evidences as $evidence) {
         $atto = OppAttoPeer::retrieveByPk($evidence->getObjectId());
         $this->lanci[] = $atto->getId();
     }
     // post del blog
     $this->post_pager = sfSimpleBlogPostPeer::getTaggedPager('in evidenza', sfConfig::get('app_sfSimpleBlog_post_max_per_page', 10), $this->getRequestParameter('page', 1));
     // estrae le circoscrizioni, compreso il valore 0
     $this->senato_constituencies = OppCaricaPeer::getAllConstituencies('senato', false);
     $this->camera_constituencies = OppCaricaPeer::getAllConstituencies('camera', false);
 }
	
	<div class="threecol last">
		<!-- 
	      <p class="last-update">data di ultimo aggiornamento: <strong><?php 
echo $last_updated_item->getDataAgg('d-m-Y');
?>
</strong></p>			
	      -->

	      <?php 
echo include_partial('sfSolr/specialized_controls', array('query' => $query, 'type' => 'nonleg', 'title' => 'negli atti non legislativi'));
?>


	      <?php 
echo include_partial('news/newsbox', array('title' => 'Atti non legislativi', 'all_news_url' => '@news_attiNonLegislativi', 'news' => oppNewsPeer::getAttiListNews(oppNewsPeer::ATTI_NON_LEGISLATIVI_TIPO_IDS, 10), 'context' => 1, 'rss_link' => '@feed_attiNonLegislativi'));
?>
	</div>
	
</div>

<?php 
slot('breadcrumbs');
?>
  <?php 
echo link_to("home", "@homepage");
?>
 /
  atti non legislativi
<?php 
end_slot();
 public function executeTagNews()
 {
     // due righe modificate per la chiamata con id
     $this->tag_id = $this->getRequestParameter('id');
     $this->tag = TagPeer::retrieveByPK($this->tag_id);
     $namespace = $this->getRequestParameter('namespace');
     //      setlocale(LC_TIME, 'it_IT');
     sfLoader::loadHelpers(array('Tag', 'Url', 'DeppNews'));
     $feed = new sfRss2ExtendedFeed();
     $feed->initialize(array('title' => 'Ultime notizie sull\'argomento ' . $this->tag->getTripleValue(), 'link' => url_for('@homepage', true), 'feedUrl' => $this->getRequest()->getURI(), 'siteUrl' => 'http://' . sfConfig::get('sf_site_url'), 'image' => 'http://' . sfConfig::get('sf_site_url') . '/images/logo-openparlamento.png', 'language' => 'it', 'authorEmail' => '*****@*****.**', 'authorName' => 'Openparlamento', 'description' => "Openparlamento.it - il progetto Openpolis per la trasparenza del Parlamento", 'sy_updatePeriod' => 'daily', 'sy_updateFrequency' => '1', 'sy_updateBase' => '2000-01-01T12:00+00:00'));
     $news = oppNewsPeer::getNewsForTagCriteria($this->tag_id);
     $news->addDescendingOrderByColumn(NewsPeer::DATE);
     $itemsperpage = $this->getRequestParameter('page', sfConfig::get('app_pagination_limit'));
     $page = $this->getRequestParameter('page', 1);
     $pager = new deppNewsPager('News', $itemsperpage);
     $pager->setCriteria($news);
     $pager->setPage($this->getRequestParameter('page', 1));
     $pager->init();
     $this->pager = $pager;
     $url = url_for('@news_tag?id=' . $this->tag_id, true) . '?' . urlencode('page=' . $page . '&itemsperpage=' . $itemsperpage);
     foreach ($pager->getGroupedResults() as $date_ts => $news) {
         foreach ($news as $cnt => $n) {
             // fetch del modello e dell'oggetto che ha generato la notizia
             $generator_model = $n->getGeneratorModel();
             if ($n->getGeneratorPrimaryKeys()) {
                 $pks = array_values(unserialize($n->getGeneratorPrimaryKeys()));
                 $generator = call_user_func_array(array($generator_model . 'Peer', 'retrieveByPK'), $pks);
             } else {
                 $pks = array();
                 $generator = null;
             }
             $item = new sfRss2ExtendedItem();
             $description = news_text($n, $generator_model, $pks, $generator, array('context' => CONTEXT_TAG));
             $item->initialize(array('title' => strip_tags($description), 'link' => $url, 'permalink' => $url, 'pubDate' => $n->getDate('U'), 'uniqueId' => $n->getId(), 'description' => $description, 'authorEmail' => '*****@*****.**', 'authorName' => 'Openparlamento'));
             $feed->addItem($item);
         }
     }
     $this->_send_output($feed);
     return sfView::NONE;
 }
    if ($nvoti_validi > 0) {
        ?>
                      
                    <?php 
        //echo include_component('parlamentare', 'votacome',
        //           array('carica' => $carica,
        //                 'parlamentare' => $parlamentare,
        //                 'acronimo' => $acronimo_gruppo_corrente));
        ?>
          
                  <?php 
    }
    ?>
        
              <?php 
    echo include_partial('news/newsbox', array('title' => 'Le ultime attivit&agrave; del parlamentare', 'all_news_url' => '@news_parlamentare?id=' . $parlamentare->getId(), 'news' => oppNewsPeer::getNewsForItem('OppPolitico', $parlamentare->getId(), 3), 'context' => 2, 'rss_link' => '@feed_politico?id=' . $parlamentare->getId()));
    ?>
               <?php 
    if ($nvoti_validi > 0) {
        ?>
               <?php 
        echo include_component('parlamentare', 'comparaQuesto', array('parlamentare' => $parlamentare, 'select2' => '', 'ramo' => $carica->getTipoCaricaId() == '1' ? '1' : '2'));
        ?>
  
               <?php 
    }
    ?>
        
    </div>
</div>
<?php 
 public function executeTag()
 {
     // due righe modificate per la chiamata con id
     $this->tag_id = $this->getRequestParameter('id');
     $this->tag = TagPeer::retrieveByPK($this->tag_id);
     $this->getResponse()->setTitle('tutte le notizie sull\'argomento ' . $this->tag->getTripleValue() . ' - ' . sfConfig::get('app_main_title'));
     $this->response->addMeta('description', 'Tutte le notizie aggiornate quotidianamente sugli atti parlamentari che parlano di  ' . $this->tag->getTripleValue(), true);
     $c = oppNewsPeer::getNewsForTagCriteria($this->tag_id);
     $c->addDescendingOrderByColumn(NewsPeer::DATE);
     if ($this->hasRequestParameter('itemsperpage')) {
         $this->getUser()->setAttribute('itemsperpage', $this->getRequestParameter('itemsperpage'));
     }
     $itemsperpage = $this->getUser()->getAttribute('itemsperpage', sfConfig::get('app_pagination_limit'));
     $pager = new deppNewsPager('News', $itemsperpage);
     $pager->setCriteria($c);
     $pager->setPage($this->getRequestParameter('page', 1));
     $pager->init();
     $this->pager = $pager;
 }
		
		

	</div>
	<div class="threecol last">
		
		<?php 
if ($atto->getTipoAttoId() != 13 && $atto->getTipoAttoId() != 14) {
    ?>
	      <?php 
    echo include_component('atto', 'monitor_n_vote', array('atto' => $atto));
    ?>

	      <?php 
    echo include_partial('news/newsbox', array('title' => 'Atto', 'all_news_url' => '@news_atto?id=' . $atto->getId(), 'news' => oppNewsPeer::getNewsForItem('OppAtto', $atto->getId(), 10), 'context' => 0, 'rss_link' => '@feed_atto?id=' . $atto->getId()));
    ?>
	    <?php 
}
?>
		
	</div>
</div>

<?php 
slot('breadcrumbs');
?>
    <?php 
echo link_to("home", "@homepage");
?>
 /
?>
		
	</div>
	<div class="threecol last">
		
		<p class="last-update">data di ultimo aggiornamento: <strong><?php 
echo $last_updated_item->getDataAgg('d-m-Y');
?>
</strong></p>			

	      <?php 
echo include_partial('sfSolr/specialized_controls', array('query' => $query, 'type' => 'disegni', 'title' => 'nei disegni di legge'));
?>

	      <?php 
echo include_partial('news/newsbox', array('title' => 'Disegni di legge', 'all_news_url' => '@news_attiDisegni', 'news' => oppNewsPeer::getAttiListNews(oppNewsPeer::ATTI_DDL_TIPO_IDS, 10), 'context' => 1, 'rss_link' => '@feed_disegni'));
?>
		
	</div>
</div>

<?php 
slot('breadcrumbs');
?>
  <?php 
echo link_to("home", "@homepage");
?>
 /
  disegni di legge
<?php 
end_slot();
 private function _fetchNewsForItem($item_model, $item_id)
 {
     $n_news = oppNewsPeer::countNewsForItem($item_model, $item_id);
     $c = oppNewsPeer::getNewsForItemCriteria($item_model, $item_id);
     $c->addDescendingOrderByColumn(NewsPeer::DATE);
     $c->setLimit(sfConfig::get('app_news_dropdown_limit', 10));
     $news = oppNewsPeer::doSelect($c);
     $grouped_news = array();
     foreach ($news as $n) {
         $date = strtotime($n->getDate());
         if ((is_string($date) || is_integer($date)) && !array_key_exists($date, $grouped_news)) {
             $grouped_news[$date] = array();
         } else {
             $grouped_news['nessuna data'] = array();
         }
         $grouped_news[$date][] = $n;
     }
     krsort($grouped_news);
     $this->grouped_news = $grouped_news;
     $this->has_more = 0;
     if ($n_news > count($news)) {
         $this->has_more = $n_news;
     }
 }
/**
 * fetch today's news regarding objects monitored by the user
 * today's news are last 24h's news
 *
 * @param string $user - OppUser object
 * @return void
 * @author Guglielmo Celata
 */
function opp_test_single_newsletter($user, $date = null)
{
    $start_time = microtime(true);
    $df = new sfDateFormat('it_IT');
    echo pakeColor::colorize(sprintf('date: %s, name: %s... ', is_null($date) ? 'Today' : $date, $user), array('fg' => 'red', 'bold' => true));
    $news_c = oppNewsPeer::getTodayNewsForUserCriteria($user, $date);
    $news_c->add(oppNewsPeer::PRIORITY, 2, Criteria::LESS_EQUAL);
    $news = oppNewsPeer::doSelect($news_c);
    // raggruppa le news per data
    $grouped_news = array();
    foreach ($news as $n) {
        $date = strtotime($n->getDate());
        if (!is_string($date) && !is_int($date)) {
            $date = 0;
        }
        if (!array_key_exists($date, $grouped_news)) {
            $grouped_news[$date] = array();
        }
        $grouped_news[$date][] = $n;
    }
    krsort($grouped_news);
    echo pakeColor::colorize(sprintf("(%d)\n", count($news)), array('fg' => 'cyan'));
    if (count($news) > 0) {
        echo pakeColor::colorize(sprintf("\t    |        ID | CREATED_AT      | REL_MODEL |    REL_ID |      GENERATOR_MODEL | P |\n"), array('fg' => 'cyan', 'bold' => true));
    }
    foreach ($grouped_news as $date_ts => $news) {
        echo pakeColor::colorize(sprintf("%2d/%3s/%4d\n", $df->format($date_ts, 'dd'), $df->format($date_ts, 'MMM'), $df->format($date_ts, 'yyyy')), array('fg' => 'cyan', 'bold' => true));
        foreach ($news as $i => $n) {
            echo pakeColor::colorize(sprintf("\t%3d | %9d | %10s | %10s | %9d | %20s | %1d |\n", $i + 1, $n->getId(), $n->getCreatedAt('y-m-d H:i'), $n->getRelatedMonitorableModel(), $n->getRelatedMonitorableId(), $n->getGeneratorModel(), $n->getPriority()));
        }
    }
    echo "\n";
    $execution_time = microtime(true) - $start_time;
    if (isset($raw_email) && $raw_email != '') {
        echo " ok (";
    } else {
        echo " no mail (";
    }
    echo pakeColor::colorize(sprintf("%f", $execution_time), array('fg' => 'cyan'));
    echo ")\n";
}