Changeset 1440
- Timestamp:
- Sep 26, 2010, 9:57:55 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpc/trunk/project/lib/task/sendAlertTask.class.php
r1438 r1440 12 12 } 13 13 14 protected static $period = array('HOUR' => 3600, 'DAY' => 86400, 'WEEK' => 604800, 'MONTH' => 2592000); 15 14 16 protected function execute($arguments = array(), $options = array()) 15 17 { … … 20 22 21 23 $solr = new SolrConnector(); 22 $query = Doctrine::getTable('Alerte')->createQuery('a')->where('next_mail < NOW()') ;24 $query = Doctrine::getTable('Alerte')->createQuery('a')->where('next_mail < NOW()')->andWhere('confirmed = 1'); 23 25 foreach($query->execute() as $alerte) { 24 26 $date = strtotime(preg_replace('/ /', 'T', $alerte->last_mail)."Z")-3600*2; 25 27 $query = $alerte->query." date:[".date('Y-m-d', $date).'T'.date('H:i:s', $date)."Z TO ".date('Y-m-d').'T'.date('H:i:s')."Z]"; 26 28 $results = $solr->search($query, array('sort' => 'date desc', 'hl' => 'yes', 'hl.fragsize'=>500)); 27 echo "$query\n"; 28 if (! $results['response']['numFound']) 29 $alerte->next_mail = date('Y-m-d H:i:s', time() + self::$period[$alerte->period]); 30 echo $alerte->next_mail." $query\n"; 31 if (! $results['response']['numFound']) { 32 $alerte->save(); 29 33 continue; 34 } 30 35 echo "sending mail to : ".$alerte->email."\n"; 31 36 $message = $this->getMailer()->compose(array('no-reply@nosdeputes.fr' => 'Regards Citoyens (ne pas répondre)'),
Note: See TracChangeset
for help on using the changeset viewer.