Changeset 3493


Ignore:
Timestamp:
11/10/10 16:07:09 (13 years ago)
Author:
rafaelraymundo
Message:

Ticket #1322 - Data incorreta nas mensagens na caixa de entrada.

Location:
branches/2.2/expressoMail1_2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/expressoMail1_2/inc/class.functions.inc.php

    r3018 r3493  
    11<?php 
    22        class Functions{ 
     3 
     4                // get the offset against GMT. 
     5                function CalculateDateOffset() 
     6                { 
     7 
     8                    $timezone_index = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['timezone']; 
     9                    $zones = $this->getTimezones(); 
     10                    $user_timezone = $zones[$timezone_index]; 
     11                    $tz = new DateTimeZone($user_timezone); 
     12                    $gmt = new DateTimeZone("Etc/GMT+0"); 
     13                    $gmttime = new DateTime("now", $gmt); 
     14                    $offset = $tz->getOffset($gmttime); 
     15                    return $offset; 
     16 
     17                } 
     18 
     19                function getTimezones() 
     20                { 
     21                    $zones = timezone_identifiers_list(); 
     22                    $friendly_zones = array(); 
     23                    foreach ($zones as $zone) 
     24                    { 
     25                        if (preg_match("/^(Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)\/.*$/", $zone)) 
     26                        { 
     27                            array_push($friendly_zones,  $zone); 
     28                        } 
     29 
     30                    } 
     31                    return $friendly_zones; 
     32                } 
     33 
    334                function CallVoipConnect($params){ 
    435                        $fromNumber = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number']; 
  • branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php

    r3427 r3493  
    109109                $search_box_type = $params['search_box_type'] != "ALL" && $params['search_box_type'] != "" ? $params['search_box_type'] : false; 
    110110 
    111                 if(!$this->mbox || !is_resource($this->mbox)) 
     111                if(!$this->mbox || !is_resource($this->mbox)) 
    112112                        $this->mbox = $this->open_mbox($folder); 
    113113 
    114114                $return = array(); 
     115                // Para enviar o offset entre o timezone definido pelo usuário e GMT 
     116                $return['offsetToGMT'] = $this->functions->CalculateDateOffset(); 
    115117                 
    116118                if(!$search_box_type || $search_box_type=="UNSEEN" || $search_box_type=="SEEN") { 
     
    531533                        //return $return; 
    532534                }else{ 
    533             $return['body']             = $body; 
    534             $return['attachments']      = $return_get_body['attachments']; 
    535             $return['thumbs']           = $return_get_body['thumbs']; 
    536             $return['signature']        = $return_get_body['signature']; 
     535                    $return['body']             = $body; 
     536                    $return['attachments']      = $return_get_body['attachments']; 
     537                    $return['thumbs']           = $return_get_body['thumbs']; 
     538                    $return['signature']        = $return_get_body['signature']; 
    537539                } 
    538540 
     
    562564                $return['msg_folder'] = $msg_folder; 
    563565 
    564                 $date_msg = gmdate("d/m/Y",$header->udate); 
     566                $offset = $this->functions->CalculateDateOffset(); 
     567                $msgTimestamp = $header->udate + $offset; 
     568 
     569                $date_msg = gmdate("d/m/Y",$msgTimestamp); 
    565570                if (date("d/m/Y") == $date_msg) 
    566                         $return['udate'] = gmdate("H:i",$header->udate); 
     571                        $return['udate'] = gmdate("H:i",$msgTimestamp); 
    567572                else 
    568573                        $return['udate'] = $date_msg; 
    569574 
    570575                $return['msg_day'] = $date_msg; 
    571                 $return['msg_hour'] = gmdate("H:i",$header->udate); 
     576                $return['msg_hour'] = gmdate("H:i",$msgTimestamp); 
    572577 
    573578                if (date("d/m/Y") == $date_msg) //no dia 
    574579                { 
    575                         $return['fulldate'] = gmdate("d/m/Y H:i",$header->udate); 
    576                         $return['smalldate'] = gmdate("H:i",$header->udate); 
     580                        $return['fulldate'] = gmdate("d/m/Y H:i",$msgTimestamp); 
     581                        $return['smalldate'] = gmdate("H:i",$msgTimestamp); 
    577582 
    578583                        $timestamp_now = strtotime("now"); 
    579                         $timestamp_msg_time = $header->udate; 
    580                         // $timestamp_now is GMT and $timestamp_msg_time is MailDate TZ. 
     584                        $timestamp_msg_time = $msgTimestamp; 
     585                        // $timestamp_now and $timestamp_msg_time are GMT. 
    581586                        // The variable $timestamp_diff is calculated without MailDate TZ. 
    582                         $pdate = date_parse($header->MailDate); 
    583                         $timestamp_diff = $timestamp_now - $timestamp_msg_time  + ($pdate['zone']*(-60)); 
     587                        $timestamp_diff = $timestamp_now - $timestamp_msg_time; 
    584588 
    585589                        if (gmdate("H",$timestamp_diff) > 0) 
     
    601605                } 
    602606                else{ 
    603                         $return['fulldate'] = gmdate("d/m/Y H:i",$header->udate); 
    604                         $return['smalldate'] = gmdate("d/m/Y",$header->udate); 
     607                        $return['fulldate'] = gmdate("d/m/Y H:i",$msgTimestamp); 
     608                        $return['smalldate'] = gmdate("d/m/Y",$msgTimestamp); 
    605609                } 
    606610 
     
    16201624                $return['new_msgs'] = imap_num_recent($this->mbox); 
    16211625                $return['msgs_to_delete'] = $msg_to_delete; 
     1626                $return['offsetToGMT'] = $this->functions->CalculateDateOffset(); 
    16221627                if($this->mbox && is_resource($this->mbox)) 
    16231628                        imap_close($this->mbox); 
     
    32933298                } 
    32943299 
     3300                $offsetToGMT = $this->functions->CalculateDateOffset(); 
     3301 
    32953302                if($search){ 
    32963303                        $search_criteria = ''; 
     
    34593466                if($header->from[0]->personal != "") 
    34603467                        $from = $header->from[0]->personal; 
    3461                 $ret_msg = $this->decode_string($from) . "--" . $subject . "--". gmdate("d/m/Y",$header ->udate)."--". $this->size_msg($header->Size) ."--". $flag; 
     3468                $ret_msg = $this->decode_string($from) . "--" . $subject . "--". gmdate("d/m/Y",$header ->udate + $this->functions->CalculateDateOffset())."--". $this->size_msg($header->Size) ."--". $flag; 
    34623469                return $ret_msg; 
    34633470        } 
     
    37063713        } 
    37073714        function get_header($msg_number){ 
    3708                 $header = @imap_headerinfo($this->mbox, imap_msgno($this->mbox, $msg_number), 80, 255); 
     3715                $header = @imap_headerinfo($this->mbox, imap_msgno($this->mbox, $msg_number), 80, 255); 
    37093716                if (!is_object($header)) 
    37103717                        return false; 
    3711                 // Prepare udate from mailDate (DateTime arrived with TZ) for fixing summertime problem. 
    3712                 $header->udate_original = $header->udate; 
    3713                 $pdate = date_parse($header->MailDate); 
    3714                 $header->udate +=  $pdate['zone']*(-60); 
    37153718 
    37163719                if($header->Flagged != "F" && $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) { 
  • branches/2.2/expressoMail1_2/inc/hook_settings.inc.php

    r3414 r3493  
    2020        \**************************************************************************/ 
    2121include_once("fckeditor.php"); 
     22include_once("class.functions.inc.php"); 
    2223$type = isset($_GET['type']) ? $_GET['type']:$GLOBALS['type']; // FIX ME 
    2324 
     
    211212create_check_box('Use shortcuts?','use_shortcuts','n key (Open new message)<br>ESC key (Close tab)<br>i key (print)<br>e key (forward)<br>r key (reply)<br>DELETE key (delete the current message)<br>Ctrl + up (go to previous message)<br>Ctrl + down (go to next message)<br>Shift + up or down (select multiple messages)<br>F9  key (search at catalog)<br>'); 
    212213create_check_box('Auto save draft','auto_save_draft','When you are away from computer it saves automatically the message you are writing'); 
     214 
     215unset($default); 
     216$functions = new functions(); 
     217$zones = $functions->getTimezones(); 
     218$default = array(sprintf("%s", array_search('America/Sao_Paulo', $zones)) => 'America/Sao_Paulo'); 
     219create_select_box('What is your timezone?', 'timezone', $zones, 'The Timezone you\'re in.', $default); 
     220 
    213221$default = array( 
    214222        '65536' => lang('unlimited'), 
  • branches/2.2/expressoMail1_2/index.php

    r3414 r3493  
    7676        $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'] = $current_config['expressoMail_Number_of_dynamic_contacts'] ? $current_config['expressoMail_Number_of_dynamic_contacts'] : "0"; 
    7777        $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['notification_domains'] = $current_config['expressoMail_notification_domains']; 
    78         $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['googlegears_url'] = $current_config['expressoMail_googlegears_url'];     
     78        $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['googlegears_url'] = $current_config['expressoMail_googlegears_url']; 
    7979    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_assinar_criptografar'] = $GLOBALS['phpgw_info']['server']['use_assinar_criptografar'] ?  $GLOBALS['phpgw_info']['server']['use_assinar_criptografar'] : "0"; 
    8080    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital_cripto'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital_cripto'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital_cripto'] : "0"; 
     
    178178 
    179179        $obj = createobject("expressoMail1_2.functions"); 
     180 
     181        // setting timezone preference 
     182        $zones = $obj->getTimezones(); 
     183        $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['timezone'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['timezone'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['timezone'] : sprintf("%s", array_search("America/Sao_Paulo", $zones)); 
     184 
    180185        // este arquivo deve ser carregado antes que 
    181186        // os demais pois nele contem a função get_lang 
    182187        // que é utilizada em diversas partes 
    183188        echo $obj -> getFilesJs("js/common_functions.js"); 
    184         include("inc/load_lang.php");  
    185  
    186         // INCLUDE these JS Files: 
     189        include("inc/load_lang.php"); 
     190 
     191        // INCLUDE these JS Files: 
    187192        if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages'])  
    188193                echo "<script src='js/gears_init.js'></script>"; 
  • branches/2.2/expressoMail1_2/js/draw_api.js

    r3459 r3493  
    789789                        tbody_element.appendChild(td_info); 
    790790                } 
    791  
    792  
    793791        for (var i=0; i < headers_msgs.length; i++){ 
    794792                        if ((headers_msgs[i].Unseen == 'U') || (headers_msgs[i].Recent == 'N')) 
    795793                                f_unseen++; 
    796                         tr_element = make_tr_message(headers_msgs[i], msg_folder); 
     794                        tr_element = make_tr_message(headers_msgs[i], msg_folder, headers_msgs.offsetToGMT); 
    797795                        if (tr_element){ 
    798796                                tbody_element.appendChild(tr_element); 
     
    838836} 
    839837 
    840 function make_tr_message(headers_msgs, msg_folder){ 
     838// Passar o parâmetro offset para esta função 
     839function make_tr_message(headers_msgs, msg_folder, offsetToGMT){ 
     840                if (typeof offsetToGMT == 'undefined') 
     841                { 
     842                    offsetToGMT = 0; 
     843                } 
    841844                var tr_element = document.createElement('tr'); 
    842845                if(typeof(preferences.line_height) != 'undefined') 
     
    10521055                var norm = function (arg) {return (arg < 10 ? '0'+arg : arg);}; 
    10531056                var weekDays = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; 
    1054                 var date_msg = new Date(headers_msgs.udate*1000); 
    1055                 var today = new Date(); 
     1057 
     1058                var today = new Date(); 
    10561059                today.setHours(0); 
    10571060                today.setMinutes(0); 
    1058                 if (today.getTime() - date_msg.getTime() < 86400000) 
     1061 
     1062                 // Using offset between user defined timezone and GMT 
     1063                 // Date object converts time to local timezone, so we have to adjust it 
     1064                var udate_local = headers_msgs.udate*1000 + offsetToGMT*1000 + today.getTimezoneOffset()*60*1000; 
     1065                var date_msg = new Date(udate_local); 
     1066 
     1067                if (today.getTime() - date_msg.getTime() < 86400000) 
    10591068                        td_element5.innerHTML = norm(date_msg.getHours()) + ':' + norm(date_msg.getMinutes()); 
    10601069                else 
     
    28912900        var tbody = Element('tbody_box'); 
    28922901        for (var i=0; i<(headers_msgs.length); i++){ 
     2902            // passa parâmetro offset 
    28932903                var tr = this.make_tr_message(headers_msgs[i], headers_msgs[i].msg_folder); 
    28942904                if (tr) 
  • branches/2.2/expressoMail1_2/js/main.js

    r3427 r3493  
    433433                                if (!existent) 
    434434                                { 
    435                                         var new_msg = this.make_tr_message(data[i], current_folder); 
     435                                        var new_msg = this.make_tr_message(data[i], current_folder, data.offsetToGMT); 
    436436                                        _dragArea.makeDragged(new_msg, data[i].msg_number, data[i].subject, true); 
    437437                                        if (data[i].Recent == 'N') 
  • branches/2.2/expressoMail1_2/setup/phpgw_en.lang

    r3441 r3493  
    362362The size of the message is      expressoMail1_2 en      The size of the message is 
    363363The size of this message has exceeded  the limit (%1B). expressoMail1_2 en      The size of this message has exceeded  the limit (%1B). 
     364The Timezone you're in. expressoMail1_2 en      The Timezone you're in. 
    364365This mail box is empty  expressoMail1_2 en      This mail box is empty. 
    365366This message is already opened! expressoMail1_2 en      This message is already opened! 
     
    399400What is the maximum number of results in an e-mail search?      expressoMail1_2 en      What is the maximum number of results in an e-mail search? 
    400401What is the minimum number of characters in searching contacts? expressoMail1_2 en      What is the minimum number of characters in searching contacts? 
     402What is your timezone?  expressoMail1_2 en      What is your timezone? 
    401403Who     expressoMail1_2 en      Who 
    402404With all        expressoMail1_2 en      With all 
  • branches/2.2/expressoMail1_2/setup/phpgw_pt-br.lang

    r3441 r3493  
    506506The size of the message is      expressoMail1_2 pt-br   O tamanho da mensagem seja 
    507507The size of this message has exceeded  the limit (%1B). expressoMail1_2 pt-br   O tamanho desta mensagem excedeu o limite (maior que %1B). 
     508The Timezone you're in. expressoMail1_2 pt-br   O fuso-horário em que você está. 
    508509This is the number of messages shown in your mailbox per page   expressoMail1_2 pt-br   Este é o número de mensagens mostradas na sua caixa de correio por página 
    509510This list has no participants   expressoMail1_2 pt-br   Esta lista nao possui nenhum participante. 
     
    556557What is the maximum size of embedded images?    expressoMail1_2 pt-br   Qual o tamanho máximo das imagens inseridas nos emails? 
    557558What is the minimum number of characters in searching contacts? expressoMail1_2 pt-br   Qual é o número mínimo de caracteres ao pesquisar contatos? 
     559What is your timezone?  expressoMail1_2 pt-br   Qual o seu fuso-horário? 
    558560When delete message, send it automatically to trash folder      expressoMail1_2 pt-br   Ao excluir um mensagem, mover automaticamente esta mensagem para a pasta lixeira 
    559561When user send an email with image in body message, it changes the size expressoMail1_2 pt-br   Quando o usuário envia um e-mail com a imagem no corpo da mensagem, ela muda o tamanho 
Note: See TracChangeset for help on using the changeset viewer.