Ignore:
Timestamp:
04/18/12 18:19:41 (12 years ago)
Author:
natan
Message:

Ticket #2633 - Implementação da limitação de numero de marcadores por usuario

File:
1 edited

Legend:

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

    r5970 r5971  
    6868                } 
    6969        } 
    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.'); 
    77                 } 
    78         } 
    7970                 
    8071        public static function in_arrayr($needle, $haystack) { 
     
    249240        }        
    250241 
     242        //label:before.create 
     243        public function validateLabel(&$uri , &$params , &$criteria , $original){ 
     244 
     245                if( !!Controller::find( array('concept' => 'label'), false, array('filter' => array('i=', 'name', $params['name'])) ) ) 
     246                { 
     247                    throw new Exception('Já existe um marcador com esse nome.'); 
     248                } 
     249 
     250                $used = Controller::service('PostgreSQL')->execSql( 'SELECT count(slot) as used from expressomail_label where user_id = '.Config::me('uidNumber'), true ); 
     251 
     252                if( $used['used'] === '0' ) 
     253                { 
     254                    $params['id'] = '1'; 
     255                    return; 
     256                } 
     257 
     258                $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 ); 
     259 
     260                if( empty( $slot ) ) 
     261                { 
     262                    throw new Exception('Nenhum slot disponivel.'); 
     263                } 
     264 
     265                $params['id'] = $slot['id']; 
     266        } 
    251267} 
    252268 
Note: See TracChangeset for help on using the changeset viewer.