Changeset 6177
- Timestamp:
- 05/14/12 16:15:42 (12 years ago)
- Location:
- trunk/prototype/modules/calendar/interceptors
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/calendar/interceptors/DBMapping.php
r6160 r6177 554 554 //TODO: Remover apos suporte a deepness na api 555 555 public function deepnessReadParticipant( &$uri , &$result , &$criteria , $original ){ 556 556 557 557 558 if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 558 559 { … … 565 566 } 566 567 } 567 568 569 570 568 571 } 569 572 570 573 //TODO: Remover apos suporte a deepness na api 571 574 public function deepnessReadEvent( &$uri , &$result , &$criteria , $original ){ 572 575 573 576 if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 574 577 { 575 578 if(isset($result['id'])) 576 579 { 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) ); 578 581 579 582 $repeat = Controller::find( array( 'concept' => 'repeat' ), false, array( 'filter' => array( '=', 'schedulable', $result['id'] ) ) ); … … 581 584 if(is_array($repeat)) 582 585 $result['repeat'] = $repeat[0]; 583 } 586 } 587 584 588 } 585 589 } … … 587 591 //TODO: Remover apos suporte a deepness na api 588 592 public function deepnessFindParticipant( &$uri , &$result , &$criteria , $original ){ 589 590 593 if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 591 594 { … … 593 596 { 594 597 self::deepnessReadParticipant( $uri, $v, $criteria, $original ); 595 596 } 598 } 599 } 597 600 598 601 } -
trunk/prototype/modules/calendar/interceptors/Helpers.php
r5636 r6177 3 3 class Helpers { 4 4 5 public static function futureEvent( $startTime , $rangeEnd )5 public static function futureEvent( $startTime , $rangeEnd, $idSchedulable ) 6 6 { 7 7 //Verifica data 8 8 $range = new DateTime( '@'.(int)($rangeEnd / 1000) , new DateTimeZone('UTC') ); 9 9 list( $y1 , $m1 , $d1) = explode( '-' , $range->format('y-m-d')); 10 10 … … 13 13 14 14 if($rangeEndMicrotime < $nowMicrotime ) 15 return false;15 return self::futureEventDecodedRepeat($startTime , $idSchedulable, $nowMicrotime); 16 16 17 if($rangeEndMicrotime 17 if($rangeEndMicrotime === $nowMicrotime ) //caso seja o mesmo dia verifica a hora do evento. 18 18 { 19 19 $sTime = new DateTime( '@'.(int)($startTime / 1000) , new DateTimeZone('UTC') ); … … 22 22 23 23 if( $eventHour < $nowHour ) 24 return false;24 return self::futureEventDecodedRepeat($startTime , $idSchedulable, $nowMicrotime); 25 25 } 26 26 return true; 27 27 } 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 28 54 29 55 /** -
trunk/prototype/modules/calendar/interceptors/Notifications.php
r6038 r6177 43 43 $updated[] = $concept['id']; 44 44 } 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 46 46 $schedulables[$concept['id']] = Controller::read(array('concept' => 'schedulable', 'id' => $concept['id']), false, array('deepness' => '2')); 47 47 foreach ($schedulables[$concept['id']]['participants'] as $i => $v) //salva em $organizers as informações do organizador … … 69 69 continue; //escapa organizador 70 70 $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'])) 72 72 continue; //Escapa eventos do passado 73 73 … … 96 96 continue; //escapa organizador 97 97 $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'])) 99 99 continue; //Escapa eventos do passado 100 100 … … 452 452 public function deleteEvent(&$uri, &$result, &$params, $original) { 453 453 $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']))) { 455 455 $method = 'CANCEL'; 456 456 $notificationType = 'Cancelamento de Calendario'; … … 478 478 $schedulable = Controller::read(array('concept' => 'schedulable', 'id' => $participant['schedulable'])); 479 479 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']))) { 481 481 $method = 'CANCEL'; 482 482 $notificationType = 'Cancelamento de Calendario'; … … 509 509 } 510 510 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']))) { 512 512 $method = 'REQUEST'; 513 513 $notificationType = 'Modificação de Calendario';
Note: See TracChangeset
for help on using the changeset viewer.