Changeset 6177


Ignore:
Timestamp:
05/14/12 16:15:42 (12 years ago)
Author:
acoutinho
Message:

Ticket #2727 - Quando criado evento com repeticoes com a hora data ou hora menor que a hora atual

Location:
trunk/prototype/modules/calendar/interceptors
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/modules/calendar/interceptors/DBMapping.php

    r6160 r6177  
    554554//TODO: Remover apos suporte a deepness na api 
    555555    public function deepnessReadParticipant( &$uri , &$result , &$criteria , $original ){ 
    556  
     556         
     557         
    557558       if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 
    558559       { 
     
    565566            } 
    566567       } 
    567  
     568        
     569       
     570        
    568571   }  
    569572 
    570573    //TODO: Remover apos suporte a deepness na api  
    571574    public function deepnessReadEvent( &$uri , &$result , &$criteria , $original ){              
    572         
     575     
    573576       if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 
    574577       { 
    575578            if(isset($result['id'])) 
    576579            { 
    577                 $result['participants'] = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=' ,  'schedulable' ,  $result['id']), 'criteria' => array('deepness' => $original['criteria']['deepness'] - 1) ));  
     580                $result['participants'] = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=' ,  'schedulable' ,  $result['id']), 'deepness' => $original['criteria']['deepness'] - 1) );  
    578581 
    579582                $repeat =  Controller::find( array( 'concept' => 'repeat' ), false, array( 'filter' => array( '=', 'schedulable', $result['id'] ) ) ); 
     
    581584                if(is_array($repeat)) 
    582585                    $result['repeat'] = $repeat[0]; 
    583             } 
     586            }  
     587             
    584588       } 
    585589   }  
     
    587591    //TODO: Remover apos suporte a deepness na api  
    588592    public function deepnessFindParticipant( &$uri , &$result , &$criteria , $original ){ 
    589  
    590593       if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 
    591594       { 
     
    593596           { 
    594597                self::deepnessReadParticipant( $uri, $v, $criteria, $original ); 
    595            } 
    596        } 
     598           } 
     599       }   
    597600        
    598601   }  
  • trunk/prototype/modules/calendar/interceptors/Helpers.php

    r5636 r6177  
    33class Helpers {     
    44 
    5     public static function futureEvent( $startTime , $rangeEnd ) 
     5    public static function futureEvent( $startTime , $rangeEnd, $idSchedulable ) 
    66    {    
    77        //Verifica data   
    8                 $range = new DateTime( '@'.(int)($rangeEnd / 1000) , new DateTimeZone('UTC') ); 
     8        $range = new DateTime( '@'.(int)($rangeEnd / 1000) , new DateTimeZone('UTC') ); 
    99        list( $y1  , $m1 , $d1) = explode( '-' , $range->format('y-m-d'));  
    1010                 
     
    1313         
    1414        if($rangeEndMicrotime < $nowMicrotime )  
    15             return false; 
     15            return self::futureEventDecodedRepeat($startTime , $idSchedulable, $nowMicrotime); 
    1616         
    17         if($rangeEndMicrotime  === $nowMicrotime ) //caso seja o mesmo dia verifica a hora do evento. 
     17        if($rangeEndMicrotime === $nowMicrotime ) //caso seja o mesmo dia verifica a hora do evento. 
    1818        { 
    1919            $sTime = new DateTime( '@'.(int)($startTime / 1000) , new DateTimeZone('UTC') );             
     
    2222             
    2323            if( $eventHour  <  $nowHour ) 
    24                     return false; 
     24                    return self::futureEventDecodedRepeat($startTime , $idSchedulable, $nowMicrotime); 
    2525        } 
    2626       return true;  
    2727    } 
     28     
     29    public static function futureEventDecodedRepeat( $startTime , $idSchedulable, $nowMicrotime ) 
     30    {    
     31 
     32        $sql = 'SELECT calendar_repeat_occurrence.occurrence as "occurrence" ' 
     33        .'FROM calendar_repeat, calendar_repeat_occurrence WHERE calendar_repeat_occurrence.occurrence >= \'' . $startTime . '\' ' 
     34        .'AND calendar_repeat.object_id = \'' . $idSchedulable . '\' ' 
     35        .'AND calendar_repeat.id = calendar_repeat_occurrence.repeat_id AND ' 
     36        .'calendar_repeat_occurrence.exception != 1'; 
     37         
     38        $ocurrences = Controller::service('PostgreSQL')->execResultSql($sql); 
     39         
     40        if($ocurrences){ 
     41            $valid = FALSE; 
     42            foreach($ocurrences as $value) 
     43                if(($value['occurrence'] / 1000) > $nowMicrotime){ 
     44                    $valid = true; 
     45                    break; 
     46                }        
     47                return $valid; 
     48        }  else 
     49            return false; 
     50    } 
     51     
     52     
     53     
    2854     
    2955    /** 
  • trunk/prototype/modules/calendar/interceptors/Notifications.php

    r6038 r6177  
    4343                    $updated[] = $concept['id']; 
    4444            } 
    45             else if ($concept['concept'] === 'schedulable') { //Caso exista schedulable no commit antecipa o carregamento do owner 
     45            else if ($concept['concept'] === 'schedulable') { //Caso exista schedulable no commit antecipa o carregamento do owner               
    4646                $schedulables[$concept['id']] = Controller::read(array('concept' => 'schedulable', 'id' => $concept['id']), false, array('deepness' => '2')); 
    4747                foreach ($schedulables[$concept['id']]['participants'] as $i => $v) //salva em $organizers as informações do organizador       
     
    6969                    continue; //escapa organizador 
    7070                $schedulable = isset($schedulables[$pCreated['schedulable']]) ? $schedulables[$pCreated['schedulable']] : Controller::read(array('concept' => 'schedulable', 'id' => $pCreated['schedulable']), false, array('deepness' => '2')); 
    71                 if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'])) 
     71                if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id'])) 
    7272                    continue; //Escapa eventos do passado 
    7373 
     
    9696                    continue; //escapa organizador 
    9797                $schedulable = isset($schedulables[$pUpdated['schedulable']]) ? $schedulables[$pUpdated['schedulable']] : Controller::read(array('concept' => 'schedulable', 'id' => $pUpdated['schedulable']), false, array('deepness' => '2')); 
    98                 if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'])) 
     98                if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id'])) 
    9999                    continue; //Escapa eventos do passado 
    100100 
     
    452452    public function deleteEvent(&$uri, &$result, &$params, $original) { 
    453453        $schedulable = Controller::read(array('concept' => 'schedulable', 'id' => $uri['id']), null, array('deepness' => '2')); 
    454         if ((Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd']))) { 
     454        if ((Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))) { 
    455455            $method = 'CANCEL'; 
    456456            $notificationType = 'Cancelamento de Calendario'; 
     
    478478        $schedulable = Controller::read(array('concept' => 'schedulable', 'id' => $participant['schedulable'])); 
    479479 
    480         if ((Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd']))) { 
     480        if ((Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))) { 
    481481            $method = 'CANCEL'; 
    482482            $notificationType = 'Cancelamento de Calendario'; 
     
    509509            } 
    510510 
    511         if (($alt === true) && (Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd']))) { 
     511        if (($alt === true) && (Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))) { 
    512512            $method = 'REQUEST'; 
    513513            $notificationType = 'Modificação de Calendario'; 
Note: See TracChangeset for help on using the changeset viewer.