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

Revision 6348, 21.1 KB checked in by airton, 12 years ago (diff)

Ticket #2815 - Inconsistencia com filtros de mensagens com anexos

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                $require_fileinto = $require_flag = $require_reject = $require_vacation = $require_body = $require_imapflag = $vacation = $startswith = $endswith = false;
96
97                $script_rules = $script_header = $script_criteria = $vacation_action = "";
98
99                $i = 0;
100               
101                foreach( $rules as $name => $data )
102                {       
103                        if( $data['enabled'] == 'false' )
104                                continue;
105                               
106                        if(array_key_exists("block", $data)) {
107                                /* Usado na opção Bloquear usuário do ExpressoMail */
108                                if($data['block']) {
109                                        ($i >0) ? $script_match = 'elsif anyof' : $script_match = 'if anyof';
110                                        $script_match = $script_match . "(address :is \"from\" [\"" .$data['name'] . "\"]) {\r\n"; 
111                                        $script_match .= "fileinto \"INBOX/Spam\"; \r\n}\r\n";
112                                        $script_rules .= $script_match;
113                                        $script_match = "";
114                                        $script_criteria = "";
115                                        $require_fileinto = true;
116                                        $i++;
117                                        continue;
118                                }
119                        }
120                               
121                        $vacation = false;
122                        $criteria = $data['criteria'];
123                        $action   = $data['actions'];
124                       
125                        ($i >0) ? $script_match = 'els' : $script_match = '';
126                        $data['isExact'] == 'false' ?  $script_match .= 'if anyof (' : $script_match .= 'if allof (';
127
128                        if( is_array($criteria) )
129                        foreach ($criteria as $j => $value)
130                        {                                       
131                               
132                                switch($criteria[$j]['field']) {
133                                        case 'To':   
134                                        case 'to':   
135                                        case 'CC':
136                                        case 'Cc':
137                                                $criteria[$j]['field'] = "[\"To\", \"TO\", \"Cc\", \"CC\"]";
138                                                $script_criteria .= "address :";
139                                                break;
140                                        case 'from':
141                                                $criteria[$j]['field'] = "\"" . $criteria[$j]['field'] . "\"";
142                                                $script_criteria .= "address :";
143                                                break;
144                                        case 'size':   
145                                                $criteria[$j]['field'] = '';
146                                                $script_criteria .= "size :";
147                                                break;
148                                        case 'subject':
149                                                $criteria[$j]['field'] = "\"" . $criteria[$j]['field'] . "\"";
150                                                $criteria[$j]['value'] = "" . imap_8bit($criteria[$j]['value']) . "*\", \"" . base64_encode($criteria[$j]['value']) . "";
151                                                $criteria[$j]['operator'] = "^";  //temporary
152                                                $script_criteria .= "header :";
153                                                break;
154                                        case 'body':
155                                                $criteria[$j]['field'] = '';
156                                                $script_criteria .= "body :";
157                                                $require_body = true;
158                                                break;
159                                        case 'vacation':
160                                                continue;
161                                        case 'hasAttachment':
162                                                $criteria[$j]['field'] = '';
163                                                $script_criteria .= "body :";
164                                                $criteria[$j]['operator'] = "^^";
165                                                $require_body = true;
166                                                break;
167                                        default:
168                                                $script_criteria .= "header :";
169                                                break;
170                                }
171                               
172                                switch ($criteria[$j]['operator']) {
173                                        case '>':
174                                                $criteria[$j]['operator'] = "over";
175                                                $criteria[$j]['value'] = $criteria[$j]['value'] . "K";
176                                                break;
177                                        case '<':
178                                                $criteria[$j]['operator'] = "under";
179                                                $criteria[$j]['value'] = $criteria[$j]['value'] . "K";
180                                                break;
181                                        case '=':
182                                                $criteria[$j]['operator'] = "is";
183                                                $criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "\"]";
184                                                break;
185                                        case '*':
186                                                $criteria[$j]['operator'] = "contains";
187                                                $criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "\"]";
188                                                break;                                         
189                                        case '^':
190                                                $criteria[$j]['operator'] = "matches";
191                                                $criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "*\"]";
192                                                $startswith = true;
193                                                break;
194                                        case '^^':
195                                                $criteria[$j]['operator'] = "raw :matches";
196                                                $criteria[$j]['value'] = "[\"*filename=*\"]";
197                                                $startswith = true;
198                                                break;
199                                        case '$':
200                                                $criteria[$j]['operator'] = "matches";
201                                                $criteria[$j]['value'] = "[\"*" . $criteria[$j]['value'] . "\"]";
202                                                $endswith = true;
203                                                break;
204                                        /*
205                                           TO-DO:
206                                           Inconsistência na regra do "não contém".
207                                        */
208                                        case '!*':
209                                                $criteria[$j]['operator'] = "contains";
210                                                $criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "\"]";
211                                                break;
212                                }
213                               
214                                if ($criteria[$j]['field'] == "" || $criteria[$j]['field'] == "\"subject\"" || $startswith || $endswith)
215                                {
216                                        $script_criteria .= $criteria[$j]['operator'] . " " . $criteria[$j]['field'] . " " . $criteria[$j]['value'] . ", ";
217                                        $startswith = $endswith = false;
218                                }
219                                else
220                                        $script_criteria .= $criteria[$j]['operator'] . " " . $criteria[$j]['field'] . " " . $criteria[$j]['value'] . ", ";
221                        }
222                        $script_criteria = substr($script_criteria,0,-2);
223                        /* if ($vacation == false) */
224                        $script_criteria .= ")";
225
226                        $script_action = " {\r\n ";
227                       
228                        if( is_array($action) )
229                        foreach ($action as $k => $value)
230                        {
231                                switch ($action[$k]['type']) {
232                                        case 'redirect':
233                                                break;
234                                        case 'reject':
235                                                $require_reject = true;
236                                                break;
237                                        case 'fileinto':
238                                                $require_fileinto = true;
239                                                $action[$k]['parameter'] = imap_utf7_encode($action[$k]['parameter']);
240                                                break;
241                                        case 'vacation':
242                                                $require_vacation = true;
243                                                $action[$k]['parameter'] = "\"" . $action[$k]['parameter'] . "\"";
244                                                $vacation_action = ' :subject "Fora do Escrit&oacuterio" ' . $action[$k]['parameter'] . ";";
245                                                $vacation = true;
246                                                continue;
247                                        case 'setflag':
248                                                $require_flag = true;
249                                                $action[$k]['parameter'] = "\\\\" . $action[$k]['parameter'];
250                                                break;
251                                        case 'discard':
252                                                break;
253                                }
254                                if ($vacation == false) $script_action .= $action[$k]['type'] . " \"" . $action[$k]['parameter'] . "\";\r\n ";
255                        }
256                        $script_action .= "}";
257                       
258                        if($vacation == false)
259                                $script_rules .= $script_match . $script_criteria . $script_action . "\r\n";
260
261                        if($data['id'] != "vacation")
262                                $i++;
263                        $script_match = "";
264                        $script_criteria = ""; 
265                        $data['applyMessages'] = "";                                                   
266                }
267
268                if($require_reject || $require_fileinto || $require_vacation || $require_body || $require_flag)
269                {
270                        /* Para habilitar as funções desejadas, edite a diretiva sieve_extensions no arquivo de configuração "/etc/imapd.conf" */
271                        $script_header .= "require [";
272                        $require_reject ? $script_header .= "\"reject\", " : "";
273                        $require_fileinto ? $script_header .= "\"fileinto\", " : "";
274                        $require_vacation? $script_header .= "\"vacation\", " : ""; 
275                        $require_flag ? $script_header .= "\"imapflags\", " : ""; 
276                        $require_body ? $script_header .= "\"body\", " : ""; 
277                        $script_header = substr($script_header,0,-2);
278                        $script_header .= "];\r\n";
279                }
280
281                if( $vacation_action )
282                {
283                  $script_rules .= "vacation" . $vacation_action . "\r\n";
284                }
285
286                $json_data = json_encode($rules);
287               
288                $script_begin = "#Filtro gerado por Expresso Livre\r\n\r\n";
289
290                $content = $script_begin . $script_header . $script_rules . "\r\n\r\n#PseudoScript#" . "\r\n#" . $json_data;
291               
292                return( $content );
293        }
294       
295        /**
296        * Método que lê e faz o parser dos filtros antigos
297        *
298        * @license    http://www.gnu.org/copyleft/gpl.html GPL
299        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
300        * @sponsor    Caixa Econômica Federal
301        * @author     Airton Bordin Junior <airton@prognus.com.br>
302        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
303        * @param      <$scriptName> <Regras do usuário>
304        * @return     <Regra do usuário parseada>
305        * @access     <public>
306        */
307        public function readOldScript($scriptName)
308        {
309        // Recebe o conteúdo do array;
310        $lines = array();
311        $lines = preg_split("/\n/", $scriptName);
312
313        // Pega o tamanho da regra na primeira do script;
314        $size_rule = array_shift($lines);
315
316        // Recebe o tamanho do script, pela primeira linha;
317        //$this->size = trim($size_rule);
318
319        // Verifica a composição do script; */
320        $line = array_shift($lines);
321
322        // Variaveis para a regra e o campo ferias;
323        $regexps = array('##PSEUDO', '#rule', '#vacation', '#mode');
324        $retorno['rule'] = array();
325
326        $line = array_shift($lines);
327        while (isset($line)) {
328            foreach ($regexps as $regp) {
329                if (preg_match("/$regp/i", $line)) {
330                    // Recebe todas as regras criadas no servidor;
331                    if (preg_match("/#rule&&/i", $line)) {
332                        $retorno['rule'][] = ltrim($line) . "\n";                         
333                    }
334                }
335            }
336            // Pega a proxima linha do sript;
337            $line = array_shift($lines);
338        }
339        return $retorno;
340    }
341       
342       
343       
344       
345        /**
346        * Método que faz o parsing do Script Sieve, transformando em Array.
347        *
348        * @license    http://www.gnu.org/copyleft/gpl.html GPL
349        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
350        * @sponsor    Caixa Econômica Federal
351        * @author     Airton Bordin Junior <airton@prognus.com.br>
352        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
353        * @param      <String> <$script> <Script Sieve com as regras do usuário>
354        * @return     <Regras do usuário em Array>
355        * @access     <public>
356        */
357        public function parseSieveScript( $script )
358        {
359                 $old_rule = strripos($script, "##PSEUDO script start");
360               
361                if($old_rule) {
362                        $parsed_rule = $this->readOldScript($script);
363                        $old_rules = array();
364                        $j = 0;
365                        foreach ($parsed_rule['rule'] as $i => $value) {
366                               
367                                $array_rule = explode("&&", $parsed_rule['rule'][$i]);
368
369                                /* TO-DO: Ver as actions possíveis além de reject e fileinto */
370                                switch($array_rule[6]) {
371                                        case 'reject':
372                                                $action_type      = 'reject';
373                                                $action_parameter = $array_rule[7];
374                                                break;
375                                        case 'folder':
376                                                $action_type      = 'fileinto';
377                                                $action_parameter = $array_rule[7];
378                                                break;
379                                }
380
381                                if($array_rule[3] != "") {
382                                        $criteria_value = $array_rule[3];
383                                        $criteria_operator = '=';
384                                        $criteria_field = 'from';
385                                }
386                                else
387                                {
388                                        $criteria_value = $array_rule[5];
389                                        $criteria_operator = '=';
390                                        $criteria_field = 'subject';
391                                }
392
393                                $old_retorno = array();
394                                $old_retorno['isExact']                                 = true;
395                                $old_retorno['name']                                    = 'regra_migrada_' . $array_rule[1];
396                                $old_retorno['criteria']                                = array();
397                                $old_retorno['criteria'][0]                     = array();
398                                $old_retorno['criteria'][0]['value']    = $criteria_value;
399                                $old_retorno['criteria'][0]['operator'] = $criteria_operator;
400                                $old_retorno['criteria'][0]['field']    = $criteria_field;
401                                $old_retorno['actions']                 = array();
402                                $old_retorno['actions'][0]              = array();
403                                $old_retorno['actions'][0]['parameter'] = $action_parameter;
404                                $old_retorno['actions'][0]['type']      = $action_type;
405                                $old_retorno['enabled']                 = ($array_rule[2] == 'ENABLED') ? true: false;
406                                $old_retorno['id']                      = 'regra_migrada_' . $array_rule[1];
407                                $old_retorno['applyMessages']           = '';
408
409                                $old_rules[$j] = $old_retorno;
410                                $j++;
411                        }                       
412                        return $old_rules;
413                }
414                /* Não tem regra antiga */
415                $pos = strripos($script, "#PseudoScript#");
416                $pseudo_script = substr( $script, $pos+17 );
417
418                $return = json_decode( $pseudo_script, true );
419       
420                return $return;
421        }
422
423        var $rules = false;
424
425        /**
426        * Construtor da classe.
427        *
428        * @license    http://www.gnu.org/copyleft/gpl.html GPL
429        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
430        * @sponsor    Caixa Econômica Federal
431        * @author     Airton Bordin Junior <airton@prognus.com.br>
432        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
433        * @access     <public>
434        */
435        public function __construct()
436        {
437                $this->service = Controller::service("Sieve");
438        }
439
440       
441        /**
442        * Método que recupera as regras do usuário.
443        *
444        * @license    http://www.gnu.org/copyleft/gpl.html GPL
445        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
446        * @sponsor    Caixa Econômica Federal
447        * @author     Airton Bordin Junior <airton@prognus.com.br>
448        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
449        * @return     <Regras do usuário>
450        * @access     <public>
451        */
452        public function getRules()
453        {
454                $this->rules = Controller::find( array( 'concept' => 'filter' ) );
455
456                if( !$this->rules ) {
457                        $this->rules = array();
458                }
459               
460                return( $this->rules );
461        }
462
463       
464        /**
465        * Método que aplica o filtro para as mensagens do usuário.
466        *
467        * @license    http://www.gnu.org/copyleft/gpl.html GPL
468        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
469        * @sponsor    Caixa Econômica Federal
470        * @author     Airton Bordin Junior <airton@prognus.com.br>
471        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
472        * @param      <$uri>
473        * @param      <$result>
474        * @param      <$criteria>
475        * @param      <$original>
476        * @access     <public>
477        */
478        public function applySieveFilter( &$uri , &$result , &$criteria , $original  )
479        {
480               
481                //if()                 
482                //{                                             
483                        $rule_apply = array();
484                       
485                        $filter = Controller::read($uri);
486                        $filter_ = $this->parseSieveScript($filter['content']);
487                       
488                        foreach ($filter_ as $f_) {
489                                if($f_['id'] == $uri['id']) {
490                                        $rule_apply     = $f_;
491                                }
492                        }
493                                       
494                        $actions = array();
495                        $actions['type']      = $rule_apply['actions'][0]['type'];
496                        $actions['parameter'] = $rule_apply['actions'][0]['parameter'];
497                        /* Hardcoded */
498                        $actions['keep']      = false;
499
500                        $messages_to_apply = array();                   
501
502                        $messages = $rule_apply['applyMessages'];
503                        /*       
504                        $proc = array();
505                        $proc['keep'] = false;
506                                 
507                        */
508                        $imap = Controller::service( 'Imap' );
509                        $imap->apliSieveFilter($messages, $actions);
510                        return $result;
511                //}
512        }
513
514       
515        /**
516        * Método que lê o script do usuário.
517        *
518        * @license    http://www.gnu.org/copyleft/gpl.html GPL
519        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
520        * @sponsor    Caixa Econômica Federal
521        * @author     Airton Bordin Junior <airton@prognus.com.br>
522        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
523        * @param      <$uri>
524        * @param      <$result>
525        * @param      <$criteria>
526        * @param      <$original>
527        * @return     <Script do usuário>
528        * @access     <public>
529        */
530        public function readUserScript( &$uri , &$params , &$criteria , $original )
531        { 
532                $uri['id'] = $this->service->config['user'];
533        }
534 
535 
536        /**
537        * Método que seta o script do usuário.
538        *
539        * @license    http://www.gnu.org/copyleft/gpl.html GPL
540        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
541        * @sponsor    Caixa Econômica Federal
542        * @author     Airton Bordin Junior <airton@prognus.com.br>
543        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
544        * @param      <$uri>
545        * @param      <$result>
546        * @param      <$criteria>
547        * @param      <$original>
548        * @return     <Script do usuário>
549        * @access     <public>
550        */
551        public function setRule( &$uri , &$params , &$criteria , $original  )
552        {
553                if( !$this->rules )
554                $this->rules = $this->getRules();
555
556            $uri['id'] = $params['id'] = isset($params['id']) ? $params['id'] : urlencode($params['name']);
557
558            $i = 0;
559
560            for( ; isset($this->rules[$i]) && $this->rules[$i]['id'] !== $params['id']; $i++ );
561
562            $this->rules[$i] = array_merge( ( isset($this->rules[$i]) ? $this->rules[$i] : array() ), $params );
563
564            $params = array( 'name' => $this->service->config['user'],
565                             'content' => $this->formatSieveScript( $this->rules ),
566                             'active' => true );
567        }
568
569       
570        /**
571        * Método que deleta o script do usuário.
572        *
573        * @license    http://www.gnu.org/copyleft/gpl.html GPL
574        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
575        * @sponsor    Caixa Econômica Federal
576        * @author     Airton Bordin Junior <airton@prognus.com.br>
577        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
578        * @param      <$uri>
579        * @param      <$result>
580        * @param      <$criteria>
581        * @param      <$original>
582        * @access     <public>
583        */
584        public function deleteRule( &$uri, &$params, &$criteria, $original )
585        {
586                if( !$this->rules ) {   
587                        $this->rules = $this->getRules();
588                }         
589                $params['id'] = $uri['id'];
590
591                $update = false;
592               
593                $rules = array();
594
595                foreach( $this->rules as $i => $rule )
596                        if( $rule['id'] !== $uri['id'] )
597                                $rules[] = $this->rules[$i];
598
599                $this->rules = $rules;
600               
601                $uri['id'] = '';
602
603                $params = array( 'name' => $this->service->config['user'],
604                           'content' => $this->formatSieveScript( $this->rules ),
605                           'active' => true );
606
607                $URI = Controller::URI( $uri['concept'], $this->service->config['user'] );
608                $this->service->update( $URI, $params );
609       
610                return( false );
611        }
612
613       
614        /**
615        * Método que pega o script do usuário.
616        *
617        * @license    http://www.gnu.org/copyleft/gpl.html GPL
618        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
619        * @sponsor    Caixa Econômica Federal
620        * @author     Airton Bordin Junior <airton@prognus.com.br>
621        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
622        * @param      <$uri>
623        * @param      <$result>
624        * @param      <$criteria>
625        * @param      <$original>
626        * @return     <Script do usuário>
627        * @access     <public>
628        */
629        public function getSieveRule( &$uri , &$params , &$criteria , $original )
630        {         
631                $script = $this->parseSieveScript( $params['content'] );
632
633                foreach( $script as $i => $rule )
634                        if(is_array ($rule['name']) && is_array($original['id']))
635                        if( $rule['name'] === $original['id'] )
636                                return( $params = $rule );
637        }
638
639       
640        /**
641        * Método que lista as regras do usuário.
642        *
643        * @license    http://www.gnu.org/copyleft/gpl.html GPL
644        * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
645        * @sponsor    Caixa Econômica Federal
646        * @author     Airton Bordin Junior <airton@prognus.com.br>
647        * @author         Gustavo Pereira dos Santos <gustavo@prognus.com.br>   
648        * @param      <$uri>
649        * @param      <$result>
650        * @param      <$criteria>
651        * @param      <$original>
652        * @return     <Regras do usuário>
653        * @access     <public>
654        */
655        public function listSieveRules( &$uri , &$params , &$criteria , $original  )
656        {
657                $return = $params = $this->parseSieveScript( $params[0]['content'] );
658                return( $return );
659        }
660}
Note: See TracBrowser for help on using the repository browser.