Changeset 7740 for sandbox


Ignore:
Timestamp:
01/14/13 10:29:47 (11 years ago)
Author:
pereira.jair
Message:

Ticket #2507 - Correção do Resource EventsResource? que retornava valores incorretos.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/rest/calendar/EventsResource.php

    r7489 r7740  
    2929                         
    3030                        $return = array(); 
    31                          
    32                         for( $j = (int)$start_date_arr[2]; $j <= (int)$end_date_arr[2]; $j++ ) 
     31 
     32 
     33                        $start_year = (int)$start_date_arr[2]; 
     34            $end_year = (int)$end_date_arr[2]; 
     35 
     36                        for( $j = $start_year; $j <= $end_year; $j++ ) 
    3337                        { 
    34                                 for( $i = (int)$start_date_arr[1]; $i <= (int)$end_date_arr[1]; $i++ ) 
     38                                $start_month = (int)$start_date_arr[1]; 
     39                                $end_month = (int)$end_date_arr[1]; 
     40 
     41                                if ($start_year != $end_year) { 
     42                                        if ($j == $start_year) { 
     43                                                $end_month = 12; 
     44                                        } else { 
     45                                                $start_month = 1; 
     46                                        } 
     47                                }        
     48 
     49                                for( $i = $start_month; $i <= $end_month; $i++ ) 
    3550                                { 
    3651                                        if( (int)$i < 10 ) 
     
    3853                                        else 
    3954                                                $result = $this->getEvents($i,$j); 
    40                                          
     55 
     56 
    4157                                        if( count($result) > 0 ) 
    4258                                        { 
     
    4662                        } 
    4763 
     64 
     65 
    4866                        if( count($return) > 0 ) 
    4967                        { 
     
    5270                                for( $j = 0 ; $j < count( $return); $j++) 
    5371                                { 
    54                                         foreach( $return[$j] as $key => $value ) 
     72                                        foreach( $return[$j] as $key => $event ) 
    5573                                        { 
    56                                                 $events[$i]['eventID']                  = "".$value[0]['id']; 
    57                                                 $events[$i]['eventDate']                = "".$key; 
    58                                                 $events[$i]['eventName']                = mb_convert_encoding("".$value[0]['title'],"UTF8","ISO_8859-1"); 
    59                                                 $events[$i]['eventDescription'] = mb_convert_encoding("".$value[0]['description'], "UTF8","ISO_8859-1"); 
    60                                                 $events[$i]['eventLocation']    = mb_convert_encoding("".$value[0]['location'], "UTF8","ISO_8859-1"); 
    61                                                 $events[$i]['eventParticipants']= $value[0]['participants']; 
    62                                                  
    63                                                 $starttime      = $this->makeTime($value[0]['start']); 
    64                                                 $endtime        = $this->makeTime($value[0]['end']); 
    65                                                 $actualdate = mktime(0,0,0,substr($key,4,2),substr($key, 6 ),substr($key,0,4)); 
    66                                                 $rawdate_offset = $actualdate - $this->getTimezoneOffset(); 
    67                                                 $nextday = mktime(0,0,0,substr($key,4,2),substr($key, 6 )+1,substr($key,0,4)) - $this->getTimezoneOffset(); 
    68                                                  
    69                                                 if( $starttime <= $rawdate_offset && $endtime >= $nextday - 60 ) 
    70                                                 { 
    71                                                         $events[$i]['eventStartDate']   = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." 00:00"; 
    72                                                         $events[$i]['eventEndDate']             = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." 23:59"; 
    73                                                         $events[$i]['eventAllDay']              = "1"; 
    74                                                 } 
    75                                                 else 
    76                                                 { 
    77                                                         if( $value[0]['start']['mday'] === $value[0]['end']['mday'] ) 
     74 
     75                                                foreach ($event as $value) { 
     76 
     77 
     78                                                        $events[$i]['eventID']                  = "".$value['id']; 
     79                                                        $events[$i]['eventDate']                = "".$key; 
     80                                                        $events[$i]['eventName']                = mb_convert_encoding("".$value['title'],"UTF8","ISO_8859-1"); 
     81                                                        $events[$i]['eventDescription'] = mb_convert_encoding("".$value['description'], "UTF8","ISO_8859-1"); 
     82                                                        $events[$i]['eventLocation']    = mb_convert_encoding("".$value['location'], "UTF8","ISO_8859-1"); 
     83                                                        $events[$i]['eventParticipants']= $value['participants']; 
     84 
     85                                                        $starttime      = $this->makeTime($value['start']); 
     86                                                        $endtime        = $this->makeTime($value['end']); 
     87                                                        $actualdate = mktime(0,0,0,substr($key,4,2),substr($key, 6 ),substr($key,0,4)); 
     88                                                        $rawdate_offset = $actualdate - $this->getTimezoneOffset(); 
     89                                                        $nextday = mktime(0,0,0,substr($key,4,2),substr($key, 6 )+1,substr($key,0,4)) - $this->getTimezoneOffset(); 
     90 
     91                                                        if( $starttime <= $rawdate_offset && $endtime >= $nextday - 60 ) 
    7892                                                        { 
    79                                                                 $hour_start     = (((int)$value[0]['start']['hour'] < 10 ) ? "0".$value[0]['start']['hour'] : $value[0]['start']['hour']).":".(((int)$value[0]['start']['min'] < 10 ) ? "0".$value[0]['start']['min'] : $value[0]['start']['min'] ); 
    80                                                                 $hour_end       = (((int)$value[0]['end']['hour'] < 10 ) ? "0".$value[0]['end']['hour'] : $value[0]['end']['hour']).":".(((int)$value[0]['end']['min'] < 10 ) ? "0".$value[0]['end']['min'] : $value[0]['end']['min'] ); 
     93                                                                $events[$i]['eventStartDate']   = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." 00:00"; 
     94                                                                $events[$i]['eventEndDate']             = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." 23:59"; 
     95                                                                $events[$i]['eventAllDay']              = "1"; 
    8196                                                        } 
    8297                                                        else 
    8398                                                        { 
    84                                                                 if( $events[$i-1] && $events[$i-1]['eventAllDay'] == "1" ) 
     99                                                                if( $value['start']['mday'] === $value['end']['mday'] ) 
    85100                                                                { 
    86                                                                         $hour_start     = "00:00"; 
    87                                                                         $hour_end       = (((int)$value[0]['end']['hour'] < 10 ) ? "0".$value[0]['end']['hour'] : $value[0]['end']['hour']).":".(((int)$value[0]['end']['min'] < 10 ) ? "0".$value[0]['end']['min'] : $value[0]['end']['min'] ); 
     101                                                                        $hour_start     = (((int)$value['start']['hour'] < 10 ) ? "0".$value['start']['hour'] : $value['start']['hour']).":".(((int)$value['start']['min'] < 10 ) ? "0".$value['start']['min'] : $value['start']['min'] ); 
     102                                                                        $hour_end       = (((int)$value['end']['hour'] < 10 ) ? "0".$value['end']['hour'] : $value['end']['hour']).":".(((int)$value['end']['min'] < 10 ) ? "0".$value['end']['min'] : $value['end']['min'] ); 
    88103                                                                } 
    89104                                                                else 
    90105                                                                { 
    91                                                                         $hour_start     = (((int)$value[0]['start']['hour'] < 10 ) ? "0".$value[0]['start']['hour'] : $value[0]['start']['hour']).":".(((int)$value[0]['start']['min'] < 10 ) ? "0".$value[0]['start']['min'] : $value[0]['start']['min'] ); 
    92                                                                         $hour_end       = "23:59"; 
     106                                                                        if( $events[$i-1] && $events[$i-1]['eventAllDay'] == "1" ) 
     107                                                                        { 
     108                                                                                $hour_start     = "00:00"; 
     109                                                                                $hour_end       = (((int)$value['end']['hour'] < 10 ) ? "0".$value['end']['hour'] : $value['end']['hour']).":".(((int)$value['end']['min'] < 10 ) ? "0".$value['end']['min'] : $value['end']['min'] ); 
     110                                                                        } 
     111                                                                        else 
     112                                                                        { 
     113                                                                                $hour_start     = (((int)$value['start']['hour'] < 10 ) ? "0".$value['start']['hour'] : $value['start']['hour']).":".(((int)$value['start']['min'] < 10 ) ? "0".$value['start']['min'] : $value['start']['min'] ); 
     114                                                                                $hour_end       = "23:59"; 
     115                                                                        } 
    93116                                                                } 
     117 
     118                                                                $events[$i]['eventStartDate']   = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." ".$hour_start; 
     119                                                                $events[$i]['eventEndDate']             = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." ".$hour_end; 
     120                                                                $events[$i]['eventAllDay']              = "0"; 
    94121                                                        } 
    95                                                                  
    96                                                         $events[$i]['eventStartDate']   = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." ".$hour_start; 
    97                                                         $events[$i]['eventEndDate']             = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." ".$hour_end; 
    98                                                         $events[$i]['eventAllDay']              = "0"; 
     122 
     123                                                        $events[$i++]['eventExParticipants'] = $value['ex_participants']; 
    99124                                                } 
    100                                                  
    101                                                 $events[$i++]['eventExParticipants'] = $value[0]['ex_participants']; 
     125 
    102126                                        } 
     127 
    103128                                } 
    104129 
Note: See TracChangeset for help on using the changeset viewer.