Ignore:
Timestamp:
12/16/11 17:03:00 (12 years ago)
Author:
acoutinho
Message:

Ticket #2385 - Sem acao ao marcar flags em mensagens resultantes de pesquisa rapida

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.imap_functions.inc.php

    r5256 r5264  
    378378        */ 
    379379        function import_msgs($params) { 
     380                 
     381                ob_start(); 
     382                print_r($params); 
     383                $output = ob_get_clean(); 
     384                file_put_contents( "/tmp/acoutinho.log",  $output , FILE_APPEND); 
     385 
     386                 
    380387                if(!$this->mbox) 
    381388                        $this->mbox = $this->open_mbox(); 
    382389 
    383                 if( preg_match('/local_/',$params["folder"]) ) 
    384                 { 
     390                if( preg_match('/local_/',$params["folder"]) ){ 
     391                         
    385392                        // PLEASE, BE CAREFULL!!! YOU SHOULD USE EMAIL CONFIGURATION VALUES (EMAILADMIN MODULE) 
    386393                        $tmp_box = mb_convert_encoding('INBOX'.$this->imap_delimiter.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'].$this->imap_delimiter.'tmpMoveToLocal', "UTF7-IMAP", "UTF-8"); 
    387                         if ( ! imap_createmailbox( $this -> mbox,"{".$this -> imap_server."}$tmp_box" ) ) 
     394                        if ( ! imap_createmailbox( $this->mbox,"{".$this -> imap_server."}$tmp_box" ) ) 
    388395                                return $this->functions->getLang( 'Import to Local : fail...' ); 
    389396                        imap_reopen($this->mbox, "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$tmp_box); 
    390397                        $params["folder"] = $tmp_box; 
    391398                } 
     399                 
    392400                $errors = array(); 
    393401                $invalid_format = false; 
    394402                $filename = $params['FILES'][0]['name']; 
    395                 $params["folder"] = mb_convert_encoding($params["folder"], "UTF7-IMAP","ISO_8859-1"); 
     403                $params["folder"] = mb_convert_encoding($params["folder"], "UTF7-IMAP","ISO-8859-1, UTF-8"); 
    396404                $quota = imap_get_quotaroot($this->mbox, $params["folder"]); 
     405                 
    397406                if((($quota['limit'] - $quota['usage'])*1024) <= $params['FILES'][0]['size']){ 
    398407                        return array( 'error' => $this->functions->getLang("fail in import:"). 
    399408                                                        " ".$this->functions->getLang("Over quota")); 
    400409                } 
     410                 
    401411                if(substr($filename,strlen($filename)-4)==".zip") { 
    402412                        $zip = zip_open($params['FILES'][0]['tmp_name']); 
    403  
    404413                        if ($zip) { 
    405414                                while ($zip_entry = zip_read($zip)) { 
     
    418427                                zip_close($zip); 
    419428                        } 
    420  
    421                         if ( isset( $tmp_box ) && ! sizeof( $errors ) ) 
    422                         { 
    423  
     429                        if (isset( $tmp_box ) && ! sizeof( $errors )){ 
    424430                                $mc = imap_check($this->mbox); 
    425  
    426431                                $result = imap_fetch_overview( $this -> mbox, "1:{$mc -> Nmsgs}", 0 ); 
    427  
    428432                                $ids = array( ); 
    429433                                foreach ($result as $overview) 
    430434                                        $ids[ ] = $overview -> uid; 
    431  
    432435                                return implode( ',', $ids ); 
    433436                        } 
    434                         } 
    435                 else if(substr($filename,strlen($filename)-4)==".eml") { 
     437                 
     438                }else if(substr($filename,strlen($filename)-4)==".eml") { 
    436439                        $email = implode("",file($params['FILES'][0]['tmp_name'])); 
    437                         $status = @imap_append($this->mbox, 
    438                                                                 "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$params["folder"], 
    439                                                                         $email 
    440                                                                         ); 
    441                         if(!$status) { 
    442                                 //TODO: remover zip_entry pois ele é tratado apenas ao importar mensagens zipadas 
    443                                 array_push($errors,zip_entry_name($zip_entry)); 
    444                                 zip_entry_close($zip_entry); 
    445                         } 
     440                        $status = imap_append($this->mbox,"{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$params["folder"],$email); 
     441                         
     442                         
     443                        ob_start(); 
     444                        var_dump($status); 
     445                        print($email);                   
     446                        $output = ob_get_clean(); 
     447                        file_put_contents( "/tmp/acoutinho.log",  $output , FILE_APPEND); 
     448                         
     449                        if(!$status) 
     450                                return "Deu Pau :("; 
    446451                         
    447452                        if ( isset( $tmp_box ) && ! sizeof( $errors ) ) { 
     
    457462                        } 
    458463                } 
    459                 else 
    460                 { 
     464                else{ 
    461465                        if ( isset( $tmp_box ) ) 
    462466                                imap_deletemailbox( $this->mbox,"{".$this -> imap_server."}$tmp_box" ); 
     
    38303834        } 
    38313835 
     3836         
     3837        function set_messages_flag_from_search($params){                 
     3838                $error = False; 
     3839                $fileNames = ""; 
     3840                 
     3841                $sel_msgs = explode(",", $params['msg_to_flag']); 
     3842                @reset($sel_msgs); 
     3843                $sorted_msgs = array(); 
     3844                foreach($sel_msgs as $idx => $sel_msg) { 
     3845                        $sel_msg = explode(";", $sel_msg); 
     3846                        if(array_key_exists($sel_msg[0], $sorted_msgs)){ 
     3847                                $sorted_msgs[$sel_msg[0]] .= ",".$sel_msg[1]; 
     3848                        } 
     3849                        else { 
     3850                                $sorted_msgs[$sel_msg[0]] = $sel_msg[1]; 
     3851                        } 
     3852                } 
     3853                unset($sorted_msgs['']);                         
     3854                $array_names_keys = array_keys($sorted_msgs);    
     3855                // Verifica se as n mensagens selecionadas 
     3856                // se encontram em um mesmo folder 
     3857                if (count($sorted_msgs)==1){ 
     3858                        $param['folder'] = $array_names_keys[0]; 
     3859                        $param['msgs_to_set'] = $sorted_msgs[$array_names_keys[0]]; 
     3860                        $param['flag'] = $params['flag']; 
     3861                        $returns[0] = $this->set_messages_flag($param); 
     3862                        return $returns; 
     3863                }else{ 
     3864                        for($i = 0; $i < count($array_names_keys); $i++){  
     3865                                $param['folder'] = $array_names_keys[$i]; 
     3866                                $param['msgs_to_set'] = $sorted_msgs[$array_names_keys[$i]]; 
     3867                                $param['flag'] = $params['flag']; 
     3868                                $returns[$i] = $this->set_messages_flag($param); 
     3869                } 
     3870        } 
     3871        return $returns; 
     3872} 
    38323873        function set_messages_flag($params) 
    3833         {          
    3834                 $folder = $params['folder']; 
     3874        {                
     3875                $folder = mb_convert_encoding($params['folder'], "UTF7-IMAP","UTF-8, ISO-8859-1, UTF7-IMAP"); 
    38353876                $msgs_to_set = $params['msgs_to_set']; 
    38363877                $flag = $params['flag']; 
     
    38403881                $return["msgs_not_to_set"] = ""; 
    38413882                         
    3842                 if(!$this->mbox && !is_resource($this->mbox)) 
    3843                         $this->mbox = $this->open_mbox($folder); 
     3883                $this->mbox = $this->open_mbox($folder); 
    38443884                         
    38453885                if ($flag == "unseen"){ 
Note: See TracChangeset for help on using the changeset viewer.