Ignore:
Timestamp:
11/29/12 17:12:33 (11 years ago)
Author:
acoutinho
Message:

Ticket #3233 - Problemas na configuracao da hora de um evento.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/services/iCal.php

    r7243 r7579  
    111111                                        $this->createAttachment($v['attachments'], $vevent); 
    112112 
    113                             $vevent->setProperty('uid', $v['uid']);   
     113                            $vevent->setProperty('uid', $v['uid']); 
     114 
     115                $timezoneDayligth = Controller::read(array('concept' => 'timezones'), null, array('filter' => array('=', 'tzid', $apTimezone))); 
     116 
     117                if(!empty( $timezoneDayligth ) && count( $timezoneDayligth ) > 0){ 
     118 
     119                    if(array_key_exists(0, $timezoneDayligth)) 
     120                        $timezoneDayligth = $timezoneDayligth[0]; 
     121 
     122                    date_default_timezone_set('UTC'); 
     123 
     124                    require_once ROOTPATH . '/plugins/when/When.php'; 
     125 
     126                    $r = new When(); 
     127 
     128                    $start = new DateTime('1970-01-01 '.$timezoneDayligth['standardDtstart']); 
     129 
     130                    $r = new When(); 
     131                    $r->recur($start, $timezoneDayligth['standardFrequency']) 
     132                        ->until($start->modify('+1 years')) 
     133                        ->bymonth(array( $timezoneDayligth['standardBymonth'] )) 
     134                        ->byday(array(  $timezoneDayligth['daylightByday'] )); 
     135 
     136                   $date = $r->next(); 
     137 
     138                    $timezone = &$ical->newComponent('vtimezone'); 
     139                    $timezone->setProperty('tzid',$apTimezone ); 
     140 
     141                    $standard  = &$timezone->newComponent( "standard" ); 
     142                    $standard->setProperty( "tzoffsetfrom", $timezoneDayligth['standardFrom'] ); 
     143                    $standard->setProperty( "tzoffsetto", $timezoneDayligth['standardTo'] ); 
     144 
     145 
     146                    $standard->setProperty( "dtstart", $date->format(DATE_RFC822), array("VALUE" => "DATE") ); 
     147 
     148                    $rrule = array( 
     149                        'FREQ' => $timezoneDayligth['standardFrequency'], 
     150                        'BYMONTH' =>  $timezoneDayligth['standardBymonth'], 
     151                        'BYday' => array(preg_replace("/[^0-9]/", "", $timezoneDayligth['standardByday']),  "DAY" => preg_replace("/[^a-zA-Z\s]/", "", $timezoneDayligth['standardByday'])) 
     152                    ); 
     153 
     154                    $standard->setProperty('rrule', $rrule); 
     155 
     156                    $daylight  = &$timezone->newComponent( "daylight" ); 
     157 
     158                    $daylight->setProperty( "tzoffsetfrom", $timezoneDayligth['daylightFrom'] ); 
     159                    $daylight->setProperty( "tzoffsetto", $timezoneDayligth['daylightTo'] ); 
     160 
     161 
     162                    $start = new DateTime('1970-01-01 '.$timezoneDayligth['daylightDtstart']); 
     163 
     164                    $r->recur($start, $timezoneDayligth['daylightFrequency']) 
     165                        ->until($start->modify('+1 years')) 
     166                        ->bymonth(array( $timezoneDayligth['daylightBymonth'] )) 
     167                        ->byday(array(  $timezoneDayligth['daylightByday'] )); 
     168 
     169                    $date = $r->next(); 
     170 
     171                    $daylight->setProperty( "dtstart", $date->format(DATE_RFC822), array("VALUE" => "DATE") ); 
     172 
     173                    $rrule = array( 
     174                        'FREQ' => $timezoneDayligth['daylightFrequency'], 
     175                        'BYMONTH' =>  $timezoneDayligth['daylightBymonth'], 
     176                        'BYday' => array(preg_replace("/[^0-9]/", "", $timezoneDayligth['daylightByday']),  "DAY" => preg_replace("/[^a-zA-Z\s]/", "", $timezoneDayligth['daylightByday'])) 
     177                    ); 
     178 
     179                    $daylight->setProperty('rrule', $rrule); 
     180                } 
     181 
    114182                            break; 
    115183            case TODO_ID: 
     
    352420                foreach ($pRepeat as $ir => $rv) { 
    353421                    if ($rv) { 
    354                         if ($ir == 'frequency' && $rv !== 'none') 
    355                             $repeat['FREQ'] = $rv; 
    356                         else if ($ir == 'endTime') { 
    357                             $time = new DateTime('@' . (int) ($rv / 1000), new DateTimeZone('UTC')); 
    358                             $time->setTimezone($apTimezoneOBJ); 
    359                             $repeat['until'] = $time->format(DATE_RFC822); 
    360                         } else if ($ir == 'count') 
    361                             $repeat[$ir] = $rv; 
    362                         else if ($ir == 'interval') 
    363                             $repeat[$ir] = $rv; 
    364                         else if ($ir !== 'schedulable' && $ir !== 'id' && $ir !== 'startTime') 
    365                             $repeat[$ir] = explode(',', $rv); 
     422                if ($ir == 'frequency' && $rv !== 'none') 
     423                    $repeat['FREQ'] = $rv; 
     424                else if ($ir == 'endTime') { 
     425                    $time = new DateTime('@' . (int) ($rv / 1000), new DateTimeZone('UTC')); 
     426                    $time->setTimezone($apTimezoneOBJ); 
     427                    $repeat['until'] = $time->format(DATE_RFC822); 
     428                }else if ($ir == 'count') 
     429                    $repeat[$ir] = $rv; 
     430                else if ($ir == 'interval') 
     431                    $repeat[$ir] = $rv; 
     432                else if ($ir !== 'schedulable' && $ir !== 'id' && $ir !== 'startTime') 
     433                    $repeat[$ir] = explode(',', $rv); 
    366434                    } 
    367435                } 
Note: See TracChangeset for help on using the changeset viewer.