Changeset 673 for trunk/expressoMail1_2/inc/class.imap_functions.inc.php
- Timestamp:
- 02/06/09 16:53:27 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r670 r673 10 10 'get_range_msgs' => True, 11 11 'get_info_msg' => True, 12 'get_info_msgs' => True,13 12 'get_folders_list' => True, 14 13 'import_msgs' => True … … 71 70 function get_range_msgs2($params) 72 71 { 72 include("class.imap_attachment.inc.php"); 73 $imap_attachment = new imap_attachment(); 73 74 $folder = $params['folder']; 74 75 $msg_range_begin = $params['msg_range_begin']; … … 84 85 if($num_msgs) { 85 86 for ($msg_range_begin; (($msg_range_begin <= $msg_range_end) && ($msg_range_begin <= $num_msgs)); $msg_range_begin++) 86 { 87 $msg_number = $sort_array_msg[$msg_range_begin-1]; 88 $temp = $this->get_info_head_msg($msg_number); 89 if(!$temp) 90 return false; 91 92 $return[$i] = $temp; 93 $i++; 94 } 95 } 96 $return['num_msgs'] = $num_msgs; 97 98 return $return; 99 } 100 101 function get_info_head_msg($msg_number) { 102 $head_array = array(); 103 include_once("class.imap_attachment.inc.php"); 104 $imap_attachment = new imap_attachment(); 105 106 /*A função imap_headerinfo não traz o cabeçalho completo, e sim alguns 107 * atributos do cabeçalho. Como eu preciso do atributo Importance 108 * para saber se o email é importante ou não, uso abaixo a função 109 * imap_fetchheader e busco o atributo importance nela para passar 110 * para as funções ajax. Isso faz com que eu acesse o cabeçalho 111 * duas vezes e de duas formas diferentes, mas em contrapartida, eu 112 * não preciso reimplementar o método utilizando o fetchheader. 113 * Como as mensagens são renderizadas de X em X, não parece ter 114 * perda considerável de performance. 115 */ 116 $flag = preg_match('/importance *: *(.*)\r/i', 87 { 88 $msg_number = $sort_array_msg[$msg_range_begin-1]; 89 90 /*A função imap_headerinfo não traz o cabeçalho completo, e sim alguns 91 * atributos do cabeçalho. Como eu preciso do atributo Importance 92 * para saber se o email é importante ou não, uso abaixo a função 93 * imap_fetchheader e busco o atributo importance nela para passar 94 * para as funções ajax. Isso faz com que eu acesse o cabeçalho 95 * duas vezes e de duas formas diferentes, mas em contrapartida, eu 96 * não preciso reimplementar o método utilizando o fetchheader. 97 * Como as mensagens são renderizadas em um número pequeno por vez, 98 * não parece ter perda considerável de performance. 99 */ 100 $flag = preg_match('/importance *: *(.*)\r/i', 117 101 imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)) 118 102 ,$importance); 119 $head_array['Importance'] = $flag==0?"Normal":$importance[1];120 121 122 $header = $this->get_header($msg_number);103 $return[$i]['Importance'] = $flag==0?"":$importance[1]; 104 105 106 $header = $this->get_header($msg_number); 123 107 if (!is_object($header)) 124 return false; 125 $head_array['Recent'] = $header->Recent; 126 $head_array['Unseen'] = $header->Unseen; 127 if($header->Answered =='A' && $header->Draft == 'X'){ 128 $head_array['Forwarded'] = 'F'; 129 } 130 else { 131 $head_array['Answered'] = $header->Answered; 132 $head_array['Draft'] = $header->Draft; 133 } 134 $head_array['Deleted'] = $header->Deleted; 135 $head_array['Flagged'] = $header->Flagged; 136 137 $head_array['msg_number'] = $msg_number; 138 //$return[$i]['msg_folder'] = $folder; 139 140 $date_msg = date("d/m/Y",$header->udate); 141 if (date("d/m/Y") == $date_msg) 142 $head_array['udate'] = date("H:i",$header->udate); 143 else 144 $head_array['udate'] = $date_msg; 145 146 $head_array['aux_date'] = $date_msg; //Auxiliar apenas para mensagens locais. 147 148 $from = $header->from; 149 $head_array['from'] = array(); 150 $tmp = imap_mime_header_decode($from[0]->personal); 151 $head_array['from']['name'] = $this->decode_string($tmp[0]->text); 152 $head_array['from']['email'] = $this->decode_string($from[0]->mailbox) . "@" . $from[0]->host; 153 if(!$head_array['from']['name']) 154 $head_array['from']['name'] = $head_array['from']['email']; 155 $to = $header->to; 156 $head_array['to'] = array(); 157 $tmp = imap_mime_header_decode($to[0]->personal); 158 $head_array['to']['name'] = $this->decode_string($this->decode_string($tmp[0]->text)); 159 $head_array['to']['email'] = $this->decode_string($to[0]->mailbox) . "@" . $to[0]->host; 160 if(!$head_array['to']['name']) 161 $head_array['to']['name'] = $head_array['to']['email']; 162 $head_array['subject'] = $this->decode_string($header->fetchsubject); 163 164 $head_array['Size'] = $header->Size; 165 166 $head_array['attachment'] = array(); 167 $head_array['attachment'] = $imap_attachment->get_attachment_headerinfo($this->mbox, $msg_number); 168 169 return $head_array; 108 return false; 109 110 $return[$i]['Recent'] = $header->Recent; 111 $return[$i]['Unseen'] = $header->Unseen; 112 if($header->Answered =='A' && $header->Draft == 'X'){ 113 $return[$i]['Forwarded'] = 'F'; 114 } 115 else { 116 $return[$i]['Answered'] = $header->Answered; 117 $return[$i]['Draft'] = $header->Draft; 118 } 119 $return[$i]['Deleted'] = $header->Deleted; 120 $return[$i]['Flagged'] = $header->Flagged; 121 122 $return[$i]['msg_number'] = $msg_number; 123 //$return[$i]['msg_folder'] = $folder; 124 125 $date_msg = gmdate("d/m/Y",$header->udate); 126 if (gmdate("d/m/Y") == $date_msg) 127 $return[$i]['udate'] = gmdate("H:i",$header->udate); 128 else 129 $return[$i]['udate'] = $date_msg; 130 131 $from = $header->from; 132 $return[$i]['from'] = array(); 133 $tmp = imap_mime_header_decode($from[0]->personal); 134 $return[$i]['from']['name'] = $this->decode_string($tmp[0]->text); 135 $return[$i]['from']['email'] = $this->decode_string($from[0]->mailbox) . "@" . $from[0]->host; 136 if(!$return[$i]['from']['name']) 137 $return[$i]['from']['name'] = $return[$i]['from']['email']; 138 $to = $header->to; 139 $return[$i]['to'] = array(); 140 $tmp = imap_mime_header_decode($to[0]->personal); 141 $return[$i]['to']['name'] = $this->decode_string($this->decode_string($tmp[0]->text)); 142 $return[$i]['to']['email'] = $this->decode_string($to[0]->mailbox) . "@" . $to[0]->host; 143 if(!$return[$i]['to']['name']) 144 $return[$i]['to']['name'] = $return[$i]['to']['email']; 145 $return[$i]['subject'] = $this->decode_string($header->fetchsubject); 146 147 $return[$i]['Size'] = $header->Size; 148 149 $return[$i]['attachment'] = array(); 150 $return[$i]['attachment'] = $imap_attachment->get_attachment_headerinfo($this->mbox, $msg_number); 151 $i++; 152 } 153 } 154 $return['num_msgs'] = $num_msgs; 155 156 return $return; 170 157 } 171 158 … … 310 297 } 311 298 312 /**313 *314 * @return315 * @param $params Object316 */317 function get_info_msgs($params) {318 include_once("class.exporteml.inc.php");319 $return = array();320 $new_params = array();321 $attach_params = array();322 $new_params["msg_folder"]=$params["folder"];323 $attach_params["folder"] = $params["folder"];324 $msgs = explode(",",$params["msgs_number"]);325 $exporteml = new ExportEml();326 foreach($msgs as $msg_number) {327 $new_params["msg_number"] = $msg_number;328 //ini_set("display_errors","1");329 $msg_info = $this->get_info_msg($new_params);330 331 $this->mbox = $this->open_mbox($params['folder']); //Não sei porque, mas se não abrir de novo a caixa dá erro.332 $msg_info['header'] = $this->get_info_head_msg($msg_number);333 334 $attach_params["num_msg"] = $msg_number;335 $msg_info['array_attach'] = $exporteml->get_attachments_in_array($attach_params);336 $msg_info['url_export_file'] = $exporteml->export_to_archive($msg_number,$params["folder"]);337 imap_close($this->mbox);338 $this->mbox=false;339 340 341 array_push($return,serialize($msg_info));342 343 }344 345 return $return;346 }347 348 299 function get_info_msg($params) 349 300 { … … 366 317 //Substituição de links em email para abrir no próprio expresso 367 318 $body = ereg_replace("<a[^>]*href=[\'\"]mailto:([^\"\']+)[\'\"]>([^<]+)</a>","<a href=\"javascript:new_message_to('\\1')\">\\2</a>",$return_get_body['body']); 368 319 369 320 $return['body'] = $body; 370 321 $return['attachments'] = $return_get_body['attachments']; … … 599 550 $return['Size'] = $header->Size; 600 551 $return['reply_toaddress'] = $header->reply_toaddress; 601 602 //All this is to help in local messages603 $return['timestamp'] = $header->udate;604 $return['login'] = $_SESSION['phpgw_info']['expressomail']['user']['account_id'];//$GLOBALS['phpgw_info']['user']['account_id'];605 $return['reply_toaddress'] = $header->reply_toaddress;606 607 552 return $return; 608 553 } … … 1072 1017 function refresh($params) 1073 1018 { 1074 include _once("class.imap_attachment.inc.php");1019 include("class.imap_attachment.inc.php"); 1075 1020 $imap_attachment = new imap_attachment(); 1076 1021 $folder = $params['folder']; … … 1152 1097 imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)) 1153 1098 ,$importance); 1154 $return[$i]['Importance'] = $flag==0?" Normal":$importance[1];1099 $return[$i]['Importance'] = $flag==0?"":$importance[1]; 1155 1100 1156 1101 $header = $this->get_header($msg_number); … … 1403 1348 $attachments = $params['FILES']; 1404 1349 $forwarding_attachments = $params['forwarding_attachments']; 1405 $local_attachments = $params['local_attachments'];1406 1350 1407 1351 $folder =$params['folder']; … … 1487 1431 //////////////////////////////////////////////////////////////////////////////////////////////////// 1488 1432 // Build Uploading Attachments!!! 1489 if ( (count($attachments)) && ($params['is_local_forward']!="1")) //Caso seja forward normal...1433 if (count($attachments)) 1490 1434 { 1491 1435 $total_uploaded_size = 0; … … 1499 1443 return $this->parse_error("message file too big"); 1500 1444 } 1501 else if(($params['is_local_forward']=="1") && (count($local_attachments))) { //Caso seja forward de mensagens locais1502 1503 $total_uploaded_size = 0;1504 $upload_max_filesize = str_replace("M","",ini_get('upload_max_filesize')) * 1024 * 1024;1505 foreach($local_attachments as $local_attachment) {1506 $file_description = unserialize(rawurldecode($local_attachment));1507 $tmp = array_values($file_description);1508 foreach($file_description as $i => $descriptor){1509 $tmp[$i] = eregi_replace('\'*\'','',$descriptor);1510 }1511 $mail->AddAttachment($_FILES[$tmp[1]]['tmp_name'], $tmp[2], "base64", $this->get_file_type($tmp[2])); // optional name1512 $total_uploaded_size = $total_uploaded_size + $_FILES[$tmp[1]]['size'];1513 }1514 if( $total_uploaded_size > $upload_max_filesize)1515 return 'false';1516 }1517 1445 //////////////////////////////////////////////////////////////////////////////////////////////////// 1518 1446 // Build Forwarding Attachments!!! … … 1675 1603 continue; 1676 1604 } 1677 1678 1605 1679 1606 if($sort_box_type=='SORTFROM') { 1680 1607 if (($header->from[0]->mailbox . "@" . $header->from[0]->host) == $_SESSION['phpgw_info']['expressomail']['user']['email']) … … 1716 1643 } 1717 1644 1718 /**1719 * Deprecated1720 *1721 * Replaced for the method messages_sort1722 */1723 function imap_sortfrom($sort_box_reverse, $search_box_type)1724 {1725 $sortfrom = array();1726 $sortfrom_uid = array();1727 1728 $num_msgs = imap_num_msg($this->mbox);1729 for ($i=1; $i<=$num_msgs; $i++)1730 {1731 $header = $this->get_header(imap_uid($this->mbox,$i));1732 // List UNSEEN messages.1733 if($search_box_type == "UNSEEN" && (!trim($header->Recent) && !trim($header->Unseen))){1734 continue;1735 }1736 // List SEEN messages.1737 elseif($search_box_type == "SEEN" && (trim($header->Recent) || trim($header->Unseen))){1738 continue;1739 }1740 // List ANSWERED messages.1741 elseif($search_box_type == "ANSWERED" && !trim($header->Answered)){1742 continue;1743 }1744 // List FLAGGED messages.1745 elseif($search_box_type == "FLAGGED" && !trim($header->Flagged)){1746 continue;1747 }1748 1749 if (($header->from[0]->mailbox . "@" . $header->from[0]->host) == $_SESSION['phpgw_info']['expressomail']['user']['email'])1750 $from = $header->to;1751 else1752 $from = $header->from;1753 1754 $tmp = imap_mime_header_decode($from[0]->personal);1755 1756 if ($tmp[0]->text != "")1757 $sortfrom[$i] = $tmp[0]->text;1758 else1759 $sortfrom[$i] = $from[0]->mailbox . "@" . $from[0]->host;1760 }1761 1762 natcasesort($sortfrom);1763 1764 foreach($sortfrom as $index => $header_msg)1765 {1766 $sortfrom_uid[] = imap_uid($this->mbox, $index);1767 }1768 1769 if ($sort_box_reverse)1770 $sortfrom_uid = array_reverse($sortfrom_uid);1771 1772 return $sortfrom_uid;1773 }1774 1775 1645 function move_search_messages($params){ 1776 1646 $params['selected_messages'] = urldecode($params['selected_messages']); … … 2083 1953 if($mbox_stream) 2084 1954 imap_close($mbox_stream); 2085 1955 if (is_array($return_files)) 2086 1956 foreach ($return_files as $index => $_attachment) { 2087 1957 if (array_key_exists("name",$_attachment)){ … … 2097 1967 2098 1968 $return['files'] = serialize($return_files); 1969 $return["subject"] = $subject; 2099 1970 2100 1971 if (!$return['append']) … … 2136 2007 imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)) 2137 2008 ,$importance); 2138 if(strtolower($importance[1])=="high" ) {2009 if(strtolower($importance[1])=="high" && $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) { 2139 2010 $flag_importance=true; 2140 2011 } … … 2152 2023 } 2153 2024 2154 if($flag_importance ) {2025 if($flag_importance && $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) { 2155 2026 $return["status"] = false; 2156 2027 $return["msg"] = $this->functions->getLang("At least one of selected message cant be marked as normal"); … … 2441 2312 function search($params) 2442 2313 { 2443 include _once("class.imap_attachment.inc.php");2314 include("class.imap_attachment.inc.php"); 2444 2315 $imap_attachment = new imap_attachment(); 2445 2316 $criteria = $params['criteria']; … … 2561 2432 $retorno = ""; 2562 2433 $mbox_stream = ""; 2563 if(strpos($params['condition'],"#")===false) { //local messages 2564 $search=false; 2565 } 2566 else { 2567 $search = explode(",",$params['condition']); 2568 } 2569 2434 $search = explode(",",$params['condition']); 2570 2435 if($search){ 2571 2436 $search_criteria = ''; 2572 foreach($search as $tmp){ 2437 foreach($search as $tmp) 2438 { 2573 2439 $tmp1 = explode("##",$tmp); 2574 2440 $name_box = $tmp1[0]; … … 2827 2693 $array_parts_attachments = array(); 2828 2694 $array_parts_attachments['names'] = ''; 2829 include _once("class.imap_attachment.inc.php");2695 include("class.imap_attachment.inc.php"); 2830 2696 $imap_attachment = new imap_attachment(); 2831 2697 … … 2894 2760 $header->udate += $pdate['zone']*(-60); 2895 2761 2896 if($header->Flagged !="F") {2762 if($header->Flagged != "F" && $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) { 2897 2763 $flag = preg_match('/importance *: *(.*)\r/i', 2898 2764 imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number))
Note: See TracChangeset
for help on using the changeset viewer.