Changeset 6111


Ignore:
Timestamp:
05/04/12 18:38:56 (12 years ago)
Author:
natan
Message:

Ticket #2141 - Eventos com repeticao nao dispara notificacao nos alarmes - implementação final

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoCalendar/setup/setup.inc.php

    r5953 r6111  
    1313        $setup_info['expressoCalendar']['title']        = 'Expresso Calendar'; 
    1414        /* Ao incrementar versão, não esquecer de declarar função do tables_update.inc.php*/ 
    15         $setup_info['expressoCalendar']['version']      = '1.005'; 
     15        $setup_info['expressoCalendar']['version']      = '1.006'; 
    1616        $setup_info['expressoCalendar']['app_order']    = 10; 
    1717 
  • trunk/expressoCalendar/setup/tables_current.inc.php

    r5994 r6111  
    152152                'id' => array( 'type' => 'auto', 'nullable' => False), 
    153153                'action_id' => array( 'type' => 'int', 'precision' => '8', 'nullable' => False), 
    154                 'range_end' => array( 'type' => 'bigint', 'precision' => '16', 'nullable' => True), 
    155                 'range_start' => array( 'type' => 'bigint', 'precision' => '16', 'nullable' => True), 
    156                 'unit' => array('type' => 'varchar','precision' => '20','nullable' => True), 
     154                'alarm_offset' => array( 'type' => 'bigint', 'precision' => '16', 'nullable' => False), 
    157155                'time' => array('type' => 'varchar','precision' => '50','nullable' => True), 
    158156                'participant_id' => array('type' => 'int', 'precision' => '8','nullable' => True), 
  • trunk/expressoCalendar/setup/tables_update.inc.php

    r5994 r6111  
    107107        }; 
    108108         
    109          
     109        $test[] = '1.005'; 
     110        function expressoCalendar_upgrade1_005() { 
     111            $oProc = $GLOBALS['phpgw_setup']->oProc; 
     112            $oProc->query("ALTER TABLE calendar_alarm ADD COLUMN alarm_offset bigint;"); 
     113            $oProc->query("UPDATE calendar_alarm SET alarm_offset = obj.range_start - calendar_alarm.range_start FROM calendar_object as obj WHERE obj.id = object_id;"); 
     114            $oProc->query("ALTER TABLE calendar_alarm DROP COLUMN range_start;"); 
     115            $oProc->query("ALTER TABLE calendar_alarm DROP COLUMN range_end;"); 
     116            $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.006'; 
     117            return $GLOBALS['setup_info']['expressoCalendar']['currentver']; 
     118        }; 
    110119         
    111120?> 
  • trunk/prototype/Sync.php

    r5905 r6111  
    3636 
    3737               false; 
     38    } 
     39} 
     40 
     41///Conversor Para utf8 ante de codificar para json pois o json so funciona com utf8 
     42if(!function_exists('toUtf8')) 
     43{ 
     44    function toUtf8($data) 
     45    { 
     46        if(!is_array($data)) 
     47          return mb_convert_encoding( $data , 'UTF-8' , 'UTF-8 , ISO-8859-1' ); 
     48 
     49        $return = array(); 
     50 
     51        foreach ($data as $i => $v) 
     52          $return[toUtf8($i)] = toUtf8($v); 
     53 
     54        return $return; 
    3855    } 
    3956} 
     
    128145          } 
    129146          catch( Exception $e ){ 
    130               $return[ $uri ] = $e->getMessage(); 
     147              $return[ $uri ] = toUtf8( $e->getMessage() ); 
    131148              unset( $data[$uri] ); 
    132149              continue; 
  • trunk/prototype/config/alarm.ini

    r5514 r6111  
    2222time = "time" 
    2323sent = "sent" 
    24 rangeStart = "range_start" 
    25 rangeEnd = "range_end" 
     24; rangeStart = "range_start" 
     25; rangeEnd = "range_end" 
    2626unit = "unit" 
    2727participant = "participant_id" 
    2828schedulable = "object_id"    
     29offset = "alarm_offset" 
  • trunk/prototype/config/participant.ini

    r5514 r6111  
    1313schedulable = schedulable.participants 
    1414 
     15[after.find] 
     16deepnessFindParticipant = modules/calendar/interceptors/DBMapping.php 
     17 
     18[after.read] 
     19deepnessReadParticipant = modules/calendar/interceptors/DBMapping.php 
     20 
    1521[after.commit] 
    1622commitParticipant = modules/calendar/interceptors/Notifications.php 
  • trunk/prototype/modules/calendar/alarms.php

    r5724 r6111  
    22 
    33if(!defined('ROOTPATH')) 
    4         define('ROOTPATH', dirname(__FILE__).'/../..'); 
     4    define('ROOTPATH', dirname(__FILE__).'/../..'); 
    55 
    66require_once ROOTPATH.'/api/controller.php'; 
    77require_once ROOTPATH.'/modules/calendar/constants.php'; 
     8require_once ROOTPATH.'/api/parseTPL.php'; 
    89 
    9 $filter = array( 'AND',  
    10           array( '='  , 'sent' , '0') , 
    11           array( '='  , 'type' , ALARM_MAIL) ,   
    12           array( '>=' , 'rangeStart' ,(gmdate('U') - 300 ).'000') , 
    13           array( '<=' , 'rangeEnd' , (gmdate('U') + 86400).'000') 
    14           );  
     10$target = (gmdate('U') - 300 ).'000'; 
    1511 
    16 //Busca os Alarmes no Range 
    17 $al = Controller::find( array('concept' => 'alarm'), false ,array( 'filter' => $filter)); 
     12$parts = Controller::service('PostgreSQL')->execSql("SELECT calendar_participant.user_info_id as user, co.id as schedulable, co.dtend as endTime, co.dtstart as startTime, co.summary as summary, co.tzid as timezone, co.location as location, al.id as id ". 
     13                                                      "FROM calendar_participant, calendar_alarm as al, calendar_object as co, calendar_repeat as rep WHERE ". 
     14                                                      "al.participant_id = calendar_participant.id AND ". 
     15                                                      "calendar_participant.object_id = co.id AND ". 
     16                                                      "al.action_id = '".ALARM_MAIL."' AND ". 
     17                                                      "al.sent = '0' AND ". 
     18                                                      "CASE WHEN rep.object_id = co.id ". 
     19                                                      "THEN  ( select count(occurrence) FROM calendar_repeat_occurrence WHERE rep.object_id = co.id AND rep.id = calendar_repeat_occurrence.repeat_id AND occurrence - al.alarm_offset >= '$target' ) > 0 ". 
     20                                                      "ELSE co.range_start - al.alarm_offset >= '$target' END"); 
    1821 
    19 if(is_array($al)) 
    20 foreach ($al as $i => $v) 
     22if(!is_array($parts)) 
     23  return; 
     24 
     25$ids = array(); 
     26 
     27foreach ($parts as $i => $part) 
    2128{ 
    22         $ev =  Controller::read( array( 'concept' => 'schedulable' , 'id' => $v['schedulable']) ) ; 
    23                  
    24         $unit = 0; 
    25         switch ($v['unit']) { 
    26                 case 'm': $unit = 60; break; 
    27                 case 'H': $unit = 3600; break; 
    28                 case 'd': $unit = 86400; break; } 
    29          
     29        ///Montando lista de participantes 
    3030 
    31         if( strtotime($v['rangeEnd']) >= time() ) // Evento Recursivo ? 
     31        $users = Controller::find( array( 'concept' => 'participant' ) , array( 'user', 'id', 'isExternal' ) ,array('filter' => array ('=', 'schedulable' , $part['schedulable'] ), 'deepness' => 1 ) ); 
     32 
     33        $attList = array(); 
     34 
     35        foreach( $users as $user ) 
    3236        { 
    33                 //TODO: Fazer Acontecer 
    34         }        
    35         else 
    36         {                               
    37                 if((((int)( $ev['startTime'] / 1000 )) - ( $v['time'] * $unit )) < gmmktime() ) //ja esta na hora de mandar o alarme ? 
    38                 {            
    39                         require_once (ROOTPATH.'/api/parseTPL.php' ); 
    40             
    41                         switch ($v['type']) { 
    42                                 case 'mail': 
    43                      
    44                         $part =  Controller::read( array( 'concept' => 'participant' , 'id' => $v['participant']) ); 
    45                         $participants = Controller::find( array( 'concept' => 'participant' ) , false ,array('filter' => array ('=', 'schedulable' , $part['schedulable'] )) );  
    46                      
    47                         if($part['isExternal'] == 1) 
    48                                 $user =  Controller::read( array( 'concept' => 'user' , 'id' => $part['user'] , 'service' => 'PostgreSQL' ) ); 
    49                         else 
    50                                 $user =  Controller::read( array( 'concept' => 'user' , 'id' => $part['user'] ) ); 
    51                                                  
    52                         ///Montando lista de participantes 
    53                             $attList = '<UL> '; 
    54                             $organizer = array(); 
    55                             foreach ($participants as $ii => $participant) 
    56                             { 
    57                                 if($participant['isExternal'] == 1) 
    58                                     $att[$ii] = Controller::read( array( 'concept' => 'user' , 'id' => $participant['user'] , 'service' => 'PostgreSQL' ) ); 
    59                                 else 
    60                                     $att[$ii] = Controller::read( array( 'concept' => 'user' , 'id' => $participant['user'] )); 
     37            if( $part['user'] === $user['user']['id'] ) 
     38                $part['mail'] = $user['user']['mail']; 
    6139 
    62                                 $attList .= '<LI> '.$att[$ii]['name'] .'</LI> '; 
     40            $attList[] = $user['user']['name']; 
     41        } 
    6342 
    64                             } 
    65                             $attList .= '</UL>'; 
    66                         ///////////////////////// 
    67                          
    68                          $timezone = new DateTimeZone('UTC'); 
    69                          $sTime = new DateTime( '@'.(int)($ev['startTime'] / 1000) , $timezone ); 
    70                          $eTime =  new DateTime( '@'.(int)($ev['endTime'] / 1000) , $timezone );  
    71                          if($ev['timezone'])                              
    72                          { 
    73                              $sTime->setTimezone(new DateTimeZone($ev['timezone'])); 
    74                              $eTime->setTimezone(new DateTimeZone($ev['timezone'])); 
    75                          } 
    76                              
    77                           
    78                          $data = array('startDate' =>  date_format( $sTime , 'd/m/Y') , 
    79                                                                   'startTime' =>  date_format( $sTime , 'H:i') , 
    80                                                                   'endDate' =>  date_format( $eTime , 'd/m/Y') , 
    81                                                                   'endTime' =>  date_format( $eTime , 'H:i') , 
    82                                                                   'eventTitle' =>  $ev['summary'], 
    83                                                                   'eventLocation' =>  $ev['location'], 
    84                                                                   'timezone' =>  ($ev['timezone']) ? $ev['timezone'] : 'UTC' , 
    85                                                                   'participants' =>  $attList 
    86                                                                 ); 
    87                           
    88                                                  $mail['isHtml'] = true;                          
    89                                                  $mail['body'] = parseTPL::load_tpl($data,ROOTPATH.'/modules/calendar/templates/notify_alarm_body.tpl'); 
    90                           
    91                                                  $mail['subject'] = 'Alarme de Calendario'; 
    92                                                  $mail['from'] = $user['mail']; 
    93                                                  $mail['to'] = $user['mail']; 
    94                                          
    95     
    96                             Controller::create( array( 'service' => 'SMTP' ), $mail ); 
    97                             Config::regSet('noAlarm', TRUE); //Evita o envio de notificação 
    98                             Controller::update( array( 'concept' => 'alarm' , 'id' => $v['id']) , array('sent' => '1')); 
    99                                         break; 
     43      ///////////////////////// 
    10044 
    101                                 case 'sms': 
    102                                         //Sem suporte atualmente 
    103                                         break; 
     45        $timezone = ($part['timezone']) ? $part['timezone'] : 'UTC'; 
     46        $sTime = new DateTime( '@'.(int)($part['startTime'] / 1000) , new DateTimeZone($timezone) ); 
     47        $eTime =  new DateTime( '@'.(int)($part['endTime'] / 1000) , new DateTimeZone($timezone) ); 
    10448 
    105                         } 
    106                 } 
    107         } 
    108          
     49        $data = array('startDate' =>  date_format( $sTime , 'd/m/Y') , 
     50                      'startTime' =>  date_format( $sTime , 'H:i') , 
     51                      'endDate' =>  date_format( $eTime , 'd/m/Y') , 
     52                      'endTime' =>  date_format( $eTime , 'H:i') , 
     53                      'eventTitle' =>  $part['summary'], 
     54                      'eventLocation' =>  $part['location'], 
     55                      'timezone' => $timezone, 
     56                      'participants' =>  '<UL> <LI> '.implode( '<LI></LI> ', $attList ).'</LI> </UL>'); 
     57 
     58        Controller::create( array( 'service' => 'SMTP' ), array( 'body' => parseTPL::load_tpl( $data, ROOTPATH.'/modules/calendar/templates/notify_alarm_body.tpl' ), 
     59                                                                  'isHtml' => true, 
     60                                                                  'subject' => 'Alarme de Calendario', 
     61                                                                  'from' => $part['mail'], 
     62                                                                  'to' => $part['mail'] ) ); 
     63 
     64        Config::regSet('noAlarm', TRUE); //Evita o envio de notificação ????? 
     65        $ids[] = $part['id']; 
    10966} 
    11067 
     68if( !empty( $ids ) ) 
     69    Controller::update( array( 'concept' => 'alarm' ) , array('sent' => '1'), array( 'IN', 'id', $ids ) ); 
    11170 
    11271?> 
  • trunk/prototype/modules/calendar/interceptors/DBMapping.php

    r6096 r6111  
    117117                } 
    118118 
    119             $sql = ' SELECT calendar_object.id as id ,calendar_object.cal_uid as "uid", calendar_object.type_id as "type", calendar_object.dtstart as "startTime", calendar_object.summary as "summary", calendar_object.description as "description", calendar_object.dtend as "endTime" , calendar_object.location as "location", calendar_object.allday as "allDay", calendar_object.transp as "transparent", calendar_object.class_id as "class", calendar_object.repeat as "repeat", calendar_object.range_start as "rangeStart",calendar_object.range_end as "rangeEnd", calendar_object.last_update as "lastUpdate", calendar_object.dtstamp as "dtstamp", calendar_object.sequence as "sequence",  calendar_object.tzid as "timezone" ,calendar_to_calendar_object.calendar_id as calendar FROM calendar_to_calendar_object , calendar_object WHERE (range_start >= \'' . $start . '\' AND range_end <= \'' . $end . '\' AND calendar_to_calendar_object.calendar_id IN (\'' . implode('\',\'', $criteria['filter'][3][2]) . '\')) AND calendar_to_calendar_object.calendar_object_id = calendar_object.id' . (!empty($ids) ? ' AND calendar_object.id NOT IN (\'' . implode('\',\'', $ids) . '\')' : ''); 
     119            $sql = ' SELECT calendar_object.id as id ,calendar_object.cal_uid as "uid", calendar_object.type_id as "type", calendar_object.dtstart as "startTime", calendar_object.summary as "summary", calendar_object.description as "description", calendar_object.dtend as "endTime" , calendar_object.location as "location", calendar_object.allday as "allDay", calendar_object.transp as "transparent", calendar_object.class_id as "class", calendar_object.repeat as "repeat", calendar_object.range_start as "rangeStart",calendar_object.range_end as "rangeEnd", calendar_object.last_update as "lastUpdate", calendar_object.dtstamp as "dtstamp", calendar_object.sequence as "sequence",  calendar_object.tzid as "timezone" ,calendar_to_calendar_object.calendar_id as calendar FROM calendar_to_calendar_object , calendar_object WHERE (range_start >= \'' . $start . '\' AND range_end <= \'' . $end . '\' AND calendar_to_calendar_object.calendar_id IN (\'' . implode('\',\'', $criteria['filter'][3][2]) . '\')) AND calendar_to_calendar_ 
     120object.calendar_object_id = calendar_object.id' . (!empty($ids) ? ' AND calendar_object.id NOT IN (\'' . implode('\',\'', $ids) . '\')' : ''); 
    120121 
    121122            $params = Controller::service('PostgreSQL')->execResultSql($sql); 
     
    504505 
    505506                if (isset($v['id'])) { 
    506                     $participants = Controller::find(array('concept' => 'participant'), false, array('filter' => array('=', 'schedulable', $v['id']))); 
    507  
    508                     if (is_array($participants) && count($participants) > 0) 
    509                         foreach ($participants as $ii => $vv) { 
    510                             if ($vv['isExternal'] == 1) 
    511                                 $participants[$ii]['user'] = Controller::read(array('concept' => 'user', 'id' => $vv['user'], 'service' => 'PostgreSQL')); 
    512                             else 
    513                                 $participants[$ii]['user'] = Controller::read(array('concept' => 'user', 'id' => $vv['user'])); 
    514  
    515                             if ($participants[$ii]['user']['id'] == Config::me('uidNumber')) 
    516                                 $participants[$ii]['alarms'] = Controller::find(array('concept' => 'alarm'), null, array('filter' => array('AND', array('=', 'participant', $vv['id']), array('=', 'schedulable', $v['id'])))); 
    517                         } 
    518                     $result[$i]['participants'] = $participants; 
    519  
    520  
     507                    $result[$i]['participants'] = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=', 'schedulable'  ,  $v['id']), 'criteria' => array( 'deepness' => $original['criteria']['deepness'] - 1 )));  
    521508 
    522509                    $attachmentRelation = Controller::find(array('concept' => 'schedulableToAttachment'), false, array('filter' => array('=', 'schedulable', $v['id']))); 
     
    568555    } 
    569556 
    570     //TODO: Remover apos suporte a deepness na api 
    571     public function deepnessReadParticipant(&$uri, &$result, &$criteria, $original) { 
    572  
    573         if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) { 
    574             if (isset($result['id'])) { 
    575                 if ($result['isExternal'] == 1) 
    576                     $result['user'] = Controller::read(array('concept' => 'user', 'id' => $result['user'], 'service' => 'PostgreSQL')); 
    577                 else 
    578                     $result['user'] = Controller::read(array('concept' => 'user', 'id' => $result['user'])); 
    579             } 
    580         } 
    581     } 
    582  
    583557    //TODO: Remover apos suporte a deepness na api  
    584     public function deepnessFindParticipant(&$uri, &$result, &$criteria, $original) { 
    585  
    586         if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) { 
    587             foreach ($result as $i => $v) { 
    588                 if (isset($v['id'])) { 
    589                     if ($result[$i]['isExternal'] == 1) 
    590                         $result[$i]['user'] = Controller::read(array('concept' => 'user', 'id' => $result[$i]['user'], 'service' => 'PostgreSQL')); 
    591                     else 
    592                         $result[$i]['user'] = Controller::read(array('concept' => 'user', 'id' => $result[$i]['user'])); 
    593                 } 
    594             } 
    595         } 
    596     } 
     558    public function deepnessReadEvent( &$uri , &$result , &$criteria , $original ){              
     559        
     560       if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 
     561       { 
     562            if(isset($result['id'])) 
     563            { 
     564                $result['participants'] = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=' ,  'schedulable' ,  $result['id']), 'criteria' => array('deepness' => $original['criteria']['deepness'] - 1) ));  
     565 
     566                $repeat =  Controller::find( array( 'concept' => 'repeat' ), false, array( 'filter' => array( '=', 'schedulable', $result['id'] ) ) ); 
     567 
     568                if(is_array($repeat)) 
     569                    $result['repeat'] = $repeat[0]; 
     570            } 
     571       } 
     572   }  
     573    
     574    //TODO: Remover apos suporte a deepness na api  
     575    public function deepnessFindParticipant( &$uri , &$result , &$criteria , $original ){                
     576        
     577       if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 
     578       { 
     579           foreach ($result as $i => &$v) 
     580           { 
     581                self::deepnessReadParticipant( $uri, $v, $criteria, $original ); 
     582           } 
     583       } 
     584        
     585   }  
    597586 
    598587    //TODO: Remover apos suporte a deepness na api  
     
    673662///////////////////////////////////////////////////////////////////////// 
    674663 
    675     static function dayAlarm(&$uri, &$params, &$criteria, $original) { 
    676         if (isset($criteria['filter'][1]) && $criteria['filter'][1] == 'date') { 
    677             $filter = array('AND', 
    678                 array('=', 'sent', '0'), 
    679                 array('=', 'type', ALARM_ALERT), 
    680                 array('>=', 'rangeStart', $criteria['filter'][2]), 
    681                 array('<=', 'rangeEnd', $criteria['filter'][2] + 86400000)); 
    682  
    683             //Busca os Alarmes no Range 
    684             $al = Controller::find(array('concept' => 'alarm'), false, array('filter' => $filter)); 
    685  
    686             if (is_array($al)) 
    687                 foreach ($al as $i => $v) { 
    688                     $ev = Controller::read(array('concept' => 'schedulable', 'id' => $v['schedulable'])); 
    689  
    690                     $unit = 0; 
    691                     switch (strtolower($v['unit'])) { 
    692                         case 'm': $unit = 60; 
    693                             break; 
    694                         case 'H': $unit = 3600; 
    695                             break; 
    696                         case 'd': $unit = 216000; 
    697                             break; 
    698                     } 
    699  
    700                     $al[$i]['sendTime'] = (((int) ( $ev['startTime'] / 1000 )) - ( $v['time'] * $unit )); 
    701                     $al[$i]['schedulable'] = $ev; 
    702                 } 
    703  
    704             $params = $al; 
    705             return false; 
    706         } 
    707     } 
     664    static function dayAlarm( &$uri , &$params , &$criteria , $original ) {      
     665        if(isset($criteria['filter'][1]) && $criteria['filter'][1] == 'date') 
     666        { 
     667            $target = $criteria['filter'][2]; 
     668 
     669            $params = array(); 
     670             
     671            $al = Controller::service('PostgreSQL')->execSql("SELECT co.id as id, co.cal_uid as uid, co.type_id as type, co.dtstart as startTime, co.summary as summary, co.description as description, co.dtend as endTime, co.location as location, co.allday as allDay, co.transp as transparent, co.class_id as class, ". 
     672                                                              "co.range_start as rangeStart, co.range_end as rangeEnd, co.last_update as lastUpdate, co.dtstamp as dtstamp, co.sequence as sequence, co.tzid as timezone, CASE WHEN rep.object_id = co.id THEN occ.occurrence - al.alarm_offset ELSE co.dtstart - al.alarm_offset END as sendTime ". 
     673                                                              "FROM calendar_alarm as al, calendar_object as co, calendar_repeat as rep, calendar_repeat_occurrence as occ, calendar_participant as part WHERE ". 
     674                                                              "al.action_id = '".ALARM_ALERT."' AND al.sent = '0' AND al.participant_id = part.id AND part.object_id = co.id AND ". 
     675                                                              "CASE WHEN rep.object_id = co.id ". 
     676                                                              "THEN rep.id = occ.repeat_id AND occ.occurrence - al.alarm_offset >= '$target' AND occ.occurrence - al.alarm_offset <= '".( $target + 86400000)."' ". 
     677                                                              "ELSE co.range_start - al.alarm_offset >= '$target' AND co.range_start - al.alarm_offset <= '".( $target + 86400000)."' END"); 
     678 
     679            if(is_array($al)) 
     680              foreach( $al as $v ) 
     681              { 
     682                    $params['sendTime'] = $al['sendTime']; 
     683 
     684                    unset( $al['sendTime'] ); 
     685 
     686                    $params['schedulable'] = $al; 
     687              } 
     688            else 
     689              $params = false; 
     690 
     691            return false; 
     692        } 
     693    }  
    708694 
    709695    public function deleteSchedulable(&$uri, &$params, &$criteria, $original) { 
  • trunk/prototype/request.php

    r5399 r6111  
    2929 
    3030///Conversor Para utf8 ante de codificar para json pois o json so funciona com utf8 
    31 function srtToUtf8($data) 
    32 { 
    33     return mb_convert_encoding( $data , 'UTF-8' , 'UTF-8 , ISO-8859-1' ); 
    34 } 
    35  
    3631function toUtf8($data) 
    3732{ 
    38     if(is_array($data)) 
    39     {    
    40         $return = array(); 
    41         foreach ($data as $i => $v) 
    42            $return[srtToUtf8($i)] = (is_array($v)) ? toUtf8($v) : srtToUtf8($v); 
    43          
    44         return $return; 
    45     } 
    46     else 
    47        return srtToUtf8($data); 
     33    if(!is_array($data)) 
     34      return mb_convert_encoding( $data , 'UTF-8' , 'UTF-8 , ISO-8859-1' ); 
     35 
     36    $return = array(); 
     37 
     38    foreach ($data as $i => $v) 
     39      $return[toUtf8($i)] = toUtf8($v); 
     40 
     41    return $return; 
    4842} 
    4943//////////////////////////////////////////////////////////////////////////////////////// 
Note: See TracChangeset for help on using the changeset viewer.