- Timestamp:
- 09/17/12 14:30:47 (12 years ago)
- Location:
- branches/2.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.4
- Property svn:mergeinfo changed
-
branches/2.4/expressoMail1_2/inc/class.imap_functions.inc.php
r7180 r7228 128 128 $result = true; 129 129 if(!imap_renamemailbox($mbox, '{'.$this->imap_server.":".$this->imap_port.$this->imap_options.'}'.$old_folder, '{'.$this->imap_server.":".$this->imap_port.$this->imap_options.'}'.$to_folder.$this->imap_delimiter.$new_folder[count($new_folder)-1])){ 130 $result = false; 131 } 130 $result = imap_last_error(); 131 } 132 132 133 imap_close($mbox); 133 134 return $result; … … 1061 1062 $content = $this->html2txt($content); 1062 1063 $content != "" ? $return['body'] = " - " . $content: $return['body'] = ""; 1063 $return['body'] = base64_encode(mb_convert_encoding(substr($return['body'], 0, 305),'UTF-8' , 'UTF-8,ISO-8859-1'));1064 $return['body'] = base64_encode(mb_convert_encoding(substr($return['body'], 0, 305),'UTF-8' , 'UTF-8,ISO-8859-1')); 1064 1065 return $return; 1065 1066 } … … 1235 1236 $return['sender']['name'] = isset($sender[0]->personal) ? $this->decode_string($sender[0]->personal): ''; 1236 1237 $return['sender']['email'] = $this->decode_string($sender[0]->mailbox . "@" . $sender[0]->host); 1237 1238 1238 1239 if ($return['sender']['name']) 1239 1240 { … … 1256 1257 if (!empty($tmp->personal)) 1257 1258 { 1258 $personal_tmp = $this->formatMailObject($tmp); 1259 1259 $personal_tmp = $this->formatMailObject($tmp); 1260 $return['toaddress2'] .= '"' . $personal_tmp['name'] . '"'; 1260 1261 $return['toaddress2'] .= " "; 1261 1262 $return['toaddress2'] .= "<"; … … 1288 1289 if (!empty($tmp_cc->personal)) 1289 1290 { 1290 $personal_tmp_cc = $this->formatMailObject($tmp_cc); 1291 $return['cc'] .= '"' . $personal_tmp_cc['name']. '"'; 1291 $personal_tmp_cc = $this->formatMailObject($tmp_cc); 1292 $return['cc'] .= '"' . $personal_tmp_cc['name']. '"'; 1292 1293 $return['cc'] .= " "; 1293 1294 $return['cc'] .= "<"; … … 1328 1329 if (!empty($tmp_bcc->personal)) 1329 1330 { 1330 $personal_tmp_bcc = $this->formatMailObject($tmp_bcc); 1331 1331 $personal_tmp_bcc = $this->formatMailObject($tmp_bcc); 1332 $return['bcc'] .= '"' . $personal_tmp_bcc['name'] . '"'; 1332 1333 $return['bcc'] .= " "; 1333 1334 $return['bcc'] .= "<"; … … 1355 1356 $reply_to = $header->reply_to; 1356 1357 $return['reply_to'] = ""; 1358 1357 1359 if (is_object($reply_to[0])) 1358 1360 { 1359 1361 if ($return['from']['email'] != ($reply_to[0]->mailbox."@".$reply_to[0]->host)) 1360 1362 { 1361 if (!empty($reply_to[0]->personal))1363 foreach ($reply_to as $tmp_reply_to) 1362 1364 { 1363 $personal_reply_to = $this->formatMailObject($tmp_reply_to); 1364 if(!empty($personal_reply_to[0]->text)) { 1365 $return['reply_to'] .= '"' . $personal_reply_to['name']. '"'; 1365 if (!empty($tmp_reply_to->personal)) 1366 { 1367 $personal_tmp_reply_to = $this->formatMailObject($tmp_reply_to); 1368 $return['reply_to'] .= '"' . $personal_tmp_reply_to['name'] . '"'; 1366 1369 $return['reply_to'] .= " "; 1367 1370 $return['reply_to'] .= "<"; 1368 $return['reply_to'] .= $personal_ reply_to['email'];1371 $return['reply_to'] .= $personal_tmp_reply_to['email']; 1369 1372 $return['reply_to'] .= ">"; 1373 $return['reply_to'] .= ", "; 1370 1374 } 1371 else { 1372 $return['reply_to'] .= $reply_to[0]->mailbox . "@" . $reply_to[0]->host; 1375 else 1376 { 1377 if (isset($tmp_reply_to->host) && $tmp_reply_to->host != 'unspecified-domain') 1378 $return['reply_to'] .= $tmp_reply_to->mailbox . "@" . $tmp_reply_to->host; 1379 else 1380 $return['reply_to'] .= $tmp_reply_to->mailbox; 1381 $return['reply_to'] .= ", "; 1373 1382 } 1374 1383 } 1375 else 1376 { 1377 $return['reply_to'] .= $reply_to[0]->mailbox . "@" . $reply_to[0]->host; 1378 } 1379 } 1380 } 1381 $return['reply_to'] = $this->decode_string($return['reply_to']); 1384 $return['reply_to'] = $this->del_last_two_caracters($return['reply_to']); 1385 } 1386 } 1387 else 1388 { 1389 $return['reply_to'] = ""; 1390 } 1391 1382 1392 $return['subject'] = ( isset($header->subject) && trim($header->subject) !== '' ) ? self::decodeMimeString($header->subject) : $this->functions->getLang('(no subject) '); 1383 1393 … … 1398 1408 } 1399 1409 $return['alarm'] = $alarm; 1400 1410 1401 1411 return $return; 1402 1412 } … … 1896 1906 $body = str_ireplace('<o:p> </o:p>','<br />', $body);//Qubra de linha do MSO 1897 1907 $body = preg_replace('/<(meta|base|link|html|\/html)[^>]*>/i', '', $body); 1908 1909 1910 // Malicious Code Remove 1911 $dirtyCodePattern = "/(<([\w]+[\w0-9]*)(.*)on(mouse(move|over|down|up)|load|blur|change|error|click|dblclick|focus|key(down|up|press)|select)([\n\ ]*)=([\n\ ]*)[\"'][^>\"']*[\"']([^>]*)>)(.*)(<\/\\2>)?/misU"; 1912 preg_match_all($dirtyCodePattern, $body, $rest, PREG_PATTERN_ORDER); 1913 foreach ($rest[0] as $i => $val) { 1914 if (!(preg_match("/javascript:window\.open\(\"([^'\"]*)\/index\.php\?menuaction=calendar\.uicalendar\.set_action\&cal_id=([^;'\"]+);?['\"]/i", $rest[1][$i]) && strtoupper($rest[4][$i]) == "CLICK" )) //Calendar events 1915 $body = str_replace($rest[1][$i], "<" . $rest[2][$i] . $rest[3][$i] . $rest[7][$i] . ">", $body); 1916 } 1898 1917 1899 1918 … … 1932 1951 $body = str_ireplace('position:absolute;', '', $body); 1933 1952 1953 $body = str_ireplace('position:absolute;', '', $body); 1954 1934 1955 //Remoção de tags <span></span> para correção de erro no firefox 1935 1956 //Comentado pois estes replaces geram erros no html da msg, não se pode garantir que o os </span></span> sejam realmente os fechamentos dos <span><span>. … … 2145 2166 $return['status'] = true; 2146 2167 2147 //Este bloco tem a finalidade de averiguar as permissoes para pastas compartilhadas2148 if (substr($folder,0,4) == 'user'){ 2149 $acl = $this->getacltouser($folder, isset($params['decoded'])); 2150 /* 2151 * l - lookup (mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox)2152 * r - read (SELECT the mailbox, perform STATUS) 2153 * s - keep seen/unseen information across sessions (set or clear \SEEN flag via STORE, also set \SEEN during APPEND/COPY/ FETCH BODY[...]) 2154 * w - write (set or clear flags other than \SEEN and \DELETED via STORE, also set them during APPEND/COPY) 2155 * i - insert (perform APPEND, COPY into mailbox) 2156 * p - post (send mail to submission address for mailbox, not enforced by IMAP4 itself) 2157 * k - create mailboxes (CREATE new sub-mailboxes in any implementation-defined hierarchy, parent mailbox for the new mailbox name in RENAME) 2158 * x - delete mailbox (DELETE mailbox, old mailbox name in RENAME) 2159 * t - delete messages (set or clear \DELETED flag via STORE, set \DELETED flag during APPEND/COPY) 2160 * e - perform EXPUNGE and expunge as a part of CLOSE 2161 * a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) 2162 * Os Atributos da ACL para pastas compartilhadas são definidos no arquivo sharemailbox.js, na função setaclfromuser 2163 * Os Atributos da ACL para contas compartilhadas são definidos no arquivo shared_accounts.js, na função setaclfromuser 2164 */ 2165 $acl_share_delete = (stripos($acl,'t') !== false && stripos($acl,'e') !== false);2166 2167 if (!$acl_share_delete) { 2168 $return['status'] = false;2169 }2170 } 2171 2168 //Este bloco tem a finalidade de averiguar as permissoes para pastas compartilhadas 2169 if (substr($folder,0,4) == 'user'){ 2170 $acl = $this->getacltouser($folder, isset($params['decoded'])); 2171 /* 2172 * l - lookup (mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox) 2173 * r - read (SELECT the mailbox, perform STATUS) 2174 * s - keep seen/unseen information across sessions (set or clear \SEEN flag via STORE, also set \SEEN during APPEND/COPY/ FETCH BODY[...]) 2175 * w - write (set or clear flags other than \SEEN and \DELETED via STORE, also set them during APPEND/COPY) 2176 * i - insert (perform APPEND, COPY into mailbox) 2177 * p - post (send mail to submission address for mailbox, not enforced by IMAP4 itself) 2178 * k - create mailboxes (CREATE new sub-mailboxes in any implementation-defined hierarchy, parent mailbox for the new mailbox name in RENAME) 2179 * x - delete mailbox (DELETE mailbox, old mailbox name in RENAME) 2180 * t - delete messages (set or clear \DELETED flag via STORE, set \DELETED flag during APPEND/COPY) 2181 * e - perform EXPUNGE and expunge as a part of CLOSE 2182 * a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) 2183 * Atributos da ACL para pastas compartilhadas são definidos no arquivo sharemailbox.js, na função setaclfromuser 2184 * Atributos da ACL para contas compartilhadas são definidos no arquivo shared_accounts.js, na função setaclfromuser 2185 */ 2186 $acl_share_delete = (stripos($acl,'t') !== false && stripos($acl,'e') !== false); 2187 2188 if (!$acl_share_delete) { 2189 $return['status'] = false; 2190 } 2191 } 2192 2172 2193 return $return; 2173 2194 } 2174 2175 2195 2176 2196 function refresh($params) … … 2367 2387 foreach ($return as $i => &$vv) 2368 2388 { 2369 if(!is_array($vv)) continue; 2370 2371 $vv['folder_id'] = mb_convert_encoding($vv['folder_id'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA ID DAS PASTAS COM ACENTOS2372 $vv['folder_name'] = mb_convert_encoding($vv['folder_name'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA NOME DAS PASTAS COM ACENTOS2373 2389 if(!is_array($vv)) continue; 2390 2391 $vv['folder_id'] = mb_convert_encoding($vv['folder_id'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA ID DAS PASTAS COM ACENTOS 2392 $vv['folder_name'] = mb_convert_encoding($vv['folder_name'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA NOME DAS PASTAS COM ACENTOS 2393 $vv['folder_parent'] = mb_convert_encoding($vv['folder_parent'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA NOME DAS PASTAS COM ACENTOS 2374 2394 } 2375 2395 … … 2412 2432 $decifrada = mb_convert_encoding('INBOX'.$this->imap_delimiter.'decifradas','UTF7-IMAP','ISO-8859-1'); //Ignorar esta pasta decifrada 2413 2433 $parent = ($nameCount > 1 && $nameArray[($nameCount - 2)] !== 'INBOX') ? implode($this->imap_delimiter, array_slice($nameArray, 0, ($nameCount - 1))): ''; //Pega folder pai 2414 if($nameArray[0] === 'user') 2415 $folders[$prefixShared.$this->imap_delimiter.$nameArray[1]][] = array('id' => $folderId , 'stream' => $v->name , 'attributes' => $v->attributes , 'name' => $nameArray[($nameCount-1)] , 'user' => $nameArray[1] ,'parent' => $parent); 2416 else if( $folderId !== $decifrada) //Escapa pasta decifrada 2417 $folders['INBOX'][strtolower($folderId)] = array('id' => $folderId , 'stream' => $v->name , 'attributes' => $v->attributes ,'name' => $nameArray[($nameCount-1)] , 'parent' => $parent); 2418 } 2434 2435 if($nameArray[0] === 'user'){ 2436 2437 //variaveis utilizadas para definição das permissões das pastas compartilhadas 2438 $acl_share_create = 0; 2439 $acl_share_rename = 0; 2440 $acl_share_delete = 0; 2441 2442 //recuperando as permissões (ACLs) aplicadas na pasta 2443 $imap_getacl = imap_getacl($mboxStream, $folderId); 2444 2445 //Se existe ACLs aplicadas a respectiva pasta (para o usuario corrente) 2446 if(isset($imap_getacl[ $this->username ])){ 2447 $aclImap = $imap_getacl[ $this->username ]; 2448 2449 //A partir dos atributos da ACL definir permissões para cada ação (create, delete e rename): 2450 //http://www.ietf.org/rfc/rfc4314.txt 2451 $acl_share_create = (stripos($aclImap,'w') !== false && stripos($aclImap,'i') !== false && stripos($aclImap,'k') !== false) ? 1 : 0; 2452 $acl_share_delete = (stripos($aclImap,'x') !== false && stripos($aclImap,'t') !== false && stripos($aclImap,'e') !== false) ? 1 : 0; 2453 2454 $acl_share_rename = ($acl_share_create && $acl_share_delete) ? 1 : 0; 2455 } 2456 2457 $folders[$prefixShared.$this->imap_delimiter.$nameArray[1]][] = array( 2458 'id' => $folderId , 2459 'stream' => $v->name , 2460 'attributes' => $v->attributes , 2461 'name' => $nameArray[($nameCount-1)] , 2462 'user' => $nameArray[1] , 2463 'parent' => $parent , 2464 2465 //Acrescentando ACLs configuradas a cada pasta compartilhada 2466 'acl_share' => array( 2467 'create' => $acl_share_create, 2468 'rename' => $acl_share_rename, 2469 'delete' => $acl_share_delete 2470 ) 2471 ); 2472 2473 } 2474 else if( $folderId !== $decifrada){ //Escapa pasta decifrada 2475 $folders['INBOX'][strtolower($folderId)] = array( 2476 'id' => $folderId , 2477 'stream' => $v->name , 2478 'attributes' => $v->attributes , 2479 'name' => $nameArray[($nameCount-1)] , 2480 'parent' => $parent 2481 ); 2482 } 2483 } 2484 2419 2485 unset($folders_list); //destroy array de objetos desnecessarios 2420 2486 … … 2434 2500 $append['folder_hasChildren'] = (($vv['attributes'] == 32) && ($vv['name'] != 'INBOX')) ? 1 : 0; 2435 2501 $append['folder_parent'] = $vv['parent']; 2502 2503 //Preparando o array de retorno para conter as ACLs configuradas para cada pasta 2504 if(isset($vv['acl_share'])){ 2505 $append['acl_share'] = $vv['acl_share']; 2506 } 2436 2507 $return[] = $append; 2437 2508 } … … 2440 2511 $quotaInfo = (!isset($params['noQuotaInfo'])) ? $this->get_quota( array('folder_id' => $currentFolder)) : false; //VERIFICA SE O USUARIO TEM COTA 2441 2512 2442 return ( ( is_array($quotaInfo) ) ? array_merge($return, $quotaInfo) : $return ); 2513 return ( ( is_array($quotaInfo) ) ? array_merge($return, $quotaInfo) : $return ); 2443 2514 } 2444 2515 … … 2460 2531 if(!imap_createmailbox($mbox_stream,"{".$imap_server."}".$namebox)) 2461 2532 { 2462 $result = im plode("<br />\n", imap_errors());2533 $result = imap_last_error(); 2463 2534 } 2464 2535 }else{ … … 2471 2542 if(!imap_createmailbox($mbox_stream,"{".$imap_server."}$namebox")) 2472 2543 { 2473 $result = im plode("<br />\n", imap_errors());2544 $result = imap_last_error(); 2474 2545 } 2475 2546 $child .=$this->imap_delimiter; … … 2513 2584 if(!imap_deletemailbox($mbox_stream,"{".$imap_server."}$namebox")) 2514 2585 { 2515 $result = im plode("<br />\n", imap_errors());2586 $result = imap_last_error(); 2516 2587 } 2517 2588 /* … … 2536 2607 if(!imap_renamemailbox($mbox_stream,"{".$imap_server."}$namebox","{".$imap_server."}$new_box")) 2537 2608 { 2538 $result = imap_ errors();2609 $result = imap_last_error(); 2539 2610 } 2540 2611 if($mbox_stream) … … 2593 2664 } 2594 2665 2595 /*Wraps the text dividing the emails as from ">,"*/ 2666 /*Wraps the text dividing the emails as from ">,"*/ 2596 2667 $toaddress = $db->getAddrs(preg_split('/>,/',preg_replace('/>,/', '>>,', $params['input_to']))); 2597 $ccaddress = $db->getAddrs(preg_split('/>,/',preg_replace('/>,/', '>>,', $params['input_cc'])));2598 $ccoaddress = $db->getAddrs(preg_split('/>,/',preg_replace('/>,/', '>>,', $params['input_cco'])));2668 $ccaddress = $db->getAddrs(preg_split('/>,/',preg_replace('/>,/', '>>,', $params['input_cc']))); 2669 $ccoaddress = $db->getAddrs(preg_split('/>,/',preg_replace('/>,/', '>>,', $params['input_cco']))); 2599 2670 2600 2671 if ($toaddress["False"] || $ccaddress["False"] || $ccoaddress["False"]) { … … 2619 2690 $ccoaddress = preg_replace('/\s+>/', '>', $ccoaddress); 2620 2691 2621 $replytoaddress = $params['input_reply to'];2692 $replytoaddress = $params['input_reply_to']; 2622 2693 $subject = $params['input_subject']; 2623 2694 $return_receipt = $params['input_return_receipt']; … … 2625 2696 $encrypt = $params['input_return_cripto']; 2626 2697 $signed = $params['input_return_digital']; 2627 2698 2628 2699 $params['attachments'] = mb_convert_encoding($params['attachments'], "UTF7-IMAP","UTF-8, ISO-8859-1, UTF7-IMAP"); 2629 2700 $message_attachments = $params['message_attachments']; … … 2804 2875 else 2805 2876 $mailService->setFrom('"' . $_SESSION['phpgw_info']['expressomail']['user']['firstname'] . ' ' . $_SESSION['phpgw_info']['expressomail']['user']['lastname'] . '" <' . $_SESSION['phpgw_info']['expressomail']['user']['email'] . '>'); 2877 2878 $mailService->addHeaderField('Reply-To', $replytoaddress); 2806 2879 2807 2880 $bol = $this->add_recipients('to', $toaddress, $mailService); … … 2950 3023 { 2951 3024 $value = json_decode($value, true); 2952 3025 2953 3026 switch ($value['type']) { 2954 3027 case 'imapPart': 2955 3028 $att = $this->getForwardingAttachment(mb_convert_encoding($value['folder'] , 'ISO-8859-1' , 'UTF7-IMAP'),$value['uid'], $value['part']); 2956 if(strstr($body,'src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'"') !== false)//Embeded IMG 3029 3030 if(strstr($body,'src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'"') !== false)//Embeded IMG 2957 3031 { 2958 3032 $body = str_ireplace('src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'"' , 'src="'.$att['name'].'"', $body); … … 3168 3242 $attachment = new attachment(); 3169 3243 $attachment->decodeConf['rfc_822bodies'] = $rfc_822bodies; //Forçar a não decodificação de mensagens em anexo. 3170 $folder = urldecode($folder);3171 3244 $folder = urldecode($folder); 3245 $attachment->setStructureFromMail($folder, $uid); 3172 3246 3173 3247 if($info === true) … … 3414 3488 3415 3489 //Este bloco tem a finalidade de averiguar as permissoes para pastas compartilhadas 3416 3417 3418 3419 3420 * l - lookup (mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox)3421 * r - read (SELECT the mailbox, perform STATUS) 3422 * s - keep seen/unseen information across sessions (set or clear \SEEN flag via STORE, also set \SEEN during APPEND/COPY/ FETCH BODY[...]) 3423 * w - write (set or clear flags other than \SEEN and \DELETED via STORE, also set them during APPEND/COPY) 3424 * i - insert (perform APPEND, COPY into mailbox) 3425 * p - post (send mail to submission address for mailbox, not enforced by IMAP4 itself) 3426 * k - create mailboxes (CREATE new sub-mailboxes in any implementation-defined hierarchy, parent mailbox for the new mailbox name in RENAME) 3427 * x - delete mailbox (DELETE mailbox, old mailbox name in RENAME) 3428 * t - delete messages (set or clear \DELETED flag via STORE, set \DELETED flag during APPEND/COPY) 3429 * e - perform EXPUNGE and expunge as a part of CLOSE 3430 * a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) 3431 * Os Atributos da ACL para pastas compartilhadas são definidos no arquivo sharemailbox.js, na função setaclfromuser 3432 * Os Atributos da ACL para contas compartilhadas são definidos no arquivo shared_accounts.js, na função setaclfromuser 3433 3434 $acl_share_delete = (stripos($acl,'t') !== false && stripos($acl,'e') !== false); 3435 3436 if (!$acl_share_delete) { 3490 if (substr($folder,0,4) == 'user'){ 3491 $acl = $this->getacltouser($folder, isset($params['decoded'])); 3492 3493 /* 3494 * l - lookup (mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox) 3495 * r - read (SELECT the mailbox, perform STATUS) 3496 * s - keep seen/unseen information across sessions (set or clear \SEEN flag via STORE, also set \SEEN during APPEND/COPY/ FETCH BODY[...]) 3497 * w - write (set or clear flags other than \SEEN and \DELETED via STORE, also set them during APPEND/COPY) 3498 * i - insert (perform APPEND, COPY into mailbox) 3499 * p - post (send mail to submission address for mailbox, not enforced by IMAP4 itself) 3500 * k - create mailboxes (CREATE new sub-mailboxes in any implementation-defined hierarchy, parent mailbox for the new mailbox name in RENAME) 3501 * x - delete mailbox (DELETE mailbox, old mailbox name in RENAME) 3502 * t - delete messages (set or clear \DELETED flag via STORE, set \DELETED flag during APPEND/COPY) 3503 * e - perform EXPUNGE and expunge as a part of CLOSE 3504 * a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) 3505 * Os Atributos da ACL para pastas compartilhadas são definidos no arquivo sharemailbox.js, na função setaclfromuser 3506 * Os Atributos da ACL para contas compartilhadas são definidos no arquivo shared_accounts.js, na função setaclfromuser 3507 */ 3508 $acl_share_delete = (stripos($acl,'t') !== false && stripos($acl,'e') !== false); 3509 3510 if (!$acl_share_delete) { 3437 3511 $return['status'] = false; 3438 3512 return $return; … … 3514 3588 imap_close($mbox_stream); 3515 3589 3516 $msg_error = "move_messages() line ".__LINE__.": ". imap_last_error()." folder:".$newmailbox; 3517 trigger_error($msg_error); 3518 return $msg_error; 3590 $msg_error = "move_messages() line ".__LINE__.": ". imap_last_error()." folder:".$newmailbox; 3591 trigger_error($msg_error); 3592 return $msg_error; 3519 3593 } 3520 3594 } … … 3731 3805 $this->mbox = $this->open_mbox($folder); 3732 3806 3807 if($offsetEnd == 0 && $offsetBegin == 0){ 3808 $offsetEnd = imap_num_msg($this->mbox); 3809 $offsetBegin = 1; 3810 } 3733 3811 return $this->messages_sort($sort_box_type,$sort_box_reverse, $search_box_type,$offsetBegin,$offsetEnd,$folder); 3734 3812 } … … 3878 3956 function empty_folder($params) 3879 3957 { 3880 $folder = 'INBOX'. $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server'][$params['clean_folder']];3958 $folder = (isset($params['shared']) ? $params['shared'] : 'INBOX') . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server'][$params['clean_folder']]; 3881 3959 $mbox_stream = $this->open_mbox($folder); 3882 3960 $return = imap_delete($mbox_stream,'1:*'); 3961 $return = imap_errors(); 3883 3962 if($mbox_stream) 3884 3963 imap_close($mbox_stream, CL_EXPUNGE); … … 4322 4401 $mbox_acl = imap_getacl($mbox_stream, 'INBOX'); 4323 4402 4324 $oldAcls = array('d' , 'c' , 'a'); 4325 $newAcls = array('xte','ik', ''); 4326 4327 $return = array(); 4403 $oldAcls = array('d' , 'c' , 'a'); 4404 $newAcls = array('xte','ik', ''); 4405 4406 $return = array(); 4328 4407 foreach ($mbox_acl as $user => $acl) 4329 4408 { 4330 if($user == $this->username) 4331 continue; 4332 4333 //Compatibiliza acls no padrão antigo para o novo 4334 $acl = str_replace($oldAcls, $oldAcls, $acl); 4335 4336 $return[$user] = array( 4337 'cn' => $this->ldap->uid2cn($user) , 4338 'acls' => $acl 4339 ); 4340 } 4341 return $return; 4342 } 4343 4344 function setacl($params) 4345 { 4346 $old_users = $this->getacl(); 4347 $new_users = unserialize($params['acls']); 4348 4349 $mbox_stream = $this->open_mbox(); 4350 $serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"; 4351 $mailboxes_list = imap_getmailboxes($mbox_stream, $serverString, "user".$this->imap_delimiter.$this->username."*"); 4409 if($user == $this->username) 4410 continue; 4411 4412 //Compatibiliza acls no padrão antigo para o novo 4413 $acl = str_replace($oldAcls, $oldAcls, $acl); 4414 4415 $return[$user] = array( 4416 'cn' => $this->ldap->uid2cn($user) , 4417 'acls' => $acl 4418 ); 4419 } 4420 return $return; 4421 } 4422 4423 function setacl($params) 4424 { 4425 $old_users = $this->getacl(); 4426 $new_users = unserialize($params['acls']); 4352 4427 4353 4428 foreach ($new_users as $user => $value) { … … 4358 4433 } 4359 4434 } 4360 4361 foreach ($new_users as $user => $value) 4435 $serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"; 4436 $mailboxes_list = imap_getmailboxes($mbox_stream, $serverString, "user".$this->imap_delimiter.$this->username."*"); 4437 4438 foreach ($new_users as $user => $value) { 4439 if(isset($old_users[$user]) && $value['acls'] == $old_users[$user]['acls']) 4440 { 4441 unset($old_users[$user]); 4442 unset($new_users[$user]); 4443 } 4444 } 4445 4446 foreach ($new_users as $user => $value) 4362 4447 { 4363 if (is_array($mailboxes_list))4364 { 4365 foreach ($mailboxes_list as $key => $val) 4366 { 4367 $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 4368 //$folder = str_replace("&-", "&", $folder); 4369 $folder = imap_utf7_encode($folder); 4370 imap_setacl ($mbox_stream, $folder, "$user", $value['acls']); 4371 4372 } 4373 } 4374 if(isset($old_users[$user])) 4375 unset($old_users[$user]); 4376 } 4377 4378 4448 if (is_array($mailboxes_list)) 4449 { 4450 foreach ($mailboxes_list as $key => $val) 4451 { 4452 $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 4453 //$folder = str_replace("&-", "&", $folder); 4454 $folder = imap_utf7_encode($folder); 4455 imap_setacl ($mbox_stream, $folder, "$user", $value['acls']); 4456 4457 } 4458 } 4459 if(isset($old_users[$user])) 4460 unset($old_users[$user]); 4461 } 4462 4463 foreach ($old_users as $user => $value) 4379 4464 { 4380 if (is_array($mailboxes_list))4381 { 4382 foreach ($mailboxes_list as $key => $val) 4383 { 4384 $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 4385 //$folder = str_replace("&-", "&", $folder); 4386 $folder = imap_utf7_encode($folder); 4387 imap_setacl ($mbox_stream, $folder, "$user", ""); 4388 4389 } 4390 } 4391 } 4392 4465 if (is_array($mailboxes_list)) 4466 { 4467 foreach ($mailboxes_list as $key => $val) 4468 { 4469 $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 4470 //$folder = str_replace("&-", "&", $folder); 4471 $folder = imap_utf7_encode($folder); 4472 imap_setacl ($mbox_stream, $folder, "$user", ""); 4473 4474 } 4475 } 4476 } 4477 4393 4478 4394 4479 return true; … … 4407 4492 //Afim de tratar as pastas compartilhadas, verificandos as permissoes de operacao sobre as mesmas 4408 4493 //No caso de se tratar da caixa do proprio usuario logado, utiliza a sintaxe abaixo 4409 if(substr($user,0,5) != 'user'.$this->imap_delimiter) 4410 $mbox_acl = imap_getacl($mbox_stream, 'user'.$this->imap_delimiter.$user); 4494 if(substr($user,0,5) != 'user'.$this->imap_delimiter) 4495 $mbox_acl = imap_getacl($mbox_stream, 'user'.$this->imap_delimiter.$user); 4411 4496 else 4412 $mbox_acl = imap_getacl($mbox_stream, $user); 4413 4414 return (isset($mbox_acl[$this->username])) ? $mbox_acl[$this->username] : ''; 4497 $mbox_acl = imap_getacl($mbox_stream, $user); 4498 4499 return (isset($mbox_acl[$this->username])) ? $mbox_acl[$this->username] : ''; 4500 4415 4501 } 4416 4502 … … 4723 4809 $array_params = explode(";;", $params); 4724 4810 $id_msg = $array_params[0]; 4725 $msg_user = $array_params[1]; 4811 $msg_user = $array_params[1]; 4812 $msg_folder = $array_params[2]; 4726 4813 $msg_folder = $array_params[2]; 4727 4814 … … 5294 5381 foreach ($messages as $k => $m) { 5295 5382 $headers = imap_fetch_overview($this->mbox, $m, FT_UID); 5383 5296 5384 $date = explode(" ", $headers[0]->date); 5297 5385 $result[$m."_".$folder] = array ( … … 5325 5413 } 5326 5414 $r = $this->get_info_msg(array('msg_number' => $message_number, 'msg_folder' =>urlencode($message_folder), 'alarm' => ($alarm))); 5415 5327 5416 return $r; 5328 5417 }
Note: See TracChangeset
for help on using the changeset viewer.