source: trunk/prototype/modules/filters/interceptors/FilterMapping.php @ 6028

Revision 6028, 20.8 KB checked in by airton, 12 years ago (diff)

Ticket #2655 - Inconsistencia em filtros com a opcao armazenar na pasta

Line 
1<?php
2/**
3*
4* Copyright (C) 2011 Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
5*
6* This program is free software; you can redistribute it and/or modify it under
7* the terms of the GNU Affero General Public License version 3 as published by
8* the Free Software Foundation with the addition of the following permission
9* added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
10* WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
11* WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
12*
13* This program is distributed in the hope that it will be useful, but WITHOUT
14* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15* FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
16* details.
17*
18* You should have received a copy of the GNU Affero General Public License
19* along with this program; if not, see www.gnu.org/licenses or write to
20* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21* MA 02110-1301 USA.
22*
23* This code is based on the OpenXchange Connector and on the Prognus pSync
24* Connector both developed by the community and licensed under the GPL
25* version 2 or above as published by the Free Software Foundation.
26*
27* You can contact Prognus Software Livre headquarters at Av. Tancredo Neves,
28* 6731, PTI, Bl. 05, Esp. 02, Sl. 10, Foz do Iguaçu - PR - Brasil or at
29* e-mail address prognus@prognus.com.br.
30*
31* Descrição rápida do arquivo
32*
33* Arquivo responsável pela manipulação dos filtros
34*
35* @package    filters
36* @license    http://www.gnu.org/copyleft/gpl.html GPL
37* @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
38* @version    1.0
39* @sponsor    Caixa EconÃŽmica Federal
40* @since      Arquivo disponibilizado na versão 2.4
41*/
42
43
44
45/**
46* Classe responsável pela manipulação dos filtros.
47*
48*
49* @package    prototype
50* @license    http://www.gnu.org/copyleft/gpl.html GPL
51* @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
52* @author     Airton Bordin Junior <airton@prognus.com.br>
53* @author     Gustavo Pereira dos Santos <gustavo@prognus.com.br>
54* @version    1.0
55* @since      Classe disponibilizada na versão 2.4
56*/
57class FilterMapping
58{
59        var $service;
60       
61        /**
62        * Método que cria o ID da regra que está sendo criada.
63        *
64        * @license    http://www.gnu.org/copyleft/gpl.html GPL
65        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
66        * @sponsor    Caixa EconÃŽmica Federal
67        * @author     Airton Bordin Junior <airton@prognus.com.br>
68        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
69        * @author         Natan Fonseca <natan@prognus.com.br> 
70        * @param      <$uri>
71        * @param      <$result>
72        * @param      <$criteria>
73        * @param      <$original>
74        * @access     <public>
75        */
76        public function makeId(&$uri , &$result , &$criteria , $original) {
77                $result['id'] = $uri['id'];
78        }
79       
80       
81        /**
82        * Método que formata o Script de acordo com a sintaxe do Sieve.
83        *
84        * @license    http://www.gnu.org/copyleft/gpl.html GPL
85        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
86        * @sponsor    Caixa EconÃŽmica Federal
87        * @author     Airton Bordin Junior <airton@prognus.com.br>
88        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
89        * @param      <Array> <$rules> <Array com as regras do usuário>
90        * @return     <Regra de acordo com a sintaxe do Sieve>
91        * @access     <public>
92        */
93        public function formatSieveScript( $rules )
94    {
95       
96                $require_fileinto = $require_flag = $require_reject = $require_vacation = $require_body = $require_imapflag = $vacation = $startswith = $endswith = false;
97
98                $script_rules = $script_header = $script_criteria = $vacation_action = "";
99
100                $i = 0;
101               
102                foreach( $rules as $name => $data )
103                {       
104                        if( $data['enabled'] == 'false' )
105                                continue;
106                               
107                        if(array_key_exists("block", $data)) {
108                                /* Usado na opção Bloquear usuário do ExpressoMail */
109                                if($data['block']) {
110                                        ($i >0) ? $script_match = 'elsif anyof' : $script_match = 'if anyof';
111                                        $script_match = $script_match . "(address :is \"from\" [\"" .$data['name'] . "\"]) {\r\n"; 
112                                        $script_match .= "fileinto \"INBOX/Spam\"; \r\n}\r\n";
113                                        $script_rules .= $script_match;
114                                        $script_match = "";
115                                        $script_criteria = "";
116                                        $require_fileinto = true;
117                                        $i++;
118                                        continue;
119                                }
120                        }
121                        //if( $data['enabled'] == 'false' )
122                                //continue;
123                               
124                        $vacation = false;
125                        $criteria = $data['criteria'];
126                        $action   = $data['actions'];
127                       
128                        ($i >0) ? $script_match = 'els' : $script_match = '';
129                        $data['isExact'] == 'false' ?  $script_match .= 'if anyof (' : $script_match .= 'if allof (';
130
131                        if( is_array($criteria) )
132                        foreach ($criteria as $j => $value)
133                        {                                       
134
135                                switch($criteria[$j]['field']) {
136                                        case 'To':   
137                                        case 'to':   
138                                        case 'CC':
139                                        case 'Cc':
140                                                $criteria[$j]['field'] = "[\"To\", \"TO\", \"Cc\", \"CC\"]";
141                                                $script_criteria .= "address :";
142                                                break;
143                                        case 'from':
144                                                $criteria[$j]['field'] = "\"" . $criteria[$j]['field'] . "\"";
145                                                $script_criteria .= "address :";
146                                                break;
147                                        case 'size':   
148                                                $criteria[$j]['field'] = '';
149                                                $script_criteria .= "size :";
150                                                break;
151                                        case 'subject':
152                                                $criteria[$j]['field'] = "\"" . $criteria[$j]['field'] . "\"";
153                                                $criteria[$j]['value'] = "" . imap_8bit($criteria[$j]['value']) . "\", \"" . base64_encode($criteria[$j]['value']) . "";
154                                                $script_criteria .= "header :";
155                                                break;
156                                        case 'body':
157                                                $criteria[$j]['field'] = '';
158                                                $script_criteria .= "body :";
159                                                $require_body = true;
160                                                break;
161                                        case 'vacation':
162                                                continue;
163                                        default:
164                                                $script_criteria .= "header :";
165                                                break;
166                                }
167                               
168                                switch ($criteria[$j]['operator']) {
169                                        case '>':
170                                                $criteria[$j]['operator'] = "over";
171                                                $criteria[$j]['value'] = $criteria[$j]['value'] . "K";
172                                                break;
173                                        case '<':
174                                                $criteria[$j]['operator'] = "under";
175                                                $criteria[$j]['value'] = $criteria[$j]['value'] . "K";
176                                                break;
177                                        case '=':
178                                                $criteria[$j]['operator'] = "is";
179                                                $criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "\"]";
180                                                break;
181                                        case '*':
182                                                $criteria[$j]['operator'] = "contains";
183                                                $criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "\"]";
184                                                break;                                         
185                                        case '^':
186                                                $criteria[$j]['operator'] = "matches";
187                                                $criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "*\"]";
188                                                $startswith = true;
189                                                break;
190                                        case '$':
191                                                $criteria[$j]['operator'] = "matches";
192                                                $criteria[$j]['value'] = "[\"*" . $criteria[$j]['value'] . "\"]";
193                                                $endswith = true;
194                                                break;
195                                        /*
196                                           TO-DO:
197                                           Inconsistência na regra do "não contém".
198                                        */
199                                        case '!*':
200                                                $criteria[$j]['operator'] = "contains";
201                                                $criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "\"]";
202                                                break;
203                                }
204                               
205                                if ($criteria[$j]['field'] == "" || $criteria[$j]['field'] == "\"subject\"" || $startswith || $endswith)
206                                {
207                                        $script_criteria .= $criteria[$j]['operator'] . " " . $criteria[$j]['field'] . " " . $criteria[$j]['value'] . ", ";
208                                        $startswith = $endswith = false;
209                                }
210                                else
211                                        $script_criteria .= $criteria[$j]['operator'] . " " . $criteria[$j]['field'] . " " . $criteria[$j]['value'] . ", ";
212                        }
213                        $script_criteria = substr($script_criteria,0,-2);
214                        /* if ($vacation == false) */
215                        $script_criteria .= ")";
216
217                        $script_action = " {\r\n ";
218                       
219                        if( is_array($action) )
220                        foreach ($action as $k => $value)
221                        {
222                                switch ($action[$k]['type']) {
223                                        case 'redirect':
224                                                break;
225                                        case 'reject':
226                                                $require_reject = true;
227                                                break;
228                                        case 'fileinto':
229                                                $require_fileinto = true;
230                                                $action[$k]['parameter'] = imap_utf7_encode($action[$k]['parameter']);
231                                                break;
232                                        case 'vacation':
233                                                $require_vacation = true;
234                                                $action[$k]['parameter'] = "\"" . $action[$k]['parameter'] . "\"";
235                                                $vacation_action = " :subject \"Fora do Escrit&oacuterio\" " . $action[$k]['parameter'] . ";";
236                                                $vacation = true;
237                                                continue;
238                                        case 'setflag':
239                                                $require_flag = true;
240                                                $action[$k]['parameter'] = "\\\\" . $action[$k]['parameter'];
241                                                break;
242                                        case 'discard':
243                                                break;
244                                }
245                                if ($vacation == false) $script_action .= $action[$k]['type'] . " \"" . $action[$k]['parameter'] . "\";\r\n ";
246                        }
247                        $script_action .= "}";
248                       
249                        if($vacation != true)
250                                $script_rules .= $script_match . $script_criteria . $script_action . "\r\n";
251
252                        if($data['id'] != "vacation")
253                                $i++;
254                        $script_match = "";
255                        $script_criteria = ""; 
256                        $data['applyMessages'] = "";                                                   
257                }
258
259                if($require_reject || $require_fileinto || $require_vacation || $require_body || $require_flag)
260                {
261                        $script_header .= "require [";
262                        $require_reject ? $script_header .= "\"reject\", " : "";
263                        $require_fileinto ? $script_header .= "\"fileinto\", " : "";
264                        $require_vacation? $script_header .= "\"vacation\", " : ""; 
265                        $require_flag ? $script_header .= "\"imapflags\", " : ""; 
266                        $require_body ? $script_header .= "\"body\", " : "";  /* tem que instalar as extensões no Cyrus */
267                        $script_header = substr($script_header,0,-2);
268                        $script_header .= "];\r\n";
269                }
270
271                if( $vacation_action )
272                {
273                  $script_rules .= "vacation" . $vacation_action . "\r\n";
274                }
275
276                $json_data = json_encode($rules);
277               
278                $script_begin = "#Filtro gerado por Expresso Livre versão 2.4\r\n\r\n";
279
280                $content = $script_begin . $script_header . $script_rules . "\r\n\r\n#PseudoScript#" . "\r\n#" . $json_data;
281
282                return( $content );
283        }
284       
285        /**
286        * Método que lê e faz o parser dos filtros antigos
287        *
288        * @license    http://www.gnu.org/copyleft/gpl.html GPL
289        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
290        * @sponsor    Caixa EconÃŽmica Federal
291        * @author     Airton Bordin Junior <airton@prognus.com.br>
292        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
293        * @param      <$scriptName> <Regras do usuário>
294        * @return     <Regra do usuário parseada>
295        * @access     <public>
296        */
297        public function readOldScript($scriptName)
298        {
299        // Recebe o conteúdo do array;
300        $lines = array();
301        $lines = preg_split("/\n/", $scriptName);
302
303        // Pega o tamanho da regra na primeira do script;
304        $size_rule = array_shift($lines);
305
306        // Recebe o tamanho do script, pela primeira linha;
307        //$this->size = trim($size_rule);
308
309        // Verifica a composição do script; */
310        $line = array_shift($lines);
311
312        // Variaveis para a regra e o campo ferias;
313        $regexps = array('##PSEUDO', '#rule', '#vacation', '#mode');
314        $retorno['rule'] = array();
315
316        $line = array_shift($lines);
317        while (isset($line)) {
318            foreach ($regexps as $regp) {
319                if (preg_match("/$regp/i", $line)) {
320                    // Recebe todas as regras criadas no servidor;
321                    if (preg_match("/#rule&&/i", $line)) {
322                        $retorno['rule'][] = ltrim($line) . "\n";                         
323                    }
324                }
325            }
326            // Pega a proxima linha do sript;
327            $line = array_shift($lines);
328        }
329        return $retorno;
330    }
331       
332       
333       
334       
335        /**
336        * Método que faz o parsing do Script Sieve, transformando em Array.
337        *
338        * @license    http://www.gnu.org/copyleft/gpl.html GPL
339        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
340        * @sponsor    Caixa EconÃŽmica Federal
341        * @author     Airton Bordin Junior <airton@prognus.com.br>
342        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
343        * @param      <String> <$script> <Script Sieve com as regras do usuário>
344        * @return     <Regras do usuário em Array>
345        * @access     <public>
346        */
347        public function parseSieveScript( $script )
348        {
349                 $old_rule = strripos($script, "##PSEUDO script start");
350               
351                if($old_rule) {
352                        $parsed_rule = $this->readOldScript($script);
353                        $old_rules = array();
354                        $j = 0;
355                        foreach ($parsed_rule['rule'] as $i => $value) {
356                               
357                                $array_rule = explode("&&", $parsed_rule['rule'][$i]);
358
359                                /* TO-DO: Ver as actions possíveis além de reject e fileinto */
360                                switch($array_rule[6]) {
361                                        case 'reject':
362                                                $action_type      = 'reject';
363                                                $action_parameter = $array_rule[7];
364                                                break;
365                                        case 'folder':
366                                                $action_type      = 'fileinto';
367                                                $action_parameter = $array_rule[7];
368                                                break;
369                                }
370
371                                if($array_rule[3] != "") {
372                                        $criteria_value = $array_rule[3];
373                                        $criteria_operator = '=';
374                                        $criteria_field = 'from';
375                                }
376                                else
377                                {
378                                        $criteria_value = $array_rule[5];
379                                        $criteria_operator = '=';
380                                        $criteria_field = 'subject';
381                                }
382
383                                $old_retorno = array();
384                                $old_retorno['isExact']                                 = true;
385                                $old_retorno['name']                                    = 'regra_migrada_' . $array_rule[1];
386                                $old_retorno['criteria']                                = array();
387                                $old_retorno['criteria'][0]                     = array();
388                                $old_retorno['criteria'][0]['value']    = $criteria_value;
389                                $old_retorno['criteria'][0]['operator'] = $criteria_operator;
390                                $old_retorno['criteria'][0]['field']    = $criteria_field;
391                                $old_retorno['actions']                 = array();
392                                $old_retorno['actions'][0]              = array();
393                                $old_retorno['actions'][0]['parameter'] = $action_parameter;
394                                $old_retorno['actions'][0]['type']      = $action_type;
395                                $old_retorno['enabled']                 = ($array_rule[2] == 'ENABLED') ? true: false;
396                                $old_retorno['id']                      = 'regra_migrada_' . $array_rule[1];
397                                $old_retorno['applyMessages']           = '';
398
399                                $old_rules[$j] = $old_retorno;
400                                $j++;
401                        }                       
402                        return $old_rules;
403                }
404                /* Não tem regra antiga */
405                $pos = strripos($script, "#PseudoScript#");
406                $pseudo_script = substr( $script, $pos+17 );
407
408                $return = json_decode( $pseudo_script, true );
409       
410                return $return;
411        }
412
413        var $rules = false;
414
415        /**
416        * Construtor da classe.
417        *
418        * @license    http://www.gnu.org/copyleft/gpl.html GPL
419        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
420        * @sponsor    Caixa EconÃŽmica Federal
421        * @author     Airton Bordin Junior <airton@prognus.com.br>
422        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
423        * @access     <public>
424        */
425        public function __construct()
426        {
427                $this->service = Controller::service("Sieve");
428        }
429
430       
431        /**
432        * Método que recupera as regras do usuário.
433        *
434        * @license    http://www.gnu.org/copyleft/gpl.html GPL
435        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
436        * @sponsor    Caixa EconÃŽmica Federal
437        * @author     Airton Bordin Junior <airton@prognus.com.br>
438        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
439        * @return     <Regras do usuário>
440        * @access     <public>
441        */
442        public function getRules()
443        {
444                $this->rules = Controller::find( array( 'concept' => 'filter' ) );
445
446                if( !$this->rules ) {
447                        $this->rules = array();
448                }
449               
450                return( $this->rules );
451        }
452
453       
454        /**
455        * Método que aplica o filtro para as mensagens do usuário.
456        *
457        * @license    http://www.gnu.org/copyleft/gpl.html GPL
458        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
459        * @sponsor    Caixa EconÃŽmica Federal
460        * @author     Airton Bordin Junior <airton@prognus.com.br>
461        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
462        * @param      <$uri>
463        * @param      <$result>
464        * @param      <$criteria>
465        * @param      <$original>
466        * @access     <public>
467        */
468        public function applySieveFilter( &$uri , &$result , &$criteria , $original  )
469        {
470               
471                //if()                 
472                //{                                             
473                        $rule_apply = array();
474                       
475                        $filter = Controller::read($uri);
476                        $filter_ = $this->parseSieveScript($filter['content']);
477                       
478                        foreach ($filter_ as $f_) {
479                                if($f_['id'] == $uri['id']) {
480                                        $rule_apply     = $f_;
481                                }
482                        }
483                                       
484                        $actions = array();
485                        $actions['type']      = $rule_apply['actions'][0]['type'];
486                        $actions['parameter'] = $rule_apply['actions'][0]['parameter'];
487                        /* Hardcoded */
488                        $actions['keep']      = false;
489
490                        $messages_to_apply = array();                   
491
492                        $messages = $rule_apply['applyMessages'];
493                        /*       
494                        $proc = array();
495                        $proc['keep'] = false;
496                                 
497                        */
498                        $imap = Controller::service( 'Imap' );
499                        $imap->apliSieveFilter($messages , $actions);
500                        return $result;
501                //}
502        }
503
504       
505        /**
506        * Método que lê o script do usuário.
507        *
508        * @license    http://www.gnu.org/copyleft/gpl.html GPL
509        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
510        * @sponsor    Caixa EconÃŽmica Federal
511        * @author     Airton Bordin Junior <airton@prognus.com.br>
512        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
513        * @param      <$uri>
514        * @param      <$result>
515        * @param      <$criteria>
516        * @param      <$original>
517        * @return     <Script do usuário>
518        * @access     <public>
519        */
520        public function readUserScript( &$uri , &$params , &$criteria , $original )
521        { 
522                $uri['id'] = $this->service->config['user'];
523        }
524 
525 
526        /**
527        * Método que seta o script do usuário.
528        *
529        * @license    http://www.gnu.org/copyleft/gpl.html GPL
530        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
531        * @sponsor    Caixa EconÃŽmica Federal
532        * @author     Airton Bordin Junior <airton@prognus.com.br>
533        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
534        * @param      <$uri>
535        * @param      <$result>
536        * @param      <$criteria>
537        * @param      <$original>
538        * @return     <Script do usuário>
539        * @access     <public>
540        */
541        public function setRule( &$uri , &$params , &$criteria , $original  )
542        {
543                if( !$this->rules )
544                $this->rules = $this->getRules();
545
546            $uri['id'] = $params['id'] = isset($params['id']) ? $params['id'] : urlencode($params['name']);
547
548            $i = 0;
549
550            for( ; isset($this->rules[$i]) && $this->rules[$i]['id'] !== $params['id']; $i++ );
551
552            $this->rules[$i] = array_merge( ( isset($this->rules[$i]) ? $this->rules[$i] : array() ), $params );
553
554            $params = array( 'name' => $this->service->config['user'],
555                             'content' => $this->formatSieveScript( $this->rules ),
556                             'active' => true );
557        }
558
559       
560        /**
561        * Método que deleta o script do usuário.
562        *
563        * @license    http://www.gnu.org/copyleft/gpl.html GPL
564        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
565        * @sponsor    Caixa EconÃŽmica Federal
566        * @author     Airton Bordin Junior <airton@prognus.com.br>
567        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
568        * @param      <$uri>
569        * @param      <$result>
570        * @param      <$criteria>
571        * @param      <$original>
572        * @access     <public>
573        */
574        public function deleteRule( &$uri, &$params, &$criteria, $original )
575        {
576                if( !$this->rules ) {   
577                        $this->rules = $this->getRules();
578                }         
579                $params['id'] = $uri['id'];
580
581                $update = false;
582               
583                $rules = array();
584
585                foreach( $this->rules as $i => $rule )
586                        if( $rule['id'] !== $uri['id'] )
587                                $rules[] = $this->rules[$i];
588
589                $this->rules = $rules;
590               
591                $uri['id'] = '';
592
593                $params = array( 'name' => $this->service->config['user'],
594                           'content' => $this->formatSieveScript( $this->rules ),
595                           'active' => true );
596
597                $URI = Controller::URI( $uri['concept'], $this->service->config['user'] );
598                $this->service->update( $URI, $params );
599       
600                return( false );
601        }
602
603       
604        /**
605        * Método que pega o script do usuário.
606        *
607        * @license    http://www.gnu.org/copyleft/gpl.html GPL
608        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
609        * @sponsor    Caixa EconÃŽmica Federal
610        * @author     Airton Bordin Junior <airton@prognus.com.br>
611        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
612        * @param      <$uri>
613        * @param      <$result>
614        * @param      <$criteria>
615        * @param      <$original>
616        * @return     <Script do usuário>
617        * @access     <public>
618        */
619        public function getSieveRule( &$uri , &$params , &$criteria , $original )
620        {         
621                $script = $this->parseSieveScript( $params['content'] );
622
623                foreach( $script as $i => $rule )
624                        if(is_array ($rule['name']) && is_array($original['id']))
625                        if( $rule['name'] === $original['id'] )
626                                return( $params = $rule );
627        }
628
629       
630        /**
631        * Método que lista as regras do usuário.
632        *
633        * @license    http://www.gnu.org/copyleft/gpl.html GPL
634        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
635        * @sponsor    Caixa EconÃŽmica Federal
636        * @author     Airton Bordin Junior <airton@prognus.com.br>
637        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
638        * @param      <$uri>
639        * @param      <$result>
640        * @param      <$criteria>
641        * @param      <$original>
642        * @return     <Regras do usuário>
643        * @access     <public>
644        */
645        public function listSieveRules( &$uri , &$params , &$criteria , $original  )
646        {
647                $return = $params = $this->parseSieveScript( $params[0]['content'] );
648                return( $return );
649        }
650}
Note: See TracBrowser for help on using the repository browser.