Changeset 5959


Ignore:
Timestamp:
04/17/12 16:09:39 (12 years ago)
Author:
adriano
Message:

Ticket #2633 - alteracoes de backend e interceptadores para a funcionalidade de sinalizadores

Location:
trunk/prototype
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/config/followupflagged.ini

    r5817 r5959  
    22PostgreSQL.concept = expressomail_message_followupflag 
    33 
     4[PostgreSQL.before.create] 
     5doImapCreate = modules/mail/interceptors/Helpers.php 
     6 
     7[PostgreSQL.after.read] 
     8doImapRead = modules/mail/interceptors/Helpers.php 
     9 
     10[PostgreSQL.after.delete] 
     11doImapDelete = modules/mail/interceptors/Helpers.php 
    412 
    513[PostgreSQL.before.find] 
    6 clearFilterAtFind = modules/mail/interceptors/Helpers.php 
     14reFilterFind = modules/mail/interceptors/Helpers.php 
    715 
    816[PostgreSQL.after.find] 
    917doImapFind = modules/mail/interceptors/Helpers.php 
    1018 
    11 [after.find] 
    12 deepnessFollowupflaggeds = modules/mail/interceptors/Helpers.php 
    13  
    14 [Imap.before.create] 
    15 letFollowupflaggedKeepUnique = modules/mail/interceptors/Helpers.php 
    16  
    17 [PostgreSQL.after.create] 
    18 doImapCreate = modules/mail/interceptors/Helpers.php 
    19  
    20 [PostgreSQL.before.read] 
    21 stripURIAttrs = modules/mail/interceptors/Helpers.php 
    22  
    23 [PostgreSQL.after.read] 
    24 doImapRead = modules/mail/interceptors/Helpers.php 
    25  
    26 [PostgreSQL.before.delete] 
    27 doImapDelete = modules/mail/interceptors/Helpers.php 
    28  
    29  
    30 [PostgreSQL.before.update] 
    31 stripURIAttrs = modules/mail/interceptors/Helpers.php 
    32 ;doImapUpdate = modules/mail/interceptors/Helpers.php 
    33  
    34  
    3519[PostgreSQL.mapping] 
    36 id = id 
     20id = id  
    3721followupflagId = followupflag_id 
     22messageId = message_id 
    3823alarmDeadline = alarm_deadline 
    3924doneDeadline = done_deadline 
     
    4429 
    4530[Imap.mapping] 
    46 id = id 
    47 followupflagId = followupflag_id 
     31;id = id 
    4832folderName = folder_name 
    49 messageNumber = message_id 
    50  
     33messageNumber = message_number 
     34messageId = message_id 
     35;TODO - modificar o nome de atributo de message_id para "Message-Id", que é como aparece no header da mensagem 
  • trunk/prototype/modules/mail/interceptors/Helpers.php

    r5909 r5959  
    6969        } 
    7070         
     71        //label:before.create 
     72        public function verifyNameLabel(&$uri , &$params , &$criteria , $original){ 
     73                $nameLabel = $params['name']; 
     74                $Labels = Controller::find(array('concept' => 'label'), false, array('filter' => array('i=', 'name', $nameLabel) )); 
     75                if($Labels){ 
     76                        Throw new Exception('Já existe um marcador com esse nome.'); 
     77                } 
     78        } 
     79                 
    7180        public static function in_arrayr($needle, $haystack) { 
    7281                //if(!is_array($haystack)) return false; 
     
    7887                return false; 
    7988        }  
    80                  
    8189         
    8290/** 
     
    8492 */  
    8593 
    86         //followupflag:before.find 
    87         public function addDefaultElementsFilter (&$uri , &$params , &$criteria , $original ){ 
    88                 //if (!self::in_arrayr('id', $criteria['filter'])) { 
    89                         $defaultsFilter = array( 'IN' , 'id' , array('1','2','3','4','5','6') ); 
    90                          
    91                         if (isset($criteria['filter']) && $criteria['filter']!=NULL && count($criteria['filter']) != 0) 
    92                                 $criteria['filter'] = array( 'OR', $criteria['filter'], $defaultsFilter ); 
    93                         else 
    94                                 $criteria['filter'] =  $defaultsFilter; 
    95                 //} 
    96         } 
    97          
    98         //followupflagged:after.find 
    99         public function deepnessFollowupflaggeds( &$uri , &$result , &$criteria , $original ){                 
    100  
    101                 if(isset($original['criteria']['deepness'])) 
    102                 { 
    103                         foreach ($result as $i => $v) 
    104                         { 
    105                                 if(isset($v['followupflagId'])) 
    106                                 { 
    107                                         $followupflags = Controller::find(array('concept' => 'followupflag'), false, array('filter' => array('=', 'id', $v['followupflagId']) )); 
    108                                          
    109                                         /** 
    110                                          * Devido há inconsistencias na chamada do interceptor addDefaultElementsFilter (followupflag:before.find) 
    111                                          * os followupflag defaults são inseridos no retorno, por isso é necessário procurar o objeto correto 
    112                                          * através do id 
    113                                          */ 
    114                                         foreach ($followupflags as $followupflag) { 
    115                                                 if ($v['followupflagId'] == $followupflag['id']) { 
    116                                                         $result[$i]['followupflag'] = $followupflag; 
    117                                                         break; 
    118                                                 } 
    119                                         } 
    120                                 } 
    121                                  
    122                                 if(isset($v['messageNumber']) && isset($v['folderName'])) 
    123                                 { 
    124                                         $details = $original['criteria']['deepness'] == '1' ? 'headers' : 'all'; 
    125                                          
    126                                         $imapService = new imap_functions(); 
    127                                         $message = $imapService->getMessages(array('messages' => array($v['folderName'] => array($v['messageNumber'])), 'details' => $details)); 
    128                                         $result[$i]['message'] = $message[$v['folderName']][0];                          
    129                                 }      
    130                         } 
    131                 } 
    132  
     94        //Remove as dependencias de uma followupflag  
     95        public function clearAllFlaggedOfFollowupflag( &$uri , &$result , &$criteria , $original ){ 
     96                //remove apenas se vier o id da Followupflag 
     97                if(isset($uri['id'])) 
     98                        Controller::deleteALL(array('concept' => 'followupflagged'), null , array('filter' => array('=' , 'followupflagId' , $uri['id']))); 
     99 
     100        } 
     101 
     102 
     103        //followupflagged:PostgreSQL.before.delete 
     104        public function doImapDelete( &$uri , &$params , &$criteria , $original ) { 
     105         
     106                $imap_uri = $uri; 
     107                $imap_uri['service'] = 'Imap'; 
     108                list($messageId, $uri['id']) = explode('#', $uri['id']); 
     109 
     110                $result = Controller::delete($imap_uri, $params, $imap_criteria); 
     111 
     112                if (!$result) 
     113                        return false; 
     114        } 
     115         
     116 
     117         
     118                 
     119 
     120         
     121         
     122         
     123         
     124         
     125         
     126         
     127         
     128         
     129         
     130         
     131         
     132         
     133         
     134         
     135         
     136         
     137         
     138         
     139         
     140         
     141         
     142        //followupflagged:PostgreSQL.before.create 
     143        public function doImapCreate( &$uri , &$params , &$criteria , $original ) {      
     144                 
     145                $imap_uri = $uri; 
     146                $imap_uri['service'] = 'Imap'; 
     147 
     148                $params = Controller::create($imap_uri, $params); 
     149                 
     150                if (!$params) 
     151                        return false;    
     152        } 
     153         
     154        //followupflagged:PostgreSQL.after.read 
     155        public function doImapRead( &$uri , &$result , &$criteria , $original ) { 
     156 
     157                if ($reusult) { 
     158                        $imap_result = Controller::read( 
     159                                array('concept' => 'followupflagged', 'service' => 'Imap'),  
     160                                false,  
     161                                array('filter' => array('=', 'messageId', $result['messageId'])) 
     162                        ); 
     163                } 
     164 
     165                if (!$imap_result) { 
     166                        /** 
     167                         * TODO - deletar do banco se não existe no imap  
     168                         */ 
     169                         return false; 
     170                } 
     171                 
     172                $result = $result + $imap_result; 
     173                 
    133174                return $result; 
    134         }        
    135          
    136         //followupflagged:PostgreSQL.before.find 
    137         public function clearFilterAtFind( &$uri , &$params , &$criteria , $original ) { 
    138          
    139                 if ($criteria['filter'] &&  
    140                                 (self::in_arrayr('messageNumber', $criteria['filter']) || self::in_arrayr('folderName', $criteria['filter'])) ) { 
    141                         unset($criteria['filter']); 
    142                 } 
    143                  
    144                 /** 
    145                  * TODO - fazer parse do $criteria['filter'] para fazer strip no id composto 
    146                  */ 
    147         } 
     175        } 
     176         
    148177         
    149178        /** 
     
    153182        //followupflagged:PostgreSQL.after.find 
    154183        public function doImapFind( &$uri , &$result , &$criteria , $original ){ 
    155                 /** 
    156                  * TODO - ver implicações de busca com id no filtro  
    157                  */ 
    158  
    159                 if ($result) { 
    160                         $list = array(); 
    161                         foreach ($result as $followupflagged) 
    162                                 $list[] = $followupflagged['id']; 
    163                                  
    164                         $filter = array( 'IN' , 'id' , $list ); 
    165                          
    166                         if (isset($original['criteria']['filter']) && $original['criteria']['filter']!=NULL && count($original['criteria']['filter']) != 0) 
    167                                 $criteria['filter'] = array( 'AND', $original['criteria']['filter'], $filter ); 
    168                         else 
    169                                 $criteria['filter'] =  $filter; 
    170                 } 
    171                  
     184 
    172185                $imap_uri = $uri; 
    173186                $imap_uri['service'] = 'Imap'; 
    174                 $imap_result = Controller::find($imap_uri, $result, $criteria); 
    175                  
     187                $imap_result = Controller::find($imap_uri, false, $original['criteria']); 
     188 
    176189                /** 
    177190                 * Mescla os dados vindos do PostgreSQL com os dados vindos do Imap 
     
    179192                $merge_result = array (); 
    180193                foreach ($imap_result as $ir) { 
    181                         list($messageId, $flagId) = explode('#', $ir['id']); 
    182                          
     194                 
    183195                        foreach($result as $r) { 
    184                                 if ($r['id'] == $flagId) { 
    185                                         $r['id'] = $ir['id']; 
    186                                         $r['messageNumber'] = $ir['messageNumber']; 
    187                                         $r['folderName'] = $ir['folderName']; 
    188                                          
    189                                         $merge_result[] = $r; 
     196                                if ($r['messageId'] == $ir['messageId']) {                       
     197                                        $merge_result[] = $r + $ir; 
     198                                        break; 
    190199                                } 
    191200                        } 
     
    195204        } 
    196205 
    197         //followupflagged:Imap.before.create 
    198         public function letFollowupflaggedKeepUnique (&$uri , &$params , &$criteria , $original ){ 
    199  
    200                 if (isset($params['folderName']) && isset($params['messageNumber'])) { 
    201                         $filter = array ('AND', array('=', 'folderName', $params['folderName']), array('=', 'messageNumber', $params['messageNumber'])); 
    202                         $toClearURI = array('concept' => 'followupflagged', 'service' => 'Imap'); 
    203  
    204                         //Obtém do banco um possível sinalizador existente 
    205                         $imap_result = Controller::find($toClearURI, false, array('filter' => $filter)); 
    206                          
    207                         //Se existe um sinalizador nesta mensagem, deleta-o 
    208                         foreach ($imap_result as $r) { 
    209                                 /** 
    210                                  * TODO - deletar sem id 
    211                                  */ 
     206        //followupflagged:PostgreSQL.before.find 
     207        public function reFilterFind (&$uri , &$params , &$criteria , $original ){ 
     208                /** 
     209                 * Se p filtor incluir atributos da mensagem que o banco de dados não conhece,   
     210                 * deve-se obter os messageId dos itens do resultado e passálos num novo filtro 
     211                 * que o banco conheça 
     212                 */ 
     213                if (self::in_arrayr('messageNumber', $criteria) || self::in_arrayr('folderName', $criteria)) { 
     214                        $result = Controller::find(array('concept' => 'message'), array('messageId'), array('filter' => $criteria['filter'])); 
     215                        $idList = array(); 
     216                        foreach ($result as $message) 
     217                                $idList[] = $message['messageId']; 
    212218                                 
    213                                 //deleta no Imap 
    214                                 $toClearURI['id'] = $r['id']; 
    215                                 Controller::delete($toClearURI, false, false); 
    216                                  
    217                                 //deleta no PostgreSQL 
    218                                 list($messageId, $toClearURI['id']) = explode('#', $r['id']); 
    219                                 $toClearURI['service'] = 'PostgreSQL'; 
    220                                 Controller::delete($toClearURI, false, false); 
    221                         } 
    222                 } 
    223  
    224         } 
    225  
    226         //Remove as dependencias de uma followupflag  
    227         public function clearAllFlaggedOfFollowupflag( &$uri , &$result , &$criteria , $original ){ 
    228                 //remove apenas se vier o id da Followupflag 
    229                 if(isset($uri['id'])) 
    230                         Controller::deleteALL(array('concept' => 'followupflagged'), null , array('filter' => array('=' , 'followupflagId' , $uri['id']))); 
    231  
    232         } 
    233          
    234  
    235         //followupflagged:PostgreSQL.after.create 
    236         public function doImapCreate( &$uri , &$result , &$criteria , $original ) {      
    237                 /** 
    238                  * Se não consegue salvar no banco, ele retorna objeto válido, porém sem id 
    239                  */ 
    240                 if (!isset($result['id'])) return false; 
    241                  
    242                 $imap_uri = $original['URI'];; 
    243                 $imap_uri['service'] = 'Imap'; 
    244  
    245                 $imap_params = array_merge($original['properties'], $result); 
    246                  
    247                 $result = array(); 
    248                 if ($imap_params['folderName'] && $imap_params['messageNumber'] && $imap_params['id']) { 
    249                         $imap_params['id'] = $imap_params['folderName'] . '/' . $imap_params['messageNumber'] . '#' . $imap_params['id'];  
    250                         $result = Controller::create($imap_uri, $imap_params); 
    251                 } 
    252  
    253                 if (!$result) { 
    254                         //TODO - rollback 
    255                 } 
    256         } 
    257          
    258         //followupflagged:PostgreSQL.after.read 
    259         public function doImapRead( &$uri , &$result , &$criteria , $original ) { 
    260                  
    261                 $imap_uri = $original['URI']; 
    262                 $imap_uri['service'] = 'Imap'; 
    263  
    264                 $imap_result = Controller::read($imap_uri, $params, $imap_criteria); 
    265                  
    266                 if (!$imap_result) 
    267                         return false;            
    268                  
    269                 $result = array_merge($result, $imap_result); 
    270  
    271         } 
    272          
    273         //followupflagged:PostgreSQL.before.<...> 
    274         public function stripURIAttrs( &$uri , &$params , &$criteria , $original ) { 
    275                 list($messageId, $uri['id']) = explode('#', $uri['id']); 
    276                 $params['id'] = $uri['id']; 
    277         } 
    278  
    279         //followupflagged:PostgreSQL.before.delete 
    280         public function doImapDelete( &$uri , &$params , &$criteria , $original ) { 
    281          
    282                 $imap_uri = $uri; 
    283                 $imap_uri['service'] = 'Imap'; 
    284                 list($messageId, $uri['id']) = explode('#', $uri['id']); 
    285  
    286                 $result = Controller::delete($imap_uri, $params, $imap_criteria); 
    287  
    288                 if (!$result) 
    289                         return false; 
    290         } 
    291          
    292         //followupflagged:PostgreSQL.before.update 
    293         public function doImapUpdate( &$uri , &$params , &$criteria , $original ) { 
    294                 /** 
    295                  * Para os conceitos "labeled" e "followupflagged", só faz sentido o update de  
    296                  * atributos gravados no banco de dados e nunca no IMAP. 
    297                  */ 
    298                 //$imap_uri = $uri; 
    299                 //$imap_uri['service'] = 'Imap'; 
    300                 //$result = Controller::update($imap_uri, $params, $criteria); 
    301         } 
    302          
    303                  
    304         //label:before.create 
    305         public function verifyNameLabel(&$uri , &$params , &$criteria , $original){ 
    306                 $nameLabel = $params['name']; 
    307                 $Labels = Controller::find(array('concept' => 'label'), false, array('filter' => array('i=', 'name', $nameLabel) )); 
    308                 if($Labels){ 
    309                         Throw new Exception('Já existe um marcador com esse nome.'); 
    310                 } 
    311         } 
     219                        $filter = array( 'IN' , 'messageId' , $idList ); 
     220 
     221                        $criteria['filter'] =  $filter; 
     222                }        
     223        }        
    312224 
    313225} 
  • trunk/prototype/services/ImapServiceAdapter.php

    r5826 r5959  
    22 
    33include_once ROOTPATH."/../expressoMail1_2/inc/class.imap_functions.inc.php"; 
    4 require_once ROOTPATH.'/library/uuid/class.uuid.php'; 
    5  
    64 
    75class ImapServiceAdapter extends imap_functions/* implements Service*/ 
     
    1917    public function find( $URI, $justthese = false, $criteria = false ) 
    2018        {  
    21                 //require_once dirname(__FILE__) . '/../api/controller.php'; 
    2219                $context = $justthese['context']; 
    2320                $URI = $URI['concept']; 
     
    6360 
    6461                                $start = $limit * $page - $limit; 
    65  
    6662                                // do not put $limit*($page - 1) 
    6763                                //end: for grid 
    68  
     64                                 
     65                                 
     66                                /** 
     67                                 * Trata o caso específico de retorno do atributo messageId 
     68                                 * 
     69                                 * TODO - refazer todo a operação find do conceito message, uma vez que esta  
     70                                 * foi desenvolvida quando a nova API ainda era muito imatura e se encontra  
     71                                 * muito acoplada à estrutura de retorno esperada pelo plugin jqGrid 
     72                                 */ 
     73                                if ( $justthese )  
     74                                { 
     75                                        if ($justthese[0] == 'messageId') { 
     76                                                $map = array( 
     77                                                        'folderName' => array(), 
     78                                                        'messageNumber' => array() 
     79                                                ); 
     80                                                 
     81                                                self::parseFilter($criteria["filter"], &$map); 
     82                                                 
     83                                                if (count($map['folderName']) == 0) { 
     84                                                        $folders = $this->get_folders_list(); 
     85                                                        foreach ($folders as $folder) 
     86                                                                if (isset($folder['folder_id']))  
     87                                                                        $map['folderName'][] = $folder['folder_id']; 
     88                                                } 
     89                                                 
     90                                                $result = array(); 
     91                                                foreach ($map['folderName'] as $folder) { 
     92                                                        $this->mbox = $this->open_mbox($folder); 
     93 
     94                                                        /** 
     95                                                         * Se não foi passado messageNumber no filtro,  
     96                                                         * busca todas as mensagens de cada pasta 
     97                                                         */ 
     98                                                        $messages = empty($map['messageNumber']) ? '1:*' : implode(',', $map['messageNumber']); 
     99                                                        $sequenceType = empty($map['messageNumber']) ? 0 : FT_UID; 
     100 
     101                                                        $headers = imap_fetch_overview($this->mbox, $messages, $sequenceType); 
     102                                                        foreach ($headers as $h) { 
     103                                                                $result[] = array ( 'messageId' => $h->message_id ); 
     104                                                        } 
     105                                                                                                                 
     106                                                        imap_close($this->mbox); 
     107                                                        $this->mbox = false; 
     108                                                } 
     109                                                return $result; 
     110                                        } 
     111                                } 
     112                                 
    69113                                if( $filter ) 
    70114                                { 
     
    94138 
    95139                                        foreach( $result as $i => $val ) 
    96                                                 $result[$i] = unserialize( $val ); 
     140                                        $result[$i] = unserialize( $val ); 
     141 
    97142                                } 
    98143                                else 
     
    110155                                } 
    111156                                //return var_export($result); 
    112                                  
     157 
    113158                                $response = array( "page" => $page, "total" => $total_pages, "records" => $count ); 
    114                                                                  
     159                                 
    115160                                for ($i=0; $i<count($result); $i++) 
    116161                                { 
    117                                         $flags_enum = array('Unseen'=> 1,  'Answered'=> 1, 'Forwarded'=> 1, 'Flagged'=> 1, 'Recent'=> 1, 'Draft'=> 1 ); 
     162                                        $flags_enum = array('Recent', 'Unseen',  'Answered',  'Draft',  'Deleted', 'Flagged'); 
    118163 
    119164                                        foreach ($flags_enum as $key => $flag) 
    120165                                        { 
    121                                                 if ( !isset($result[$i][$key]) || !trim($result[$i][$key]) || trim($result[$i][$key]) == '')  
    122                                                         $flags_enum[$key] = 0; 
    123                                                         //unset($flags_enum[$key]); 
     166                                                if ( !isset($result[$i][$flag]) || !trim($result[$i][$flag]) || trim($result[$i][$flag]) == '')  
     167                                                        unset($flags_enum[$key]); 
    124168 
    125169                                                unset($result[$i][$flag]); 
    126                                         }                                        
     170                                        } 
     171 
    127172                                        if (array_key_exists($i, $result)) 
    128173                                        { 
     
    131176                                                $response["rows"][$i]['flags'] = implode(',', $flags_enum); 
    132177                                                $response["rows"][$i]['size'] = $response["rows"][$i]['Size']; 
    133                                                 $response["rows"][$i]['folder'] = $folder_name; 
    134                                                  
    135178                                                //$response["rows"][$i]['udate'] = ( $result[$i]['udate'] + $this->functions->CalculateDateOffset()  * 1000 ); 
    136179                                                unset($response["rows"][$i]['Size']); 
    137180                                        } 
    138                                  }                                        
     181                                 } 
     182 
    139183                                return $this->to_utf8($response); 
    140184                        } 
     
    214258                         
    215259                        case 'followupflagged': 
    216                         { 
    217                          
     260                        {                        
    218261                                $result = array ( ); 
    219                                 if (isset($criteria["filter"]) && is_array($criteria['filter'])) { 
    220                                         //TODO - melhorar o tratamento do filter com a lista de todos os labelIds dado pelo interceptor 
    221                                         $map = array( 
    222                                                 'id' => array(), 
    223                                                 'folderName' => array(), 
    224                                                 'messageNumber' => array() 
    225                                         ); 
    226                                          
    227                                         self::parseFilter($criteria["filter"], &$map); 
    228                                          
    229                                         if (empty($map['folderName'])) { 
    230                                                 $folders = $this->get_folders_list(); 
    231                                                 foreach ($folders as $folder) 
    232                                                         if (isset($folder['folder_id']))  
    233                                                                 $map['folderName'][] = $folder['folder_id']; 
    234                                         } 
    235  
    236                                         foreach ($map['folderName'] as $folder) { 
    237                                                 $this->mbox = $this->open_mbox($folder); 
    238                                                  
    239                                                 /** 
    240                                                  * Caso não tenha sido passado id no filtro 
    241                                                  */ 
    242                                                 if (!$map['id']) { 
    243                                                         $messagesFlaggeds = imap_search($this->mbox, 'UNDELETED KEYWORD "$Followupflagged"', SE_UID); 
    244  
    245                                                         foreach ($messagesFlaggeds as $messageFlagged) { 
    246                                                                 if (count($map['messageNumber']) > 0 && !in_array($messageFlagged, $map['messageNumber'])) 
    247                                                                         continue; 
    248                                                                          
    249                                                                 $result[] = array ( 
    250                                                                         'folderName' => $folder, 
    251                                                                         'messageNumber' => $messageFlagged 
    252                                                                 ); 
    253                                                         } 
    254                                                          
    255                                                 } else { 
    256                                                         foreach ($map['id'] as $followupflagged) { 
    257                                                                 $messagesFlaggeds = imap_search($this->mbox, 'UNDELETED KEYWORD "$Followupflag'.$followupflagged.'"', SE_UID); 
    258                                                                  
    259                                                                 foreach ($messagesFlaggeds as $messageFlagged) { 
    260                                                                         if (count($map['messageNumber']) > 0 && !in_array($messageFlagged, $map['messageNumber'])) 
    261                                                                                 continue; 
    262                                                                                  
    263                                                                         $result[] = array ( 
    264                                                                                 'id' => $folder . '/' . $messageFlagged . '#' . $followupflagged,  
    265                                                                                 'folderName' => $folder, 
    266                                                                                 'messageNumber' => $messageFlagged 
    267                                                                         ); 
    268                                                                 } 
     262 
     263                                $map = array( 
     264                                        //'id' => array(), 
     265                                        'folderName' => array(), 
     266                                        'messageNumber' => array(), 
     267                                        'messageId' => array() 
     268                                ); 
     269                                 
     270                                self::parseFilter($criteria["filter"], &$map); 
     271         
     272                                if (empty($map['folderName'])) { 
     273                                        $folders = $this->get_folders_list(); 
     274                                        foreach ($folders as $folder) 
     275                                                if (isset($folder['folder_id']))  
     276                                                        $map['folderName'][] = $folder['folder_id']; 
     277                                } 
     278                                 
     279                                $messagesIds = $map['messageId']; 
     280 
     281                                foreach ($map['folderName'] as $folder) { 
     282                                        $messages = array(); 
     283                                         
     284                                        $this->mbox = $this->open_mbox($folder); 
     285                                 
     286                                        /** 
     287                                         * Se é uma busca por messageId 
     288                                         */ 
     289                                        if (!empty($map['messageId'])) { 
     290                                                         
     291                                                foreach ($messagesIds as $k => $v) { 
     292                                                        $r = imap_search($this->mbox, 'UNDELETED KEYWORD "$Followupflagged" TEXT "'.$v.'"', SE_UID); 
     293 
     294                                                        if ($r) { 
     295                                                                $messages = $messages + $r; 
     296                                                                unset($messagesIds[$k]);         
    269297                                                        } 
    270298                                                } 
    271                                                  
    272                                                 imap_close($this->mbox); 
    273                                                 $this->mbox = false; 
    274                                         } 
    275                                 } 
    276                                                  
    277                                 return $result;                          
    278                         } 
     299 
     300                                        /** 
     301                                         * Se é uma busca por messageNumber. 
     302                                         * Lembrando que, neste caso, só deve ser suportada uma única pasta no filtro. 
     303                                         */ 
     304                                        } else { 
     305                                                $messages = imap_search($this->mbox, 'UNDELETED KEYWORD "$Followupflagged"', SE_UID); 
     306                                        } 
     307 
     308                                        /** 
     309                                         * Se é uma busca por messageId, deve ser comparado com os messageNumbers  
     310                                         * passados no filtro, se houverem. 
     311                                         */ 
     312                                        if (!empty($map['messageNumber'])) { 
     313                                                foreach ($messages as $k => $m) 
     314                                                        if (!in_array($m, $map['messageNumber'])) 
     315                                                                unset($messages[$k]); 
     316                                        } 
     317 
     318                                        /** 
     319                                         * Adicionar demais atributos às mensagens para retorno 
     320                                         */ 
     321                                        foreach ($messages as $k => $m) { 
     322                                                $headers = imap_fetch_overview($this->mbox, $m, FT_UID); 
     323                                                         
     324                                                $result[] = array ( 
     325                                                        'messageId' => $headers[0]->message_id, 
     326                                                        'messageNumber' => $m, 
     327                                                        'folderName' => $folder 
     328                                                ); 
     329                                        } 
     330 
     331                                        imap_close($this->mbox); 
     332                                        $this->mbox = false; 
     333                                         
     334                                        /** 
     335                                         * Se é uma busca por messageId e todos os messageIds foram econstrados: 
     336                                         * Stop searching in all folders 
     337                                         */ 
     338                                        if (!empty($map['messageId']) && empty($messagesIds)) 
     339                                                break; 
     340                                } 
     341                                 
     342                                if ($this->mbox) { 
     343                                        imap_close($this->mbox); 
     344                                        $this->mbox = false; 
     345                                } 
     346 
     347                                return $result; 
     348                                 
     349                        } //CASE 'followupflag' 
    279350                } 
    280351    } 
     
    324395                        case 'followupflagged': 
    325396                        { 
    326                                 /** 
    327                                  * id looks like 'folder/subfolder/subsubfolder/65#13', meaning messageId#followupflaggedId 
     397                         
     398                                /**  
     399                                 * identifica se o formato de ID é "folder/subfolder/subsubfolder/<messageNumber>" ou "<message-id>" 
    328400                                 */ 
    329                                 list($messageId, $followupflaggedId) = explode('#', $URI['id']); 
    330                                 $folderName = dirname($messageId); 
    331                                 $messageNumber = basename($messageId); 
    332                                  
     401                                $folderName = $messageNumber = false; 
     402                                if(!($messageHasId = preg_match('/<.*>/', $URI['id']))) { 
     403                                        $folderName = dirname($URI['id']); 
     404                                        $messageNumber = basename($URI['id']); 
     405                                } 
     406 
    333407                                $result = array(); 
    334  
    335                                 if ($folderName && $messageNumber && $followupflaggedId) { 
     408                                if ($folderName && $messageNumber) { 
     409 
    336410                                        $this->mbox = $this->open_mbox($folderName); 
    337                                         $messagesFlaggeds = imap_search($this->mbox, 'UNDELETED KEYWORD "$Followupflag'.$followupflaggedId.'"', SE_UID); 
    338                                          
    339                                         if (in_array($messageNumber, $messagesFlaggeds)) { 
     411                                        $r = imap_search($this->mbox, 'UNDELETED KEYWORD "$Followupflagged"', SE_UID); 
     412 
     413                                        if (in_array($messageNumber, $r)) { 
     414                                                $headers = imap_fetch_overview($this->mbox, $messageNumber, FT_UID); 
     415                                                         
    340416                                                $result = array ( 
    341                                                         'id' => $URI['id'],  
    342                                                         'folderName' => $folderName, 
    343                                                         'messageNumber' => $messageNumber 
     417                                                        'messageId' => $headers[0]->message_id, 
     418                                                        'messageNumber' => $messageNumber, 
     419                                                        'folderName' => $folderName 
    344420                                                ); 
    345421                                        } 
     422                                         
    346423                                        imap_close($this->mbox); 
    347424                                        $this->mbox = false; 
     425                                 
     426                                } else { 
     427                                        /** 
     428                                         * Busca pela mensagem com o messageId dado. Se uma pasta foi passada, busca nela, 
     429                                         * senão busca em todas. 
     430                                         */ 
     431                                         
     432                                        $folders = array (); 
     433                                        if ($folderName) { 
     434                                                $folders = array ($folderName); 
     435                                        } else { 
     436                                                $folder_list = $this->get_folders_list(); 
     437                                                foreach ($folder_list as $folder) 
     438                                                        if (isset($folder['folder_id']))  
     439                                                                $folders[] = $folder['folder_id']; 
     440                                        } 
     441                                         
     442                                        foreach ($folders as $folder) { 
     443                                                 
     444                                                $this->mbox = $this->open_mbox($folder); 
     445                                                 
     446                                                if ($messages = imap_search($this->mbox, 'UNDELETED KEYWORD "$Followupflagged" TEXT "'.$URI['id'].'"', SE_UID)) { 
     447                                 
     448                                                        $result = array ( 
     449                                                                'messageId' => $URI['id'], 
     450                                                                'messageNumber' => $messages[0], 
     451                                                                'folderName' => $folder 
     452                                                        ); 
     453                                                         
     454                                                        /** 
     455                                                         * Stop searching in all folders 
     456                                                         */ 
     457                                                        break; 
     458                                                } 
     459                                                 
     460                                                imap_close($this->mbox); 
     461                                                $this->mbox = false; 
     462                                        } 
     463                                } 
     464                                 
     465                                if ($this->mbox) { 
     466                                        imap_close($this->mbox); 
     467                                        $this->mbox = false; 
    348468                                } 
    349469                                 
     
    353473    } 
    354474 
    355     public function create( $URI, $data) 
     475    public function create($URI, &$data) 
    356476    {                
    357477                switch( $URI['concept'] ) 
     
    372492                        case 'followupflagged': 
    373493                        { 
    374                                 //deve ser gravado no banco primeiro, obtido o id e, depois, gravado no imap passando o id no parametro $data 
    375                                 if (isset($data['folderName']) && isset($data['messageNumber']) && isset($data['id'])) { 
    376                                         list($messageId, $followupflaggedId) = explode('#', $data['id']); 
     494                                //deve ser gravado primeiro no imap, obtido o message-id e, depois gravado no banco 
     495                                 
     496                                if (isset($data['folderName']) && isset($data['messageNumber'])) { 
    377497                                         
    378498                                        $this->mbox = $this->open_mbox($data['folderName']); 
    379                                         $s = imap_setflag_full($this->mbox, $data['messageNumber'], '$Followupflagged $Followupflag' . $followupflaggedId, ST_UID); 
    380                                                                                  
     499                                        $s = imap_setflag_full($this->mbox, $data['messageNumber'], '$Followupflagged', ST_UID); 
     500                                         
     501                                        $headers = imap_fetch_overview($this->mbox, $data['messageNumber'], FT_UID); 
     502                                         
     503                                        $data['messageId'] = $headers[0]->message_id; 
     504                                                         
    381505                                        imap_close($this->mbox); 
    382506                                        $this->mbox = false; 
     
    384508                                        return ($s) ? $data : array(); 
    385509 
     510                                } else if (isset($data['messageId'])) { 
     511                                        /** 
     512                                         * Busca pela mensagem com o messageId dado. Se uma pasta foi passada, busca nela, 
     513                                         * senão busca em todas. 
     514                                         */ 
     515                                        $folders = array (); 
     516                                        if (isset($data['folderName'])) { 
     517                                                $folders = array ($data['folderName']); 
     518                                        } else { 
     519                                                $folder_list = $this->get_folders_list(); 
     520                                                foreach ($folder_list as $folder) 
     521                                                        if (isset($folder['folder_id']))  
     522                                                                $folders[] = $folder['folder_id']; 
     523                                        } 
     524                                         
     525                                        foreach ($folders as $folder) { 
     526                                                 
     527                                                $this->mbox = $this->open_mbox($folder); 
     528                                                if ($messages = imap_search($this->mbox, 'TEXT "'.$data['messageId'].'"', SE_UID)) { 
     529                                                         
     530                                                        $s = imap_setflag_full($this->mbox, $messages[0], '$Followupflagged', ST_UID); 
     531                                                         
     532                                                        imap_close($this->mbox); 
     533                                                        $this->mbox = false; 
     534                                                         
     535                                                        /** 
     536                                                         * Stop searching in all folders 
     537                                                         */ 
     538                                                        return $data; 
     539                                                } 
     540                                                 
     541                                                imap_close($this->mbox); 
     542                                                $this->mbox = false; 
     543                                        } 
    386544                                } 
    387545                                return array (); 
     
    390548                        case 'message': 
    391549                        { 
     550                                require_once ROOTPATH.'/library/uuid/class.uuid.php'; 
     551                                 
    392552                                $GLOBALS['phpgw_info']['flags'] = array( 'noheader' => true, 'nonavbar' => true,'currentapp' => 'expressoMail1_2','enable_nextmatchs_class' => True ); 
    393                                 $return = array(); 
    394                                  
    395                                 require_once dirname(__FILE__) . '/../../services/class.servicelocator.php'; 
    396                                 $mailService = ServiceLocator::getService('mail'); 
    397  
    398                                 $msg_uid = $data['msg_id']; 
    399                                 $body = $data['body']; 
    400                                 $body = str_replace("%nbsp;","&nbsp;",$body); 
    401                                 $body = html_entity_decode ( $body, ENT_QUOTES , 'ISO-8859-1' );                                         
    402  
    403                                 $folder = mb_convert_encoding($data['folder'], "UTF7-IMAP","ISO-8859-1, UTF-8"); 
    404                                 $folder = @eregi_replace("INBOX[/.]", "INBOX".$this->imap_delimiter, $folder); 
     553                                $return = array(); 
     554 
     555                                require_once dirname(__FILE__) . '/../../services/class.servicelocator.php'; 
     556                                $mailService = ServiceLocator::getService('mail'); 
     557 
     558                                $msg_uid = $data['msg_id']; 
     559                                $body = $data['body']; 
     560                                $body = str_replace("%nbsp;","&nbsp;",$body); 
     561                                $body = preg_replace("/\n/"," ",$body); 
     562                                $body = preg_replace("/\r/","" ,$body); 
     563                                $body = html_entity_decode ( $body, ENT_QUOTES , 'ISO-8859-1' );                                         
     564 
     565                                $folder = mb_convert_encoding($data['folder'], "UTF7-IMAP","ISO-8859-1, UTF-8"); 
     566                                $folder = @eregi_replace("INBOX[/.]", "INBOX".$this->imap_delimiter, $folder); 
    405567 
    406568                                /** 
    407                                  * Gera e preenche o field Message-Id do header 
    408                                  */ 
     569                                * Gera e preenche o field Message-Id do header 
     570                                */ 
    409571                                $mailService->addHeaderField('Message-Id', UUID::generate( UUID::UUID_RANDOM, UUID::FMT_STRING ) . '@Draft'); 
    410                                                                  
    411                                 $mailService->addTo(mb_convert_encoding(($data['input_to']), 'ISO-8859-1', 'UTF-8,ISO-8859-1')); 
    412                                 $mailService->addCc( mb_convert_encoding(($data['input_cc']), 'ISO-8859-1', 'UTF-8,ISO-8859-1')); 
    413                                 $mailService->addBcc(mb_convert_encoding(($data['input_cco']), 'ISO-8859-1', 'UTF-8,ISO-8859-1')); 
    414                                 $mailService->setSubject(mb_convert_encoding(($data['input_subject']), 'ISO-8859-1', 'UTF-8,ISO-8859-1')); 
    415                                  
    416                                 if(isset($data['input_important_message'])) 
    417                                         $mailService->addHeaderField('Importance','High'); 
    418  
    419                                 if(isset($data['input_return_receipt'])) 
    420                                         $mailService->addHeaderField('Disposition-Notification-To', Config::me('mail')); 
    421  
    422                                 $isHTML = ( isset($data['type']) && $data['type'] == 'html' )?  true : false; 
    423                                                                    
    424                                 if (!$body) $body = ' '; 
    425                                  
    426  
    427                                 $mbox_stream = $this->open_mbox($folder); 
    428  
    429                                 $attachment = json_decode($data['attachments'],TRUE); 
    430                                  
    431  
    432                                 foreach ($attachment as &$value)  
    433                                 { 
    434  
    435                                     if((int)$value > 0) //BD attachment 
    436                                     { 
    437                                          $att = Controller::read(array('id'=> $value , 'concept' => 'mailAttachment')); 
    438                                           
    439                                           
    440                                          if($att['disposition'] == 'embedded') 
    441                                          { 
    442                                              $body = str_replace('"../prototype/getArchive.php?mailAttachment='.$att['id'].'"', $att['name'], $body); 
    443                                              $mailService->addStringImage(base64_decode($att['source']), $att['type'], $att['name']); 
    444                                          } 
    445                                          else 
    446                                              $mailService->addStringAttachment(base64_decode($att['source']), $att['name'], $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] :'attachment' ); 
    447                                           
    448                                          unset($att); 
    449                                     } 
    450                                     else 
    451                                     { 
    452                                         $value = json_decode($value, true); 
    453                                          
    454                                         switch ($value['type']) { 
    455                                             case 'imapPart': 
    456                                                     $att = $this->getForwardingAttachment($value['folder'],$value['uid'], $value['part']); 
    457                                                     if(strstr($body,'<img src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'" />') !== false)//Embeded IMG 
    458                                                     {     
    459                                                         $body = str_ireplace('<img src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'" />' , '<img src="'.$att['name'].'" />', $body); 
    460                                                         $mailService->addStringImage($att['source'], $att['type'], $att['name']); 
    461                                                     } 
    462                                                     else 
    463                                                         $mailService->addStringAttachment($att['source'], $att['name'], $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] :'attachment' ); 
    464                                                     unset($att); 
    465                                                 break; 
    466                                               case 'imapMSG': 
    467                                                     $sub =  $value['name'] ? $value['name'].'.eml' :'no title.eml'; 
    468                                                     $mbox_stream = $this->open_mbox($value['folder']); 
    469                                                     $rawmsg = $this->getRawHeader($value['uid']) . "\r\n\r\n" . $this->getRawBody($value['uid']); 
    470                                                     $mailService->addStringAttachment($rawmsg, $sub, 'message/rfc822', '7bit', 'attachment' ); 
    471                                                     unset($rawmsg); 
    472                                                 break; 
    473  
    474                                             default: 
    475                                                 break; 
    476                                         } 
    477                                     } 
    478  
    479                                 } 
    480                                  
    481                                 if($isHTML) $mailService->setBodyHtml($body); else $mailService->setBodyText($body); 
    482    
    483                                 if(imap_append($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, $mailService->getMessage(), "\\Seen \\Draft")) 
    484                                 { 
    485                                     $status = imap_status($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, SA_UIDNEXT); 
    486                                     $return['id'] = $status->uidnext - 1; 
    487                                          
    488                                     if($data['uidsSave'] ) 
    489                                         $this->delete_msgs(array('folder'=> $folder , 'msgs_number' => $data['uidsSave'])); 
    490                         
    491                                 } 
    492                   
    493                                 if($mbox_stream) imap_close($mbox_stream); 
    494  
    495                                 return $return; 
     572 
     573                                $mailService->addTo($data['input_to']); 
     574                                $mailService->addCc( $data['input_cc']); 
     575                                $mailService->addBcc($data['input_cco']); 
     576                                $mailService->setSubject($data['input_subject']); 
     577                                if(isset($data['input_important_message'])) 
     578                                        $mailService->addHeaderField('Importance','High'); 
     579 
     580                                if(isset($data['input_return_receipt'])) 
     581                                        $mailService->addHeaderField('Disposition-Notification-To', Config::me('mail')); 
     582 
     583                                $isHTML = ( ( array_key_exists( 'type', $data ) && in_array( strtolower( $data[ 'type' ] ), array( 'html', 'plain' ) ) ) ? strtolower( $data[ 'type' ] ) != 'plain' : true ); 
     584 
     585                                if (!$body) $body = ' '; 
     586 
     587 
     588                                $mbox_stream = $this->open_mbox($folder); 
     589 
     590                                $attachment = json_decode($data['attachments'],TRUE); 
     591 
     592 
     593                                foreach ($attachment as &$value)  
     594                                { 
     595                                        if((int)$value > 0) //BD attachment 
     596                                        { 
     597                                                $att = Controller::read(array('id'=> $value , 'concept' => 'mailAttachment')); 
     598 
     599                                                if($att['disposition'] == 'embedded') 
     600                                                { 
     601                                                        $body = str_replace('"../prototype/getArchive.php?mailAttachment='.$att['id'].'"', $att['name'], $body); 
     602                                                        $mailService->addStringImage(base64_decode($att['source']), $att['type'], $att['name']); 
     603                                                } 
     604                                                else 
     605                                                        $mailService->addStringAttachment(base64_decode($att['source']), $att['name'], $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] :'attachment' ); 
     606 
     607                                                unset($att); 
     608                                        } 
     609                                        else 
     610                                        { 
     611                                                $value = json_decode($value, true); 
     612 
     613                                                switch ($value['type']) { 
     614                                                        case 'imapPart': 
     615                                                                $att = $this->getForwardingAttachment($value['folder'],$value['uid'], $value['part']); 
     616                                                                if(strstr($body,'<img src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'" />') !== false)//Embeded IMG 
     617                                                                {     
     618                                                                        $body = str_ireplace('<img src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'" />' , '<img src="'.$att['name'].'" />', $body); 
     619                                                                        $mailService->addStringImage($att['source'], $att['type'], $att['name']); 
     620                                                                } 
     621                                                                else 
     622                                                                        $mailService->addStringAttachment($att['source'], $att['name'], $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] :'attachment' ); 
     623                                                                unset($att); 
     624                                                                break; 
     625                                                        case 'imapMSG': 
     626                                                                $sub =  $value['name'] ? $value['name'].'.eml' :'no title.eml'; 
     627                                                                $mbox_stream = $this->open_mbox($value['folder']); 
     628                                                                $rawmsg = $this->getRawHeader($value['uid']) . "\r\n\r\n" . $this->getRawBody($value['uid']); 
     629                                                                $mailService->addStringAttachment($rawmsg, $sub, 'message/rfc822', '7bit', 'attachment' ); 
     630                                                                unset($rawmsg); 
     631                                                                break; 
     632 
     633                                                        default: 
     634                                                        break; 
     635                                                } 
     636                                        } 
     637 
     638                                } 
     639 
     640                                if($isHTML) $mailService->setBodyHtml($body); else $mailService->setBodyText($body); 
     641 
     642                                if(imap_append($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, $mailService->getMessage(), "\\Seen \\Draft")) 
     643                                { 
     644                                        $status = imap_status($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, SA_UIDNEXT); 
     645                                        $return['id'] = $status->uidnext - 1; 
     646 
     647                                        if($data['uidsSave'] ) 
     648                                        $this->delete_msgs(array('folder'=> $folder , 'msgs_number' => $data['uidsSave'])); 
     649                                } 
     650 
     651                                if($mbox_stream) imap_close($mbox_stream); 
     652 
     653                                return $return; 
    496654                        } 
    497655                } 
     
    518676                        case 'followupflagged': 
    519677                        { 
    520                                 list($messageId, $followupflaggedId) = explode('#', $URI['id']); 
    521                                  
    522                                 $folderName = dirname($messageId); 
    523                                 $messageNumber = basename($messageId); 
    524678                         
    525                                 if ($folderName && $messageNumber && $followupflaggedId) { 
     679                                /**  
     680                                 * identifica se o formato de ID é "folder/subfolder/subsubfolder/<messageNumber>" ou "<message-id>" 
     681                                 */ 
     682                                $folderName = $messageNumber = false; 
     683                                if(!($messageHasId = preg_match('/<.*>/', $URI['id']))) { 
     684                                        $folderName = dirname($URI['id']); 
     685                                        $messageNumber = basename($URI['id']); 
     686                                } 
     687                                 
     688                                /** 
     689                                 * TODO - efetuar o parsing do $criteria e obter a pasta passada 
     690                                 */ 
     691                                $map = array( 
     692                                        'folderName' => array(), 
     693                                        'messageNumber' => array(), 
     694                                        'messageId' => array() 
     695                                ); 
     696                         
     697                                if ($folderName && $messageNumber) { 
    526698 
    527699                                        $this->mbox = $this->open_mbox($folderName); 
    528                                         $f1 = imap_clearflag_full($this->mbox, $messageNumber, '$Followupflag' . $followupflaggedId, ST_UID); 
    529  
    530                                         /** 
    531                                          * implementa a possibilidade de listar todas as mensagens sinalizadas através da busca 
    532                                          */ 
    533                                         $f2 = imap_clearflag_full($this->mbox, $messageNumber, '$Followupflagged', ST_UID); 
     700                                        $s = imap_clearflag_full($this->mbox, $messageNumber, '$Followupflagged', ST_UID); 
    534701 
    535702                                        imap_close($this->mbox, CL_EXPUNGE); 
    536703                                        $this->mbox = false; 
    537704                                         
    538                                         return ($f1 && $f2); 
     705                                        return $s; 
     706                                } else { 
     707                                        /** 
     708                                         * Busca pela mensagem com o messageId dado. Se uma pasta foi passada, busca nela, 
     709                                         * senão busca em todas. 
     710                                         */ 
     711                                         
     712                                        $folders = array (); 
     713                                        if (isset($map['folderName'])) { 
     714                                                $folders = $map['folderName']; 
     715                                        } else { 
     716                                                $folder_list = $this->get_folders_list(); 
     717                                                foreach ($folder_list as $folder) 
     718                                                        if (isset($folder['folder_id']))  
     719                                                                $folders[] = $folder['folder_id']; 
     720                                        } 
     721                                         
     722                                        foreach ($folders as $folder) { 
     723                                                 
     724                                                $this->mbox = $this->open_mbox($folder); 
     725                                                if ($messages = imap_search($this->mbox, 'TEXT "'.$URI['id'].'"', SE_UID)) { 
     726                                                         
     727                                                        $s = imap_clearflag_full($this->mbox, $messages[0], '$Followupflagged', ST_UID); 
     728                                                         
     729                                                        imap_close($this->mbox, CL_EXPUNGE); 
     730                                                        $this->mbox = false; 
     731                                                         
     732                                                        /** 
     733                                                         * Stop searching in all folders 
     734                                                         */ 
     735                                                        return $s; 
     736                                                } 
     737                                                 
     738                                                imap_close($this->mbox); 
     739                                                $this->mbox = false; 
     740                                        } 
    539741                                } 
    540742                                 
     
    552754    { 
    553755                /** 
    554                  * Os únicos atributos que podem ser alterados no IMAP são folderName e messageId, 
     756                 * Os únicos atributos da sinalização presentes no IMAP são folderName, messageNumber e messageId, 
    555757                 * porém a operação de update desses atributos não faz sentido para o usuário da DataLayer, 
    556758                 * pois na prática elas são executadas através das operações de CREATE e DELETE. 
Note: See TracChangeset for help on using the changeset viewer.