Ignore:
Timestamp:
10/08/13 16:20:46 (11 years ago)
Author:
douglas
Message:

Ticket #0000 - Copiadas as alterações do Trunk. Versão final 2.5.1.

File:
1 edited

Legend:

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

    r8032 r8232  
    3030    { 
    3131        $return = array(); 
    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             }  
     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            } 
    7777        } 
    7878 
     
    154154    public function ChangeFolder($folderid, $oldid, $displayname, $type) 
    155155    { 
    156        return false; 
     156        if($oldid) 
     157        { 
     158            $idNumber = (int)str_replace('calendar' , '' , $oldid); 
     159            $calendarSignature =  Controller::read( array( 'concept' => 'calendarSignature' , 'id' => $idNumber )); 
     160 
     161            Controller::update( array('concept' => 'calendar' , 'id' => $calendarSignature['calendar']), array( 'name' => $displayname) ); 
     162 
     163            return $this->StatFolder($oldid); 
     164        } 
     165        else 
     166        { 
     167             $cal = array('name' => $displayname, 
     168                'timezone' => 'America/Sao_Paulo', 
     169                'type' => '0' 
     170            ); 
     171 
     172            $calCreated = Controller::create(array('concept' => 'calendar'), $cal); 
     173 
     174            if(!$calCreated){ 
     175                return false; 
     176            } 
     177 
     178            $sig = array('user' => $_SESSION['wallet']['user']['uidNumber'], 
     179                'calendar' => $calCreated['id'], 
     180                'isOwner' => '1', 
     181                'dtstamp' => time() . '000', 
     182                'fontColor' => 'FFFFFF', 
     183                'backgroundColor' => '3366CC', 
     184                'borderColor' => '3366CC', 
     185            ); 
     186 
     187            $sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig); 
     188 
     189            if(!$sigCreated){ 
     190                return false; 
     191            } 
     192            else 
     193            { 
     194                $return = array(); 
     195                $return["id"] = 'calendar'.$calCreated; 
     196                $return["parent"] = 0; 
     197                $return["mod"] = $displayname; 
     198                return $return; 
     199            } 
     200        } 
     201 
     202        return false; 
    157203 
    158204    } 
     
    168214     * @throws StatusException              could throw specific SYNC_FSSTATUS_* exceptions 
    169215     */ 
    170     public function DeleteFolder($id, $parentid) 
    171     { 
    172         return false; 
     216    public function DeleteFolder($id, $parent) 
     217    { 
     218        $interation = array(); 
     219        $idNumber = (int)str_replace('calendar' , '' , $id); 
     220        $calendarSignature =  Controller::read( array( 'concept' => 'calendarSignature' , 'id' => $idNumber )); 
     221 
     222        $interation['calendar://' . $calendarSignature['calendar']] = false; 
     223        ob_start(); 
     224        $args = $interation; 
     225        include EXPRESSO_PATH.'/prototype/Sync.php'; 
     226        ob_end_clean(); 
     227 
     228        return true; 
    173229    } 
    174230 
     
    302358                                break; 
    303359                            case 'd': 
    304                                 $mult = 3600; 
     360                                $mult = 1440; 
    305361                                break; 
    306362                            default: 
     
    316372                        case STATUS_ACCEPTED: 
    317373                            $message->busystatus = 2; 
    318                            break; 
     374                            break; 
    319375                        case STATUS_TENTATIVE: 
    320376                            $message->busystatus = 1; 
     
    333389        //------------------------------------------------------------------------------------------------------------// 
    334390 
    335        /* 
    336        * Sincronização de Recorrência 
    337        */ 
     391        /* 
     392        * Sincronização de Recorrência 
     393        */ 
    338394        $repeats = Controller::find(array('concept' => 'repeat'), null , array( 'filter' => array( 'and' , array( '=' , 'schedulable' , $schedulable['id'] ),array( '!=' , 'frequency' , 'none' )  ) )); 
    339395        if(is_array($repeats) && count($repeats) > 0) 
     
    359415 
    360416            if($repeat['endTime']) 
    361                $recur->until =  (int) substr($repeat['endTime'], 0, -3); 
     417                $recur->until =  (int) substr($repeat['endTime'], 0, -3); 
    362418 
    363419            $recur->interval = $repeat['interval'] ? $repeat['interval'] : 1; 
     
    558614        $schedulable['timezone'] = $calendar['timezone']; 
    559615 
    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   
     616 
     617        $sv  = new DateTime('@'.($message->starttime + $GMT_CEL), $calendarSignatureTimezone); 
     618 
     619        if($sv->format('I') == 0) 
     620            $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 
     621 
     622        $ev  = new DateTime('@'.($message->endtime + $GMT_CEL), $calendarSignatureTimezone); 
     623 
     624        if($ev->format('I') == 0) 
     625            $schedulable['endTime'] = $schedulable['endTime'] - 3600000; 
     626 
    571627        $schedulable['allDay'] = $message->alldayevent; 
    572628        $schedulable['description'] = $message->body; 
     
    741797            if($v['user']['id'] == $this->_uidnumber ) 
    742798            { 
    743                $schedulable['participants'][$i]['status'] = $this->formatBusy($message->busystatus); 
     799                $schedulable['participants'][$i]['status'] = $this->formatBusy($message->busystatus); 
    744800            } 
    745801        } 
     
    779835        $schedulable['startTime'] = (($message->starttime + $GMT_CEL) + ($calendarSignatureTimezone->getOffset(new DateTime('@'.($message->starttime + $GMT_CEL), new DateTimeZone('UTC'))) * -1) ) *1000; //$message->starttime  * 1000; 
    780836        $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   
     837 
     838        $sv  = new DateTime('@'.($message->starttime + $GMT_CEL), $calendarSignatureTimezone); 
     839 
     840        if($sv->format('I') == 0) 
     841            $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 
     842 
     843        $ev  = new DateTime('@'.($message->endtime + $GMT_CEL), $calendarSignatureTimezone); 
     844 
     845        if($ev->format('I') == 0) 
     846            $schedulable['endTime'] = $schedulable['endTime'] - 3600000; 
     847 
    792848        $schedulable['timezone'] = $calendar['timezone']; 
    793849 
     
    803859        $participant['isOrganizer'] = '1'; 
    804860        $participant['acl'] = 'rowi'; 
    805         $participant['status'] = '1';  
     861        $participant['status'] = '1'; 
    806862 
    807863        if($message->organizeremail) 
     
    10211077            if($v['user']['id'] == $this->_uidnumber && $v['user']['isOrganizer']  == '1') 
    10221078            { 
    1023               $delete = true; 
     1079                $delete = true; 
    10241080            } 
    10251081        } 
     
    12621318                break; 
    12631319            case 0: 
    1264                return STATUS_UNANSWERED; 
     1320                return STATUS_UNANSWERED; 
    12651321                break; 
    12661322        } 
Note: See TracChangeset for help on using the changeset viewer.