Changeset 5983


Ignore:
Timestamp:
04/20/12 15:26:36 (12 years ago)
Author:
marcieli
Message:

Ticket #2633 - Corrigido bug nos labels, surgiu após melhoria e inserção da coluna slot.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/modules/mail/interceptors/Helpers.php

    r5977 r5983  
    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                  
    8071        public static function in_arrayr($needle, $haystack) { 
    8172                //if(!is_array($haystack)) return false; 
     
    322313        }        
    323314 
     315        //label:before.create  
     316        public function validateLabel(&$uri , &$params , &$criteria , $original){  
     317 
     318                        if( !!Controller::find( array('concept' => 'label'), false, array('filter' => array('i=', 'name', $params['name'])) ) )  
     319                        {  
     320                                throw new Exception('Já existe um marcador com esse nome.');  
     321                        }  
     322 
     323                        $used = Controller::read( array( 'concept' => 'label', 'id' => '1' ), array( 'id' ), array( 'uid' => Config::me('uidNumber') ) ); 
     324 
     325                        if( !isset( $used['id'] ) )  
     326                        {  
     327                                $params['id'] = '1';  
     328                                return;  
     329                        }  
     330 
     331                        $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 );  
     332 
     333                        if( empty( $slot ) )  
     334                        {  
     335                                throw new Exception('Nenhum slot disponivel.');  
     336                        }  
     337 
     338                        $params['id'] = $slot['id'];  
     339        } 
    324340} 
    325341 
Note: See TracChangeset for help on using the changeset viewer.