Changeset 7953 for trunk


Ignore:
Timestamp:
03/05/13 11:39:07 (11 years ago)
Author:
acoutinho
Message:

Ticket #3370 - Corrigido duplicacao de repeticao em compartilhamento de eventos

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

Legend:

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

    r7932 r7953  
    340340        $repeat = Controller::read(array('concept' => 'repeat', 'id' => $id)); 
    341341 
    342         unset($repeat['schedulable']); 
    343342        unset($repeat['id']); 
    344343 
     
    347346        if (isset($original['properties']['exceptions'])) { 
    348347            $exceptions = explode(',', $original['properties']['exceptions']); 
    349             unset($repeat['exceptions']); 
     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']); 
    350361        } 
    351362 
    352         $lastExceptions = Controller::find(array('concept' => 'repeatOccurrence'), array("occurrence"), array('filter' => array('AND', array('=', 'repeat', $id), array('=', 'exception', 1)))); 
     363    unset($repeat['schedulable']); 
     364 
     365    $lastExceptions = Controller::find(array('concept' => 'repeatOccurrence'), array("occurrence"), array('filter' => array('AND', array('=', 'repeat', $id), array('=', 'exception', 1)))); 
    353366 
    354367        //Recurepa as execeções anteriores caso exista 
     
    365378        else if(!empty($exceptions)) 
    366379            Controller::service('PostgreSQL')->execResultSql("INSERT INTO calendar_repeat_occurrence(repeat_id,exception,occurrence)VALUES ('" . $id . "','1','" . implode("'),('" . $id . "','1','", $exceptions) . "')" ); 
    367     }        
     380    } 
    368381 
    369382    public function checkOccurrences($start, $end, $calendarIds) { 
     
    414427 
    415428            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)) 
    418444                Controller::service('PostgreSQL')->execResultSql("INSERT INTO calendar_repeat_occurrence(repeat_id,occurrence)VALUES('" . $id . "','" . implode("'),('" . $id . "', '", $ocurrences) . "')"); 
    419             } 
     445 
     446        } 
    420447            $data = array(); 
    421448 
     
    436463//      $return = Controller::find( array( 'concept' => 'repeatOccurrence' ), false, array( 'filter' => array( 'AND', array( '>=', 'occurrence', $origStart ), array( '<=', 'occurrence', $origEnd ), array( 'IN', 'repeat', $ids ) ), 'deepness' => $deep ) ); 
    437464 
    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'); 
    439466 
    440467        if (!is_array($return)) 
  • trunk/prototype/modules/calendar/js/calendar.codecs.js

    r7928 r7953  
    18561856                                allDay: parseInt( evt.allDay ), 
    18571857                                isRepeat: isRepeat, 
    1858                                 occurrence: i, 
     1858                                occurrence: occurrences[i], 
    18591859                                type: typeEvent, 
    18601860                                calendar: evt.calendar,  
  • trunk/prototype/modules/calendar/js/helpers.js

    r7928 r7953  
    19811981} 
    19821982 
    1983 function mount_exception(eventID, idException){ 
     1983function mount_exception(eventID, exception){ 
    19841984 
    19851985    getSchedulable( eventID.toString() , ''); 
     
    19901990    edit.repeat.endTime = parseInt(edit.repeat.count) > 0 ? '0' : new Date(parseInt(edit.repeat.endTime)).toString('yyyy-MM-dd HH:mm:00'); 
    19911991     
    1992     edit.repeat.exceptions = (schedulable.occurrences[idException]);          
     1992    edit.repeat.exceptions = ( exception ); 
    19931993     
    19941994    return edit.repeat; 
    1995  
    19961995} 
    19971996 
Note: See TracChangeset for help on using the changeset viewer.