Changeset 5977


Ignore:
Timestamp:
04/19/12 17:54:45 (12 years ago)
Author:
adriano
Message:

Ticket #2633 - correcao nos interceptors de consistencia para a funcionalidade de sinalizadores

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.imap_functions.inc.php

    r5906 r5977  
    198198                            }  
    199199                                                         
    200                                                         $filter = array('AND', array('=', 'folderName', $folder), array('IN','messageNumber', $sort_array_msg[0])); 
     200                                                        $filter = array('AND', array('=', 'folderName', $folder), array('IN','messageNumber', $sort_array_msg)); 
    201201                                                        $followupflagged = Controller::find( 
    202202                                                                array('concept' => 'followupflagged'), 
  • trunk/prototype/modules/mail/interceptors/Helpers.php

    r5972 r5977  
    6666                        else 
    6767                                $criteria['filter'] =  $filter; 
     68                } 
     69        } 
     70         
     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.'); 
    6877                } 
    6978        } 
     
    127136 
    128137                        $imap_result = Controller::find(  
    129                                 array('concept' => 'followupflagged'),  
     138                                array('concept' => 'message'),  
    130139                                array('messageId'),  
    131140                                array('filter' => $filter) 
    132141                        ); 
    133                          
     142 
    134143                        if($imap_result) { 
    135144                                $params['messageId'] = $imap_result['messageId']; 
     
    139148                $filter = array('=', 'messageId', $params['messageId']); 
    140149                Controller::delete(array('concept' => 'followupflagged', 'service' => 'PostgreSQL'), null, $filter); 
     150 
    141151        } 
    142152         
     
    232242                $imap_uri = $uri; 
    233243                $imap_uri['service'] = 'Imap'; 
    234                 $imap_result = Controller::find($imap_uri, false, $original['criteria']); 
     244                $imap_criteria = $original['criteria']; 
     245                 
     246                if (self::in_arrayr('alarmDeadline', $original['criteria']) || self::in_arrayr('doneDeadline', $original['criteria'])) { 
     247                        if (empty($result)) return $reult; 
     248                         
     249                        $idList = array(); 
     250                        foreach($result as $r) { 
     251                                $idList[] = $r['messageId']; 
     252                        } 
     253                         
     254                        $imap_criteria['filter'] = array('IN', 'messageId', $idList); 
     255                } 
     256                $imap_result = Controller::find($imap_uri, false, $imap_criteria); 
    235257 
    236258                /** 
     
    241263                 
    242264                        foreach($result as $k => $r) { 
     265                         
    243266                                if ($r['messageId'] == $ir['messageId']) { 
    244267                                        $merge_result[] = $r + $ir; 
     268                                         
    245269                                        unset($result[$k]); 
     270                                        unset($imap_result[$j]); 
     271                                         
    246272                                        break; 
    247273                                } 
    248274                        } 
    249                          
    250                         unset($imap_result[$j]); 
    251275                } 
    252276                 
     
    272296                                $n['backgroundColor'] = '#FF2016'; 
    273297                                $n['id'] = Controller::create(array('concept' => 'followupflagged'), $n); 
    274                                 $merge_result[] = $ir + $n; 
    275                         } 
    276                 } 
    277                          
     298                                $merge_result[] = $n; 
     299                        } 
     300                } 
     301 
    278302                return $merge_result; 
    279303        } 
     
    298322        }        
    299323 
    300         //label:before.create 
    301         public function validateLabel(&$uri , &$params , &$criteria , $original){ 
    302  
    303                 if( !!Controller::find( array('concept' => 'label'), false, array('filter' => array('i=', 'name', $params['name'])) ) ) 
    304                 { 
    305                     throw new Exception('Já existe um marcador com esse nome.'); 
    306                 } 
    307  
    308                 $used = Controller::service('PostgreSQL')->execSql( 'SELECT count(slot) as used from expressomail_label where user_id = '.Config::me('uidNumber'), true ); 
    309  
    310                 if( $used['used'] === '0' ) 
    311                 { 
    312                     $params['id'] = '1'; 
    313                     return; 
    314                 } 
    315  
    316                 $slot = Controller::service('PostgreSQL')->execSql( 'SELECT label.slot + 1 as id FROM expressomail_label as label, phpgw_config as config WHERE label.user_id = '.Config::me('uidNumber').' AND config.config_name = \'expressoMail_limit_labels\' AND label.slot <= config.config_value::integer AND ( SELECT count(slot) FROM expressomail_label WHERE slot = label.slot + 1 AND user_id = '.Config::me('uidNumber').' ) = 0 limit 1', true ); 
    317  
    318                 if( empty( $slot ) ) 
    319                 { 
    320                     throw new Exception('Nenhum slot disponivel.'); 
    321                 } 
    322  
    323                 $params['id'] = $slot['id']; 
    324         } 
    325324} 
    326325 
Note: See TracChangeset for help on using the changeset viewer.