- Timestamp:
- 03/05/13 18:13:47 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.5/prototype/modules/calendar/interceptors/DBMapping.php
r7962 r7965 340 340 $repeat = Controller::read(array('concept' => 'repeat', 'id' => $id)); 341 341 342 unset($repeat['schedulable']);343 342 unset($repeat['id']); 344 343 … … 347 346 if (isset($original['properties']['exceptions'])) { 348 347 $exceptions = explode(',', $original['properties']['exceptions']); 349 unset($repeat['exceptions']); 350 } 351 352 $lastExceptions = Controller::find(array('concept' => 'repeatOccurrence'), array("occurrence"), array('filter' => array('AND', array('=', 'repeat', $id), array('=', 'exception', 1)))); 348 $event = Controller::read(array('concept' => 'schedulable', 'id' => $repeat['schedulable'])); 349 350 if(array_key_exists(0, $event)) $event = $event[0]; 351 352 $date = new DateTime('now', new DateTimeZone('UTC')); 353 354 foreach($exceptions as &$e){ 355 $date->setTimestamp((int) ($e / 1000)); 356 $date->setTimezone( new DateTimeZone( $event['timezone'] )); 357 $e = ($date->getTimestamp() - $date->getOffset()).'000'; 358 } 359 360 unset($repeat['exceptions']); 361 } 362 363 unset($repeat['schedulable']); 364 365 $lastExceptions = Controller::find(array('concept' => 'repeatOccurrence'), array("occurrence"), array('filter' => array('AND', array('=', 'repeat', $id), array('=', 'exception', 1)))); 353 366 354 367 //Recurepa as execeções anteriores caso exista … … 365 378 else if(!empty($exceptions)) 366 379 Controller::service('PostgreSQL')->execResultSql("INSERT INTO calendar_repeat_occurrence(repeat_id,exception,occurrence)VALUES ('" . $id . "','1','" . implode("'),('" . $id . "','1','", $exceptions) . "')" ); 367 } 380 } 368 381 369 382 public function checkOccurrences($start, $end, $calendarIds) { … … 414 427 415 428 foreach ($result as $id => $res){ 416 417 $ocurrences = array_unique($res); 429 430 $ocurrences = array_unique($res); 431 432 /* 433 * Check current range decoded 434 * */ 435 $current = Controller::find(array('concept' => 'repeatOccurrence'), array("occurrence"), array('filter' => array('=', 'repeat', $id))); 436 $toDiff = array(); 437 438 if(!empty($current)) 439 foreach($current as $c) $toDiff[] = $c['occurrence']; 440 441 $ocurrences = array_diff($ocurrences, $toDiff); 442 443 if(!empty($ocurrences)) 418 444 Controller::service('PostgreSQL')->execResultSql("INSERT INTO calendar_repeat_occurrence(repeat_id,occurrence)VALUES('" . $id . "','" . implode("'),('" . $id . "', '", $ocurrences) . "')"); 419 } 445 446 } 420 447 $data = array(); 421 448 … … 436 463 // $return = Controller::find( array( 'concept' => 'repeatOccurrence' ), false, array( 'filter' => array( 'AND', array( '>=', 'occurrence', $origStart ), array( '<=', 'occurrence', $origEnd ), array( 'IN', 'repeat', $ids ) ), 'deepness' => $deep ) ); 437 464 438 $return = Controller::service('PostgreSQL')->execResultSql('SELECT calendar_repeat_occurrence.occurrence as "occurrence", calendar_repeat.object_id as "schedulable" FROM calendar_repeat, calendar_repeat_occurrence WHERE calendar_repeat_occurrence.occurrence >= \'' . $origStart . '\' AND calendar_repeat_occurrence.occurrence <= \'' . $origEnd . '\' AND calendar_repeat_occurrence.repeat_id IN (\'' . implode('\',\'', $ids) . '\') AND calendar_repeat.id = calendar_repeat_occurrence.repeat_id AND calendar_repeat_occurrence.exception != 1 ');465 $return = Controller::service('PostgreSQL')->execResultSql('SELECT calendar_repeat_occurrence.occurrence as "occurrence", calendar_repeat.object_id as "schedulable" FROM calendar_repeat, calendar_repeat_occurrence WHERE calendar_repeat_occurrence.occurrence >= \'' . $origStart . '\' AND calendar_repeat_occurrence.occurrence <= \'' . $origEnd . '\' AND calendar_repeat_occurrence.repeat_id IN (\'' . implode('\',\'', $ids) . '\') AND calendar_repeat.id = calendar_repeat_occurrence.repeat_id AND calendar_repeat_occurrence.exception != 1 order by calendar_repeat_occurrence.occurrence'); 439 466 440 467 if (!is_array($return))
Note: See TracChangeset
for help on using the changeset viewer.