Ignore:
Timestamp:
03/18/13 17:19:52 (11 years ago)
Author:
douglas
Message:

Ticket #3393 - Desconsiderar sincronização de agendas compartilhadas no Z-Push

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.5/zpush/backend/expresso/providers/calendarProvider.php

    r7687 r8032  
    3030    { 
    3131        $return = array(); 
    32         $sigs = Controller::find(array('concept' => 'calendarSignature'), array( 'id','calendar' ), array( 'filter' => array( '=' , 'user' , $this->_uidnumber ))); 
    33  
    34         foreach($sigs as $sig) 
    35         { 
    36             $calendar =  Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] )); 
    37             if($calendar['type'] != 0 ) continue; //ecluir grupo de tarefas 
    38  
    39             $tmpSig = array(); 
    40             $tmpSig["id"] = 'calendar'.$sig['id']; 
    41             $tmpSig["parent"] = 0; 
    42             $tmpSig["mod"] = $calendar['name']; 
    43             $return[] = $tmpSig; 
     32        $criteria = CALENDAR_SYNC_SIGNED_CALENDARS ? array( 'filter' => array( 'AND' , array( '=' , 'type' , '0' ) , array( '=' , 'user' , $this->_uidnumber ))) : array( 'filter' => array ( 'AND'  ,array( '=' , 'isOwner' , '1' ),array( '=' , 'type' , '0' ) , array( '=' , 'user' , $this->_uidnumber )));  
     33        $sigs = Controller::find(array('concept' => 'calendarSignature'), array( 'id','calendar' ), $criteria);  
     34  
     35        if(Request::GetDeviceType()  == 'iPhone' || Request::GetDeviceType()  == 'iPad')  
     36        {  
     37            foreach($sigs as $sig)  
     38            {  
     39                $calendar =  Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] ));  
     40                $tmpSig = array();  
     41                $tmpSig["id"] = 'calendar'.$sig['id'];  
     42                $tmpSig["parent"] = 0;  
     43                $tmpSig["mod"] = $calendar['name'];  
     44                $return[] = $tmpSig;  
     45            }  
     46        }  
     47        else  
     48        {  
     49            $defaultCalendar = Controller::find(array('concept' => 'modulePreference'), array('value','id') , array('filter' => array( 'and' , array('=' , 'name' , 'defaultCalendar') , array('=' , 'module' , 'expressoCalendar') , array('=' , 'user' , $this->_uidnumber )  )) );  
     50  
     51            if(isset($defaultCalendar[0])) //Prioriza agenda default de importação pois o android so sincroniza a primeira agenda.  
     52            {  
     53                foreach($sigs as $i => $sig)  
     54                {  
     55                    if($sig['calendar'] == $defaultCalendar[0]['value'])  
     56                    {  
     57                        $calendar =  Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] ));  
     58                        $tmpSig = array();  
     59                        $tmpSig["id"] = 'calendar'.$sig['id'];  
     60                        $tmpSig["parent"] = 0;  
     61                        $tmpSig["mod"] = $calendar['name'];  
     62                        $return[] = $tmpSig;  
     63                    }  
     64                }  
     65            }  
     66            else  
     67            {  
     68                $sig = $sigs[0];  
     69                $calendar =  Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] ));  
     70                $tmpSig = array();  
     71                $tmpSig["id"] = 'calendar'.$sig['id'];  
     72                $tmpSig["parent"] = 0;  
     73                $tmpSig["mod"] = $calendar['name'];  
     74                $return[] = $tmpSig;  
     75  
     76            }  
    4477        } 
    4578 
     
    525558        $schedulable['timezone'] = $calendar['timezone']; 
    526559 
     560  
     561        $sv  = new DateTime('@'.($message->starttime + $GMT_CEL), $calendarSignatureTimezone);  
     562  
     563        if($sv->format('I') == 0)  
     564            $schedulable['startTime'] = $schedulable['startTime'] - 3600000;  
     565  
     566        $ev  = new DateTime('@'.($message->endtime + $GMT_CEL), $calendarSignatureTimezone);  
     567  
     568        if($ev->format('I') == 0)  
     569            $schedulable['endTime'] = $schedulable['endTime'] - 3600000;  
     570  
    527571        $schedulable['allDay'] = $message->alldayevent; 
    528572        $schedulable['description'] = $message->body; 
     
    735779        $schedulable['startTime'] = (($message->starttime + $GMT_CEL) + ($calendarSignatureTimezone->getOffset(new DateTime('@'.($message->starttime + $GMT_CEL), new DateTimeZone('UTC'))) * -1) ) *1000; //$message->starttime  * 1000; 
    736780        $schedulable['endTime'] = (($message->endtime + $GMT_CEL) + ($calendarSignatureTimezone->getOffset(new DateTime('@'.($message->endtime + $GMT_CEL), new DateTimeZone('UTC')))* -1)) *1000;//$message->endtime  * 1000; 
     781  
     782        $sv  = new DateTime('@'.($message->starttime + $GMT_CEL), $calendarSignatureTimezone);  
     783  
     784        if($sv->format('I') == 0)  
     785            $schedulable['startTime'] = $schedulable['startTime'] - 3600000;  
     786  
     787        $ev  = new DateTime('@'.($message->endtime + $GMT_CEL), $calendarSignatureTimezone);  
     788  
     789        if($ev->format('I') == 0)  
     790            $schedulable['endTime'] = $schedulable['endTime'] - 3600000;  
     791  
    737792        $schedulable['timezone'] = $calendar['timezone']; 
    738  
    739793 
    740794 
     
    749803        $participant['isOrganizer'] = '1'; 
    750804        $participant['acl'] = 'rowi'; 
     805        $participant['status'] = '1';  
    751806 
    752807        if($message->organizeremail) 
     
    10331088 
    10341089        //Inicia Variaveis de para API expresso 
    1035             if(!isset($_SESSION)) 
    1036                 session_start(); 
    1037  
    1038             $userWallet = array(); 
    1039             $userWallet['uidNumber'] = $entries[0]['uidnumber'][0]; 
    1040             $userWallet['uid'] = $entries[0]['uid'][0]; 
    1041             $userWallet['mail'] = $entries[0]['mail'][0]; 
    1042  
    1043             $_SESSION['wallet'] = array(); 
    1044             $_SESSION['wallet']['user'] = $userWallet; 
    1045             $_SESSION['flags']['currentapp'] = 'expressoCalendar'; 
     1090        if(!isset($_SESSION)) 
     1091            session_start(); 
     1092 
     1093        $userWallet = array(); 
     1094        $userWallet['uidNumber'] = $entries[0]['uidnumber'][0]; 
     1095        $userWallet['uid'] = $entries[0]['uid'][0]; 
     1096        $userWallet['mail'] = $entries[0]['mail'][0]; 
     1097 
     1098        $_SESSION['wallet'] = array(); 
     1099        $_SESSION['wallet']['user'] = $userWallet; 
     1100        $_SESSION['flags']['currentapp'] = 'expressoCalendar'; 
    10461101 
    10471102        //----------------------------------------------------------------------------------------// 
Note: See TracChangeset for help on using the changeset viewer.