Ignore:
Timestamp:
09/17/12 14:30:47 (12 years ago)
Author:
douglas
Message:

Ticket #0000 - Copiadas as alterações do Trunk. Versão final da 2.4.2.

Location:
branches/2.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4

  • branches/2.4/expressoMail1_2/inc/class.imap_functions.inc.php

    r7180 r7228  
    128128                $result = true; 
    129129                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 
    132133                imap_close($mbox);  
    133134                return $result; 
     
    10611062                $content = $this->html2txt($content);    
    10621063                $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')); 
    10641065                return $return; 
    10651066        } 
     
    12351236                $return['sender']['name'] = isset($sender[0]->personal) ? $this->decode_string($sender[0]->personal): ''; 
    12361237                $return['sender']['email'] = $this->decode_string($sender[0]->mailbox . "@" . $sender[0]->host); 
    1237                  
     1238 
    12381239                if ($return['sender']['name']) 
    12391240                { 
     
    12561257                                if (!empty($tmp->personal)) 
    12571258                                { 
    1258                                         $personal_tmp = $this->formatMailObject($tmp);  
    1259                         $return['toaddress2'] .= '"' . $personal_tmp['name'] . '"'; 
     1259                                        $personal_tmp = $this->formatMailObject($tmp); 
     1260                                        $return['toaddress2'] .= '"' . $personal_tmp['name'] . '"'; 
    12601261                                        $return['toaddress2'] .= " "; 
    12611262                                        $return['toaddress2'] .= "<"; 
     
    12881289                                if (!empty($tmp_cc->personal)) 
    12891290                                { 
    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']. '"'; 
    12921293                                        $return['cc'] .= " "; 
    12931294                                        $return['cc'] .= "<"; 
     
    13281329                                if (!empty($tmp_bcc->personal)) 
    13291330                                { 
    1330                                         $personal_tmp_bcc = $this->formatMailObject($tmp_bcc);  
    1331                         $return['bcc'] .= '"' . $personal_tmp_bcc['name'] . '"'; 
     1331                                        $personal_tmp_bcc = $this->formatMailObject($tmp_bcc); 
     1332                                        $return['bcc'] .= '"' . $personal_tmp_bcc['name'] . '"'; 
    13321333                                        $return['bcc'] .= " "; 
    13331334                                        $return['bcc'] .= "<"; 
     
    13551356                $reply_to = $header->reply_to; 
    13561357                $return['reply_to'] = ""; 
     1358                 
    13571359                if (is_object($reply_to[0])) 
    13581360                { 
    13591361                        if ($return['from']['email'] != ($reply_to[0]->mailbox."@".$reply_to[0]->host)) 
    13601362                        { 
    1361                                 if (!empty($reply_to[0]->personal)) 
     1363                                foreach ($reply_to as $tmp_reply_to) 
    13621364                                { 
    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'] . '"'; 
    13661369                                                $return['reply_to'] .= " "; 
    13671370                                                $return['reply_to'] .= "<"; 
    1368                                                 $return['reply_to'] .= $personal_reply_to['email']; 
     1371                                                $return['reply_to'] .= $personal_tmp_reply_to['email']; 
    13691372                                                $return['reply_to'] .= ">"; 
     1373                                                $return['reply_to'] .= ", "; 
    13701374                                        } 
    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'] .= ", "; 
    13731382                                        } 
    13741383                                } 
    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 
    13821392                $return['subject'] = ( isset($header->subject) && trim($header->subject) !== '' ) ?  self::decodeMimeString($header->subject) : $this->functions->getLang('(no subject)   '); 
    13831393 
     
    13981408                }   
    13991409                $return['alarm'] = $alarm; 
    1400          
     1410                 
    14011411                return $return; 
    14021412        } 
     
    18961906            $body = str_ireplace('<o:p>&nbsp;</o:p>','<br />', $body);//Qubra de linha do MSO 
    18971907            $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            } 
    18981917             
    18991918 
     
    19321951            $body = str_ireplace('position:absolute;', '', $body); 
    19331952                 
     1953            $body = str_ireplace('position:absolute;', '', $body); 
     1954 
    19341955            //Remoção de tags <span></span> para correção de erro no firefox 
    19351956            //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>. 
     
    21452166                $return['status'] = true; 
    21462167 
    2147                         //Este bloco tem a finalidade de averiguar as permissoes para pastas compartilhadas  
    2148             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 
    21722193                return $return; 
    21732194        } 
    2174  
    21752195 
    21762196        function refresh($params) 
     
    23672387            foreach ($return as $i => &$vv) 
    23682388            { 
    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 ACENTOS  
    2372             $vv['folder_name'] = mb_convert_encoding($vv['folder_name'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA NOME DAS PASTAS COM ACENTOS  
    2373             $vv['folder_parent'] = mb_convert_encoding($vv['folder_parent'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA NOME DAS PASTAS COM ACENTOS 
     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 
    23742394            } 
    23752395 
     
    24122432                        $decifrada = mb_convert_encoding('INBOX'.$this->imap_delimiter.'decifradas','UTF7-IMAP','ISO-8859-1'); //Ignorar esta pasta decifrada 
    24132433                        $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 
    24192485                unset($folders_list); //destroy array de objetos desnecessarios 
    24202486                 
     
    24342500                                $append['folder_hasChildren'] = (($vv['attributes'] == 32) && ($vv['name'] != 'INBOX')) ? 1 : 0; 
    24352501                                $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                                } 
    24362507                                $return[] = $append; 
    24372508                        } 
     
    24402511                $quotaInfo =  (!isset($params['noQuotaInfo'])) ? $this->get_quota( array('folder_id' => $currentFolder)) : false; //VERIFICA SE O USUARIO TEM COTA 
    24412512 
    2442                 return ( ( is_array($quotaInfo) ) ?  array_merge($return, $quotaInfo) : $return );         
     2513                return ( ( is_array($quotaInfo) ) ?  array_merge($return, $quotaInfo) : $return ); 
    24432514        } 
    24442515     
     
    24602531                        if(!imap_createmailbox($mbox_stream,"{".$imap_server."}".$namebox)) 
    24612532                        { 
    2462                                 $result = implode("<br />\n", imap_errors()); 
     2533                                $result = imap_last_error(); 
    24632534                        } 
    24642535                }else{ 
     
    24712542                                if(!imap_createmailbox($mbox_stream,"{".$imap_server."}$namebox")) 
    24722543                                { 
    2473                                         $result = implode("<br />\n", imap_errors());                                            
     2544                                        $result = imap_last_error();                                             
    24742545                                } 
    24752546                                $child .=$this->imap_delimiter; 
     
    25132584                if(!imap_deletemailbox($mbox_stream,"{".$imap_server."}$namebox")) 
    25142585                { 
    2515                         $result = implode("<br />\n", imap_errors()); 
     2586                        $result = imap_last_error(); 
    25162587                } 
    25172588                /* 
     
    25362607                if(!imap_renamemailbox($mbox_stream,"{".$imap_server."}$namebox","{".$imap_server."}$new_box")) 
    25372608                { 
    2538                         $result = imap_errors(); 
     2609                        $result = imap_last_error(); 
    25392610                } 
    25402611                if($mbox_stream) 
     
    25932664            } 
    25942665 
    2595             /*Wraps the text dividing the emails as from ">,"*/  
     2666            /*Wraps the text dividing the emails as from ">,"*/ 
    25962667            $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']))); 
    25992670 
    26002671            if ($toaddress["False"] || $ccaddress["False"] || $ccoaddress["False"]) { 
     
    26192690            $ccoaddress = preg_replace('/\s+>/', '>', $ccoaddress); 
    26202691 
    2621             $replytoaddress = $params['input_replyto']; 
     2692            $replytoaddress = $params['input_reply_to']; 
    26222693            $subject = $params['input_subject']; 
    26232694            $return_receipt = $params['input_return_receipt']; 
     
    26252696            $encrypt = $params['input_return_cripto']; 
    26262697            $signed = $params['input_return_digital']; 
    2627                          
     2698 
    26282699                        $params['attachments'] = mb_convert_encoding($params['attachments'], "UTF7-IMAP","UTF-8, ISO-8859-1, UTF7-IMAP"); 
    26292700            $message_attachments = $params['message_attachments']; 
     
    28042875            else 
    28052876                $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); 
    28062879 
    28072880            $bol = $this->add_recipients('to', $toaddress, $mailService); 
     
    29503023                { 
    29513024                    $value = json_decode($value, true); 
    2952                                      
     3025 
    29533026                    switch ($value['type']) { 
    29543027                        case 'imapPart': 
    29553028                                $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 
    29573031                                {     
    29583032                                    $body = str_ireplace('src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'"' , 'src="'.$att['name'].'"', $body); 
     
    31683242            $attachment = new attachment(); 
    31693243            $attachment->decodeConf['rfc_822bodies'] = $rfc_822bodies; //Forçar a não decodificação de mensagens em anexo. 
    3170                                     $folder = urldecode($folder);  
    3171                                 $attachment->setStructureFromMail($folder, $uid); 
     3244                        $folder = urldecode($folder); 
     3245                $attachment->setStructureFromMail($folder, $uid); 
    31723246             
    31733247            if($info === true) 
     
    34143488 
    34153489                //Este bloco tem a finalidade de averiguar as permissoes para pastas compartilhadas 
    3416                 if (substr($folder,0,4) == 'user'){ 
    3417                         $acl = $this->getacltouser($folder, isset($params['decoded'])); 
    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) { 
    34373511                                $return['status'] = false; 
    34383512                                return $return; 
     
    35143588                                        imap_close($mbox_stream); 
    35153589                                 
    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; 
    35193593                        } 
    35203594                } 
     
    37313805                        $this->mbox = $this->open_mbox($folder); 
    37323806 
     3807                if($offsetEnd == 0 && $offsetBegin == 0){ 
     3808                        $offsetEnd = imap_num_msg($this->mbox); 
     3809                        $offsetBegin = 1; 
     3810                } 
    37333811                return $this->messages_sort($sort_box_type,$sort_box_reverse, $search_box_type,$offsetBegin,$offsetEnd,$folder); 
    37343812        } 
     
    38783956        function empty_folder($params) 
    38793957        { 
    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']]; 
    38813959                $mbox_stream = $this->open_mbox($folder); 
    38823960                $return = imap_delete($mbox_stream,'1:*'); 
     3961                $return = imap_errors(); 
    38833962                if($mbox_stream) 
    38843963                        imap_close($mbox_stream, CL_EXPUNGE); 
     
    43224401                $mbox_acl = imap_getacl($mbox_stream, 'INBOX'); 
    43234402 
    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(); 
    43284407                foreach ($mbox_acl as $user => $acl) 
    43294408                { 
    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']); 
    43524427 
    43534428            foreach ($new_users as $user => $value) {  
     
    43584433                    }  
    43594434            }  
    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) 
    43624447                { 
    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             foreach ($old_users as $user => $value) 
     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) 
    43794464                { 
    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                 
    43934478 
    43944479                return true; 
     
    44074492                //Afim de tratar as pastas compartilhadas, verificandos as permissoes de operacao sobre as mesmas 
    44084493                //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); 
    44114496                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                
    44154501        } 
    44164502 
     
    47234809                $array_params = explode(";;", $params);  
    47244810                $id_msg   = $array_params[0];  
    4725                 $msg_user = $array_params[1];  
     4811                $msg_user = $array_params[1]; 
     4812                $msg_folder = $array_params[2]; 
    47264813            $msg_folder = $array_params[2];  
    47274814                 
     
    52945381                                foreach ($messages as $k => $m) { 
    52955382                                        $headers = imap_fetch_overview($this->mbox, $m, FT_UID); 
     5383 
    52965384                                        $date = explode(" ", $headers[0]->date);  
    52975385                                        $result[$m."_".$folder] = array ( 
     
    53255413                } 
    53265414                $r = $this->get_info_msg(array('msg_number' => $message_number, 'msg_folder' =>urlencode($message_folder), 'alarm' => ($alarm))); 
     5415 
    53275416                return $r; 
    53285417        } 
Note: See TracChangeset for help on using the changeset viewer.