Changeset 3923


Ignore:
Timestamp:
03/28/11 15:09:35 (13 years ago)
Author:
thiagoaos
Message:

Ticket #1684 - Corrigido mecanismo de ordenação do mobile.

Location:
branches/2.2
Files:
4 edited

Legend:

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

    r3922 r3923  
    210210                $head_array['msg_number'] = $msg_number; 
    211211                $head_array['udate'] = $header->udate; 
    212                 $head_array['offsetToGMT'] = $this->functions->CalculateDateOffset(); 
    213  
    214                 $msgTimestamp = $header->udate + $head_array['offsetToGMT']; 
     212                $head_array['offsetToGMT'] = $this->functions->CalculateDateOffset(); 
     213 
     214                $msgTimestamp = $header->udate + $head_array['offsetToGMT']; 
     215                $head_array['timestamp'] = $msgTimestamp; 
     216                 
    215217                $date_msg = gmdate("d/m/Y",$msgTimestamp); 
    216218//              if (date("d/m/Y") == $date_msg) 
     
    32893291                return $return; 
    32903292        } 
    3291          
    3292          
     3293 
     3294 
    32933295        function mobile_search($params) 
    32943296        { 
     
    33063308                        $folders = array(0=>array('folder_id'=>$params['folder'])); 
    33073309                $num_msgs = 0; 
    3308                 $max_msgs = $params['max_msgs']; 
    3309                 $return["total_msgs"] = 0; 
     3310                $max_msgs = $params['max_msgs'] + 1; //get one more because mobile paginate 
     3311                $return["msgs"] = array(); 
     3312                 
     3313                //get max_msgs of each folder order by date and later order all messages together and retur only max_msgs msgs 
    33103314                foreach($folders as $id =>$folder) 
    33113315                { 
    33123316                        if(strpos($folder['folder_id'],'user')===false && is_array($folder)) { 
    33133317                                foreach($criterias as $criteria_fixed) 
    3314                     { 
    3315                         $_filter = $criteria_fixed . ' "'.$params['filter'].'"'; 
     3318                                { 
     3319                                        $_filter = $criteria_fixed . ' "'.$params['filter'].'"'; 
     3320 
    33163321                                        $mbox_stream = $this->open_mbox($folder['folder_id']); 
    3317          
    3318                                         $messages = imap_search($mbox_stream, $_filter, SE_UID); 
     3322 
     3323                                        $messages = imap_sort($mbox_stream,SORTARRIVAL,1,SE_UID,$_filter); 
    33193324                                         
    33203325                                        if ($messages == ''){ 
     
    33233328                                                continue;        
    33243329                                        } 
    3325                                                                          
     3330                                         
    33263331                                        foreach($messages as $msg_number) 
    3327                                         {        
    3328                                                 if($num_msgs>=$max_msgs) 
    3329                                                         break;                           
     3332                                        { 
    33303333                                                $temp = $this->get_info_head_msg($msg_number); 
    33313334                                                if(!$temp) 
    33323335                                                        return false; 
    33333336                                                $temp['msg_folder'] = $folder['folder_id']; 
    3334                                                 $return[$num_msgs] = $temp; 
     3337                                                $return["msgs"][$num_msgs] = $temp; 
    33353338                                                $num_msgs++; 
    3336                                                  
    33373339                                        } 
    3338                                         $return['num_msgs'] = $num_msgs; 
    3339                                         $return["total_msgs"]+=count($messages); 
     3340 
    33403341                                        if($mbox_stream) 
    33413342                                                imap_close($mbox_stream); 
    3342                                         if($num_msgs>=$max_msgs) 
    3343                                                         continue; 
    3344                                 } 
    3345                         }                        
    3346                 } 
     3343                                } 
     3344                        } 
     3345                } 
     3346 
     3347                if(!function_exists("cmp_date")) { 
     3348                        function cmp_date($obj1, $obj2){ 
     3349                    if($obj1['timestamp'] == $obj2['timestamp']) return 0; 
     3350                    return ($obj1['timestamp'] < $obj2['timestamp']) ? 1 : -1; 
     3351                        } 
     3352                } 
     3353                usort($return["msgs"], "cmp_date"); 
     3354                $return["has_more_msg"] = (sizeof($return["msgs"]) > $max_msgs); 
     3355                $return["msgs"] = array_slice($return["msgs"], 0, $max_msgs); 
     3356                 
    33473357                return $return; 
    33483358        } 
  • branches/2.2/mobile/inc/class.common_functions.inc.php

    r3609 r3923  
    11<?php 
    2         /**************************************************************************\ 
    3         * eGroupWare                                                               * 
    4         * http://www.egroupware.org                                                * 
    5         * The file written by Mário César Kolling <mario.kolling@serpro.gov.br>    * 
    6         * --------------------------------------------                             * 
    7         *  This program is free software; you can redistribute it and/or modify it * 
    8         *  under the terms of the GNU General Public License as published by the   * 
    9         *  Free Software Foundation; either version 2 of the License, or (at your  * 
    10         *  option) any later version.                                              * 
    11         \**************************************************************************/ 
     2/**************************************************************************\ 
     3* eGroupWare                                                               * 
     4* http://www.egroupware.org                                                * 
     5* The file written by Mário César Kolling <mario.kolling@serpro.gov.br>    * 
     6* --------------------------------------------                             * 
     7*  This program is free software; you can redistribute it and/or modify it * 
     8*  under the terms of the GNU General Public License as published by the   * 
     9*  Free Software Foundation; either version 2 of the License, or (at your  * 
     10*  option) any later version.                                              * 
     11\**************************************************************************/ 
    1212 
    13         class common_functions 
     13class common_functions 
     14{ 
     15        function borkb($size, $enclosed = NULL)  
    1416        { 
    15             function borkb($size, $enclosed = NULL)  
    16             { 
    17                         if (!$size) 
     17                if (!$size) 
    1818                        $size = 0; 
    19          
    20                         if ($enclosed) 
    21                         { 
    22                                 $left = '('; 
    23                                 $right = ')'; 
     19 
     20                if ($enclosed) 
     21                { 
     22                        $left = '('; 
     23                        $right = ')'; 
     24                } 
     25 
     26                if ($size < 1024) 
     27                        $rstring = $left . $size . ' B' . $right; 
     28                else if ($size < 1048576) 
     29                        $rstring = $left . round($size/1024) . ' KB' . $right; 
     30                else if ($size < 1073741824) 
     31                        $rstring = $left . round($size/1024/1024) . ' MB' . $right; 
     32                else 
     33                        $rstring = $left . round($size/1024/1024/1024) . ' GB' . $right; 
     34 
     35                return $rstring; 
     36        } 
     37 
     38        function complete_string($str = "", $length = 10, $align = "R", $char = " ") { 
     39                if( $str == null ) 
     40                        $str = ""; 
     41                else  
     42                if( strlen($str) > $length ) { 
     43                        return substr($str, 0, $length); 
     44                } else if( strlen($str) == $length ) { 
     45                        return $str; 
     46                }                        
     47 
     48                $char = substr($char, 0, 1); 
     49                $complete_str = ""; 
     50 
     51                while( strlen($str) + strlen($complete_str) < $length  ) 
     52                        $complete_str .= $char; 
     53 
     54                if( $align == "L" ) 
     55                        return $str . $complete_str; 
     56                else 
     57                        return $complete_str . $str; 
     58        }                
     59 
     60        function strach_string($string,$size) { 
     61                return strlen($string)>$size ? substr($string,0,$size)."...": 
     62                $string; 
     63        } 
     64 
     65        /** 
     66        * Fixes the odd indexing of multiple file uploads from the format: 
     67        * 
     68        * $_FILES['field']['key']['index'] 
     69        * 
     70        * To the more standard and appropriate: 
     71        * 
     72        * $_FILES['field']['index']['key'] 
     73        * 
     74        * @param array $files 
     75        * @author Corey Ballou 
     76        * @link http://www.jqueryin.com 
     77        */ 
     78        function fixFilesArray(&$files) 
     79        { 
     80                $names = array( 'name' => 1, 'type' => 1, 'tmp_name' => 1, 'error' => 1, 'size' => 1); 
     81 
     82                foreach ($files as $key => $part) { 
     83                        // only deal with valid keys and multiple files 
     84                        $key = (string) $key; 
     85                        if (isset($names[$key]) && is_array($part)) { 
     86                                foreach ($part as $position => $value) { 
     87                                        $files[$position][$key] = $value; 
     88                                } 
     89                                // remove old key reference 
     90                                unset($files[$key]); 
    2491                        } 
    25          
    26                         if ($size < 1024) 
    27                                 $rstring = $left . $size . ' B' . $right; 
    28                         else if ($size < 1048576) 
    29                                 $rstring = $left . round($size/1024) . ' KB' . $right; 
    30                         else if ($size < 1073741824) 
    31                                 $rstring = $left . round($size/1024/1024) . ' MB' . $right; 
    32                         else 
    33                                 $rstring = $left . round($size/1024/1024/1024) . ' GB' . $right; 
    34          
    35                         return $rstring; 
    3692                } 
    37                  
    38                 function complete_string($str = "", $length = 10, $align = "R", $char = " ") { 
    39                         if( $str == null ) 
    40                                 $str = ""; 
    41                         else  
    42                                 if( strlen($str) > $length ) { 
    43                                         return substr($str, 0, $length); 
    44                                 } else if( strlen($str) == $length ) { 
    45                                         return $str; 
    46                                 }                        
    47          
    48                         $char = substr($char, 0, 1); 
    49                         $complete_str = ""; 
    50          
    51                 while( strlen($str) + strlen($complete_str) < $length  ) 
    52                     $complete_str .= $char; 
    53          
    54                 if( $align == "L" ) 
    55                         return $str . $complete_str; 
    56                 else 
    57                         return $complete_str . $str; 
    58                 }                
    59                  
    60                 function strach_string($string,$size) { 
    61                         return strlen($string)>$size ? substr($string,0,$size)."...": 
    62                                                                                 $string; 
    63                 } 
    64                  
    65                 /** 
    66                  * Fixes the odd indexing of multiple file uploads from the format: 
    67                  * 
    68                  * $_FILES['field']['key']['index'] 
    69                  * 
    70                  * To the more standard and appropriate: 
    71                  * 
    72                  * $_FILES['field']['index']['key'] 
    73                  * 
    74                  * @param array $files 
    75                  * @author Corey Ballou 
    76                  * @link http://www.jqueryin.com 
    77                  */ 
    78                 function fixFilesArray(&$files) 
    79                 { 
    80                     $names = array( 'name' => 1, 'type' => 1, 'tmp_name' => 1, 'error' => 1, 'size' => 1); 
    81                  
    82                     foreach ($files as $key => $part) { 
    83                         // only deal with valid keys and multiple files 
    84                         $key = (string) $key; 
    85                         if (isset($names[$key]) && is_array($part)) { 
    86                             foreach ($part as $position => $value) { 
    87                                 $files[$position][$key] = $value; 
    88                             } 
    89                             // remove old key reference 
    90                             unset($files[$key]); 
    91                         } 
    92                     } 
    93                 } 
    94                  
    95         } //end common class 
    96          
     93        } 
     94 
     95} //end common class 
     96 
    9797 
    9898?> 
  • branches/2.2/mobile/inc/class.ui_home.inc.php

    r3829 r3923  
    232232                                        $p->set_var('next_max_msgs',$mail_params['max_msgs']+10); 
    233233                                        $p->set_var('max_msgs',$mail_params['max_msgs']); 
    234  
     234                                         
    235235                                        $messages = $imap_functions->mobile_search($mail_params); 
    236                                         if($mail_params['max_msgs']>=$messages["total_msgs"]) 
     236                                        if($messages["has_more_msg"]) 
     237                                                $p->set_var('show_more_messages',"block"); 
     238                                        else 
    237239                                                $p->set_var('show_more_messages',"none"); 
    238                                         else 
    239                                                 $p->set_var('show_more_messages',"block"); 
    240                                         $p->set_var('mails',$ui_mobilemail->print_mails_list($messages)); 
     240                                        $p->set_var('mails',$ui_mobilemail->print_mails_list($messages['msgs'])); 
    241241                                } 
    242242                                else { 
  • branches/2.2/mobile/inc/class.ui_mobilemail.inc.php

    r3907 r3923  
    502502                                foreach($messages as $id => $message) { 
    503503                                         
    504                                         if(($id==='num_msgs') ||($id==='total_msgs')) 
     504                                        if(($id==='num_msgs') ||($id==='total_msgs') || ($id==='has_more_msg')) 
    505505                                                continue; 
    506506                                        if($message['from']['name']) 
Note: See TracChangeset for help on using the changeset viewer.