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

Revision 6213, 20.8 KB checked in by thiago, 12 years ago (diff)

Ticket #2749 - problemas de interpretação de caracteres especiais.

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