Changeset 6378


Ignore:
Timestamp:
06/01/12 13:04:37 (8 years ago)
Author:
acoutinho
Message:

Ticket #2826 - Inconsistências na notificação nos eventos agendado com alarmes via email

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/modules/calendar/alarms.php

    r6111 r6378  
    1010$target = (gmdate('U') - 300 ).'000'; 
    1111 
    12 $parts = Controller::service('PostgreSQL')->execSql("SELECT calendar_participant.user_info_id as user, co.id as schedulable, co.dtend as endTime, co.dtstart as startTime, co.summary as summary, co.tzid as timezone, co.location as location, al.id as id ". 
    13                                                       "FROM calendar_participant, calendar_alarm as al, calendar_object as co, calendar_repeat as rep WHERE ". 
    14                                                       "al.participant_id = calendar_participant.id AND ". 
    15                                                       "calendar_participant.object_id = co.id AND ". 
    16                                                       "al.action_id = '".ALARM_MAIL."' AND ". 
    17                                                       "al.sent = '0' AND ". 
    18                                                       "CASE WHEN rep.object_id = co.id ". 
    19                                                       "THEN  ( select count(occurrence) FROM calendar_repeat_occurrence WHERE rep.object_id = co.id AND rep.id = calendar_repeat_occurrence.repeat_id AND occurrence - al.alarm_offset >= '$target' ) > 0 ". 
    20                                                       "ELSE co.range_start - al.alarm_offset >= '$target' END"); 
     12$parts = Controller::service('PostgreSQL')->execSql('SELECT DISTINCT calendar_participant.user_info_id as "user", co.id as "schedulable", co.allDay as "allDay" ,co.dtend as "endTime", co.dtstart as "startTime", co.summary as "summary", co.tzid as "timezone", co.location as "location", al.id as "id" '. 
     13                            'FROM calendar_participant, calendar_alarm as "al", calendar_object as "co", calendar_repeat as "rep" WHERE ('. 
     14                            "al.participant_id = calendar_participant.id AND ". 
     15                            "calendar_participant.object_id = co.id AND ". 
     16                            "al.action_id = '".ALARM_MAIL."' AND ". 
     17                            "al.sent = '0' AND ". 
     18                            "CASE WHEN rep.object_id = co.id ". 
     19                            "THEN  ( select count(occurrence) FROM calendar_repeat_occurrence WHERE rep.object_id = co.id AND rep.id = calendar_repeat_occurrence.repeat_id AND ((occurrence - al.alarm_offset) >= '$target') AND  ((occurrence - al.alarm_offset) >= '".($target + 360000)."') ) > 0 ". 
     20                            "ELSE (co.range_start - al.alarm_offset >= '$target') AND (co.range_start - al.alarm_offset < '".($target + 360000)."') END )"); 
    2121 
    2222if(!is_array($parts)) 
     
    4141        } 
    4242 
    43       ///////////////////////// 
     43        $timezone = new DateTimeZone('UTC'); 
     44        $sTime = new DateTime('@' . (int) ($part['startTime'] / 1000), $timezone); 
     45        $eTime = new DateTime('@' . (int) ($part['endTime'] / 1000), $timezone); 
    4446 
    45         $timezone = ($part['timezone']) ? $part['timezone'] : 'UTC'; 
    46         $sTime = new DateTime( '@'.(int)($part['startTime'] / 1000) , new DateTimeZone($timezone) ); 
    47         $eTime =  new DateTime( '@'.(int)($part['endTime'] / 1000) , new DateTimeZone($timezone) ); 
    48  
     47        $timezone = $part['timezone']; 
     48        $sTime->setTimezone(new DateTimeZone($part['timezone'])); 
     49        $eTime->setTimezone(new DateTimeZone($part['timezone'])); 
     50         
    4951        $data = array('startDate' =>  date_format( $sTime , 'd/m/Y') , 
    50                       'startTime' =>  date_format( $sTime , 'H:i') , 
     52                      'startTime' =>  $part['allDay'] ? '' : date_format( $sTime , 'H:i'), 
    5153                      'endDate' =>  date_format( $eTime , 'd/m/Y') , 
    52                       'endTime' =>  date_format( $eTime , 'H:i') , 
     54                      'endTime' =>  $part['allDay'] ? '' : date_format( $eTime , 'H:i'), 
    5355                      'eventTitle' =>  $part['summary'], 
    5456                      'eventLocation' =>  $part['location'], 
     
    6264                                                                  'to' => $part['mail'] ) ); 
    6365 
    64         Config::regSet('noAlarm', TRUE); //Evita o envio de notificação ????? 
     66        Config::regSet('noAlarm', TRUE); //Evita o envio de notificação ????? 
    6567        $ids[] = $part['id']; 
    6668} 
    6769 
    6870if( !empty( $ids ) ) 
    69     Controller::update( array( 'concept' => 'alarm' ) , array('sent' => '1'), array( 'IN', 'id', $ids ) ); 
     71    Controller::update( array( 'concept' => 'alarm' ) , array('sent' => '1'), array('filter' => array( 'IN', 'id', $ids ) )); 
    7072 
    7173?> 
Note: See TracChangeset for help on using the changeset viewer.