Changeset 5264 for trunk/expressoMail1_2/inc/class.imap_functions.inc.php
- Timestamp:
- 12/16/11 17:03:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r5256 r5264 378 378 */ 379 379 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 380 387 if(!$this->mbox) 381 388 $this->mbox = $this->open_mbox(); 382 389 383 if( preg_match('/local_/',$params["folder"]) ) 384 {390 if( preg_match('/local_/',$params["folder"]) ){ 391 385 392 // PLEASE, BE CAREFULL!!! YOU SHOULD USE EMAIL CONFIGURATION VALUES (EMAILADMIN MODULE) 386 393 $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" ) ) 388 395 return $this->functions->getLang( 'Import to Local : fail...' ); 389 396 imap_reopen($this->mbox, "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$tmp_box); 390 397 $params["folder"] = $tmp_box; 391 398 } 399 392 400 $errors = array(); 393 401 $invalid_format = false; 394 402 $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"); 396 404 $quota = imap_get_quotaroot($this->mbox, $params["folder"]); 405 397 406 if((($quota['limit'] - $quota['usage'])*1024) <= $params['FILES'][0]['size']){ 398 407 return array( 'error' => $this->functions->getLang("fail in import:"). 399 408 " ".$this->functions->getLang("Over quota")); 400 409 } 410 401 411 if(substr($filename,strlen($filename)-4)==".zip") { 402 412 $zip = zip_open($params['FILES'][0]['tmp_name']); 403 404 413 if ($zip) { 405 414 while ($zip_entry = zip_read($zip)) { … … 418 427 zip_close($zip); 419 428 } 420 421 if ( isset( $tmp_box ) && ! sizeof( $errors ) ) 422 { 423 429 if (isset( $tmp_box ) && ! sizeof( $errors )){ 424 430 $mc = imap_check($this->mbox); 425 426 431 $result = imap_fetch_overview( $this -> mbox, "1:{$mc -> Nmsgs}", 0 ); 427 428 432 $ids = array( ); 429 433 foreach ($result as $overview) 430 434 $ids[ ] = $overview -> uid; 431 432 435 return implode( ',', $ids ); 433 436 } 434 }435 else if(substr($filename,strlen($filename)-4)==".eml") {437 438 }else if(substr($filename,strlen($filename)-4)==".eml") { 436 439 $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 :("; 446 451 447 452 if ( isset( $tmp_box ) && ! sizeof( $errors ) ) { … … 457 462 } 458 463 } 459 else 460 { 464 else{ 461 465 if ( isset( $tmp_box ) ) 462 466 imap_deletemailbox( $this->mbox,"{".$this -> imap_server."}$tmp_box" ); … … 3830 3834 } 3831 3835 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 } 3832 3873 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"); 3835 3876 $msgs_to_set = $params['msgs_to_set']; 3836 3877 $flag = $params['flag']; … … 3840 3881 $return["msgs_not_to_set"] = ""; 3841 3882 3842 if(!$this->mbox && !is_resource($this->mbox)) 3843 $this->mbox = $this->open_mbox($folder); 3883 $this->mbox = $this->open_mbox($folder); 3844 3884 3845 3885 if ($flag == "unseen"){
Note: See TracChangeset
for help on using the changeset viewer.