- Timestamp:
- 10/20/10 14:37:02 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php
r3369 r3380 721 721 722 722 $return = ""; 723 if( (!isset($this->pref s['preview_msg_subject']) || ($this->prefs['preview_msg_subject'] != "1")) &&724 (!isset($this->pref s['preview_msg_tip'] ) || ($this->prefs['preview_msg_tip'] != "1")) )723 if( (!isset($this->preferences['preview_msg_subject']) || ($this->preferences['preview_msg_subject'] != "1")) && 724 (!isset($this->preferences['preview_msg_tip'] ) || ($this->preferences['preview_msg_tip'] != "1")) ) 725 725 { 726 726 $return['body'] = ""; … … 3191 3191 3192 3192 function search_msg($params = ''){ 3193 $mbox_stream = ""; 3194 if(strpos($params['condition'],"#")===false) { //local messages? It shouldn't be necessary, should it? FIXME 3195 $search=false; 3196 } 3197 else { 3198 $search = explode(",",$params['condition']); 3199 } 3200 $params['page'] = $params['page']*1; 3201 3202 if(is_array($search)){ 3203 $search = array_unique($search); // Remove duplicated folders 3204 $search_criteria = ''; 3205 $search_result_number = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['search_result_number']; 3206 foreach($search as $tmp) 3193 $retorno = ""; 3194 $mbox_stream = ""; 3195 if(strpos($params['condition'],"#")===false) { //local messages 3196 $search=false; 3197 } 3198 else { 3199 $search = explode(",",$params['condition']); 3200 } 3201 3202 if($search){ 3203 $search_criteria = ''; 3204 $search_result_number = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['search_result_number']; 3205 foreach($search as $tmp) 3206 { 3207 $tmp1 = explode("##",$tmp); 3208 $sum = 0; 3209 $name_box = $tmp1[0]; 3210 unset($filter); 3211 foreach($tmp1 as $index => $criteria) 3212 { 3213 if ($index != 0 && strlen($criteria) != 0) 3214 { 3215 $filter_array = explode("<=>",html_entity_decode(rawurldecode($criteria))); 3216 $filter .= " ".$filter_array[0]; 3217 if (strlen($filter_array[1]) != 0){ 3218 if (trim($filter_array[0]) != 'BEFORE' && 3219 trim($filter_array[0]) != 'SINCE' && 3220 trim($filter_array[0]) != 'ON') 3221 { 3222 // Remove accents from criteria, because method remove accents is broken. 3223 $filter .= '"'.strtr($filter_array[1], 3224 "áàâãäéèêëíìîïóòôõöúùûüçÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ", 3225 "aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC").'"'; 3226 } 3227 else { 3228 $filter .= '"'.$this->make_search_date($filter_array[1]).'"'; 3229 } 3230 } 3231 } 3232 } 3233 $name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO_8859-1" ); 3234 3235 //Este bloco tem a finalidade de transformar o login (quando numerico) das pastas compartilhadas em common name 3236 if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'] && substr($name_box,0,4) == 'user') 3237 { 3238 $folder_name = explode($this->imap_delimiter,$name_box); 3239 $this->ldap = new ldap_functions(); 3240 if ($cn = $this->ldap->uid2cn($folder_name[1])) 3241 { 3242 $folder_name[1] = $cn; 3243 } 3244 $folder_name = implode($this->imap_delimiter,$folder_name); 3245 } 3246 else 3247 $folder_name = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO_8859-1" ); 3248 3249 if(!is_resource($mbox_stream)) 3250 $mbox_stream = $this->open_mbox($name_box); 3251 else 3252 imap_reopen($mbox_stream, "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$name_box); 3253 3254 if (preg_match("/^.?\bALL\b/", $filter)){ // Quick Search, note: this ALL isn't the same ALL from imap_search 3255 3256 $all_criterias = array ("TO","SUBJECT","FROM","CC"); 3257 3258 foreach($all_criterias as $criteria_fixed) 3259 { 3260 $_filter = $criteria_fixed . substr($filter,4); 3261 3262 $search_criteria = imap_search($mbox_stream, $_filter, SE_UID); 3263 // Testa aqui 3264 if($search_criteria) // && count($search_criteria) < $search_result_number) 3265 { 3266 foreach($search_criteria as $new_search){ 3267 if ($search_result_number != '65536' && $sum == $search_result_number) 3268 { 3269 return $retorno ? $sum . "=sumResults=" . $retorno : "none"; 3270 } 3271 3272 $m_token = trim("##". mb_convert_encoding( $folder_name, "ISO_8859-1", "UTF7-IMAP" ) . "--" . mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ) . "--" . $this->get_msg($new_search,$name_box,$mbox_stream) . "--".$new_search."##"."\n"); 3273 if(!@strstr($retorno,$m_token)) 3274 { 3275 $retorno .= $m_token; 3276 $sum++; 3277 } 3278 } 3279 } 3280 } 3281 } 3282 else { 3283 $search_criteria = imap_search($mbox_stream, $filter, SE_UID); 3284 if( is_array( $search_criteria) ) 3285 { 3286 foreach($search_criteria as $new_search) 3287 { 3288 if ($search_result_number != '65536' && $sum == $search_result_number) 3289 { 3290 return $retorno ? $sum . "=sumResults=" . $retorno : "none"; 3291 } 3292 $retorno .= trim("##". mb_convert_encoding( $folder_name, "ISO_8859-1", "UTF7-IMAP" ) . "--" . mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ) . "--" . $this->get_msg($new_search,$name_box,$mbox_stream) . "--" . $new_search."##"."\n"); 3293 $sum++; 3294 } 3295 } 3296 } 3297 3298 // $acumulated_results += $sum; 3299 // 3300 // if ($search_result_number != '65536' && $acumulated_results >= $search_result_number) 3301 // { 3302 // return "many results"; 3303 // } 3304 } 3305 } 3306 if($mbox_stream) 3307 imap_close($mbox_stream); 3308 3309 if ($retorno){ 3310 return $retorno; 3311 } 3312 else 3207 3313 { 3208 $tmp1 = explode("##",$tmp); 3209 $sum = 0; 3210 $name_box = $tmp1[0]; 3211 unset($filter); 3212 foreach($tmp1 as $index => $criteria) 3213 { 3214 if ($index != 0 && strlen($criteria) != 0) 3215 { 3216 $filter_array = explode("<=>",rawurldecode($criteria)); 3217 $filter .= " ".$filter_array[0]; 3218 if (strlen($filter_array[1]) != 0){ 3219 if (trim($filter_array[0]) != 'BEFORE' && 3220 trim($filter_array[0]) != 'SINCE' && 3221 trim($filter_array[0]) != 'ON') 3222 { 3223 $filter .= '"'.$filter_array[1].'"'; 3224 } 3225 else 3226 { 3227 $filter .= '"'.$this->make_search_date($filter_array[1]).'"'; 3228 } 3229 } 3230 } 3231 } 3232 $name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO_8859-1" ); 3233 $filter = $this->remove_accents($filter); 3234 //Este bloco tem a finalidade de transformar o login (quando numerico) das pastas compartilhadas em common name 3235 if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'] && substr($name_box,0,4) == 'user') 3236 { 3237 $folder_name = explode($this->imap_delimiter,$name_box); 3238 $this->ldap = new ldap_functions(); 3239 if ($cn = $this->ldap->uid2cn($folder_name[1])) 3240 { 3241 $folder_name[1] = $cn; 3242 } 3243 $folder_name = implode($this->imap_delimiter,$folder_name); 3244 } 3245 else 3246 { 3247 $folder_name = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO_8859-1" ); 3248 } 3249 3250 if(!is_resource($mbox_stream)) 3251 { 3252 $mbox_stream = $this->open_mbox($name_box); 3253 } 3254 else 3255 { 3256 imap_reopen($mbox_stream, "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$name_box); 3257 } 3258 3259 if (preg_match("/^.?\bALL\b/", $filter)) 3260 { // Quick Search, note: this ALL isn't the same ALL from imap_search 3261 3262 $all_criterias = array ("TO","SUBJECT","FROM","CC"); 3263 foreach($all_criterias as $criteria_fixed) 3264 { 3265 $_filter = $criteria_fixed . substr($filter,4); 3266 3267 $search_criteria = imap_search($mbox_stream, $_filter, SE_UID); 3268 3269 if(is_array($search_criteria)) 3270 { 3271 foreach($search_criteria as $new_search) 3272 { 3273 $elem = $this->get_msg_detail($new_search,$name_box,$mbox_stream); 3274 $elem['boxname'] = mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ); 3275 $elem['uid'] = $new_search; 3276 $retorno[] = $elem; 3277 } 3278 } 3279 } 3280 } 3281 else { 3282 $search_criteria = imap_search($mbox_stream, $filter, SE_UID); 3283 if( is_array( $search_criteria) ) 3284 { 3285 foreach($search_criteria as $new_search) 3286 { 3287 $elem = $this->get_msg_detail($new_search,$name_box,$mbox_stream); 3288 $elem['boxname'] = mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ); 3289 $elem['uid'] = $new_search; 3290 $retorno[] = $elem; 3291 } 3292 } 3293 } 3314 return 'none'; 3294 3315 } 3295 } 3296 if($mbox_stream) 3297 { 3298 imap_close($mbox_stream); 3299 } 3300 $num_msgs = count($retorno); 3301 3302 /* Comparison functions, descendent is ascendent with parms inverted */ 3303 function SORTDATE($a, $b) { return ($a['udate'] < $b['udate']); } 3304 function SORTDATE_REVERSE($b, $a) { return SORTDATE($a,$b); } 3305 3306 function SORTWHO($a, $b) { return (strtoupper($a['from']) > strtoupper($b['from'])); } 3307 function SORTWHO_REVERSE($b, $a) { return SORTWHO($a,$b); } 3308 3309 function SORTSUBJECT($a, $b) { return (strtoupper($a['subject']) > strtoupper($b['subject'])); } 3310 function SORTSUBJECT_REVERSE($b, $a) { return SORTSUBJECT($a,$b); } 3311 3312 function SORTBOX($a, $b) { return ($a['boxname'] > $b['boxname']); } 3313 function SORTBOX_REVERSE($b, $a) { return SORTBOX($a,$b); } 3314 3315 function SORTSIZE($a, $b) { return ($a['size'] > $b['size']); } 3316 function SORTSIZE_REVERSE($b, $a) { return SORTSIZE($a,$b); } 3317 3318 usort($retorno, $params['sort_type']); 3319 $pageret = array_slice($retorno, $params['page'] * $this->prefs['max_email_per_page'], $this->prefs['max_email_per_page']); 3320 $arrayRetorno['num_msgs'] = $num_msgs; 3321 $arrayRetorno['data'] = $pageret; 3322 3323 if ($pageret) 3324 { 3325 return $arrayRetorno; 3326 } 3327 else 3328 { 3329 return 'none'; 3330 } 3331 } 3332 3333 function get_msg_detail($uid_msg,$name_box, $mbox_stream ) 3316 //return $retorno ? $retorno : "none"; 3317 } 3318 3319 function get_msg($uid_msg,$name_box, $mbox_stream ) 3334 3320 { 3335 3321 $header = $this->get_header($uid_msg); 3336 require_once("class.imap_attachment.inc.php");3322 include_once("class.imap_attachment.inc.php"); 3337 3323 $imap_attachment = new imap_attachment(); 3338 3324 $attachments = $imap_attachment->get_attachment_headerinfo($mbox_stream, $uid_msg); … … 3351 3337 if($header->from[0]->personal != "") 3352 3338 $from = $header->from[0]->personal; 3353 $ret_msg['from'] = $this->decode_string($from); 3354 $ret_msg['subject'] = $subject; 3355 $ret_msg['udate'] = $header ->udate; 3356 $ret_msg['size'] = $header->Size; 3357 $ret_msg['flag'] = $flag; 3339 $ret_msg = $this->decode_string($from) . "--" . $subject . "--". gmdate("d/m/Y",$header ->udate)."--". $this->size_msg($header->Size) ."--". $flag; 3358 3340 return $ret_msg; 3359 3341 } 3342 3343 3344 function size_msg($size){ 3345 $var = floor($size/1024); 3346 if($var >= 1){ 3347 return $var." kb"; 3348 }else{ 3349 return $size ." b"; 3350 } 3351 } 3352 3360 3353 function ob_array($the_object) 3361 3354 {
Note: See TracChangeset
for help on using the changeset viewer.