Changeset 7976


Ignore:
Timestamp:
03/06/13 19:04:55 (7 years ago)
Author:
douglas
Message:

Ticket #3340 - Falha ao alterar o grupo de uma tarefa no modulo expressocalendar

File:
1 edited

Legend:

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

    r7967 r7976  
    625625            //necessário para atulizar a atividade de composta pela tarefa aqui sendo atualizada 
    626626            if(isset($criteria['historic']['startTime']) || isset($criteria['historic']['endTime'])){ 
     627                /*  
     628                 * Verify current task is built-in activity  
     629                 * */  
    627630                $taskToActivity = Controller::find(array('concept' => 'taskToActivity'), false, array('filter' => array('AND', array('=', 'task', $uri['id']), array('=', 'owner', Config::me('uidNumber'))), 'deepness' => 2)); 
    628631                if(!empty($taskToActivity)){ 
     
    630633                    $isAllDay = 1; 
    631634 
     635                    /*  
     636                     * Get all task in activity  
     637                     * */  
     638                    $taskToActivity = Controller::find(array('concept' => 'taskToActivity'), false, array('filter' => array('AND', array('=', 'activity', $taskToActivity[0]['activity']), array('=', 'owner', Config::me('uidNumber'))), 'deepness' => 2));  
     639  
    632640                    if(!empty($activity)){ 
    633641                        $start = $params['startTime']; 
    634642                        $end = $params['endTime']; 
    635643                        foreach($taskToActivity as $t){ 
    636                          if($t['task']['id'] != $params['id']){ 
    637                             $start = $t['task']['startTime'] < $start ? $t['task']['startTime'] : $start; 
    638                             $end = $t['task']['endTime'] > $end ? $t['task']['endTime'] : $end; 
    639                             $isAllDay = (($isAllDay == 1) && ($t['task']['allDay'] == '1')) ? 1 : 0; 
    640                          } 
     644  
     645  
     646                            if($t['task']['id'] != $params['id']){  
     647                                $start = $t['task']['startTime'] < $start ? $t['task']['startTime'] : $start;  
     648                                $end = $t['task']['endTime'] > $end ? $t['task']['endTime'] : $end;  
     649                                $isAllDay = (($isAllDay == 1) && ($t['task']['allDay'] == '1')) ? 1 : 0;  
     650                            }  
    641651                        } 
    642652 
     
    662672                } 
    663673            } 
    664  
     674            /*  
     675             * Clean historic not used  
     676             * */  
    665677            unset($criteria['historic']['endTime']); 
    666678            unset($criteria['historic']['rangeEnd']); 
     
    872884    } 
    873885 
     886    public function getCalendarTask( $task ){  
     887  
     888        $sql = 'select co.calendar_id as "calendar" from calendar_to_calendar_object as "co", calendar_signature as "cs" where cs.user_uidnumber = '. Config::me('uidNumber')  
     889            .' AND cs.is_owner = 1 AND cs.calendar_id = co.calendar_id AND co.calendar_object_id = '. $task;  
     890  
     891  
     892        $returns = Controller::service('PostgreSQL')->execResultSql($sql);  
     893  
     894        return $returns[0]['calendar'];  
     895    }  
     896  
    874897    //TODO: Remover apos suporte a deepness na api  
    875898    public function deepnessFindTask(&$uri, &$result, &$criteria, $original) { 
    876         if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0)  
    877            foreach($result as &$value) 
     899        if (isset($criteria['deepness']) && $criteria['deepness'] != 0){  
     900  
     901            foreach($result as &$value){  
     902  
    878903                $value['task'] = Controller::read(array('concept' => 'schedulable', 'id' => $value['task'])); 
    879             
    880          
    881         return $result; 
     904                $value['task']['calendar'] = self::getCalendarTask( $value['task']['id'] );  
     905            }  
     906  
     907            return $result;  
     908        }  
    882909    } 
    883910 
    884911    //TODO: Remover apos suporte a deepness na api  
    885912    public function deepnessFindHistoric(&$uri, &$result, &$criteria, $original) { 
    886         if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) { 
     913        if (isset($criteria['deepness']) && $criteria['deepness'] != 0) { 
    887914            foreach($result as &$v){ 
    888915                $v['user'] = Controller::read(array('concept' => 'user', 'id' => $v['user'])); 
     
    914941                .'calendar_object.range_end as "rangeEnd", calendar_object.last_update as "lastUpdate", ' 
    915942                .'calendar_object.dtstamp as "dtstamp", calendar_object.sequence as "sequence", ' 
    916                 .'calendar_object.tzid as "timezone" ' 
    917                 .'FROM calendar_object ' 
    918                 .'WHERE ( calendar_object.id = '. $criteria['schedulable'] .')'; 
     943                .'calendar_object.tzid as "timezone", calendar_to_calendar_object.calendar_id as "calendar" ' 
     944                .'FROM calendar_object, calendar_to_calendar_object ' 
     945                .'WHERE ( calendar_object.id = '. $criteria['schedulable'] .' AND calendar_to_calendar_object.calendar_object_id = calendar_object.id)'; 
    919946 
    920947            $params = Controller::service('PostgreSQL')->execResultSql($sql); 
     948  
     949            foreach( $params as &$event ){  
     950  
     951  
     952                if(isset( $event['repeat'] ) && isset( $event['repeat']['id'] ) ){  
     953                    $occurrences = Controller::service('PostgreSQL')->execResultSql('SELECT DISTINCT occurrence FROM calendar_object as "c", calendar_repeat_occurrence as "o", calendar_repeat as "r" WHERE r.object_id = '. $event['id'] .' AND o.repeat_id = r.id ' );  
     954  
     955                    if($occurrences){  
     956                        $event['occurrences'] = array();  
     957  
     958                        foreach($occurrences as $o)  
     959                            $event['occurrences'][] = $o['occurrence'];  
     960                    }else  
     961                        unset( $event['occurrences'] );  
     962                }  
     963            }  
    921964 
    922965            $params = self::deepnessFindEvent($uri, $params, $criteria, $original); 
    923966            return false; 
    924967        } 
    925  
    926  
    927  
    928968    } 
    929969 
    930970    //TODO: Remover apos suporte a deepness na api  
    931971    public function deepnessFindEvent(&$uri, &$result, &$criteria, $original) { 
    932         if ((isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) ) { 
     972        if ((isset($criteria['deepness']) && $criteria['deepness'] != 0) ) { 
    933973 
    934974            $date = new DateTime('now', new DateTimeZone('UTC')); 
     
    10201060    public static function deepnessReadParticipant( &$uri , &$result , &$criteria , $original ){ 
    10211061         
    1022        if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 
     1062       if(isset($criteria['deepness']) && $criteria['deepness'] != 0) 
    10231063       { 
    10241064            if(isset($result['id']) && isset($result['user'])) 
Note: See TracChangeset for help on using the changeset viewer.