- Timestamp:
- 04/02/12 17:58:17 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/filters/interceptors/FilterMapping.php
r5747 r5862 50 50 * @license http://www.gnu.org/copyleft/gpl.html GPL 51 51 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 52 * @author Airton Bordin Junior 53 * @author Gustavo Pereira dos Santos 52 * @author Airton Bordin Junior <airton@prognus.com.br> 53 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 54 54 * @version 1.0 55 55 * @since Classe disponibilizada na versão 2.4 … … 67 67 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 68 68 * @sponsor Caixa EconÃŽmica Federal 69 * @author Airton Bordin Junior 70 * @author Gustavo Pereira dos Santos 69 * @author Airton Bordin Junior <airton@prognus.com.br> 70 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 71 71 * @param <Array> <$rules> <Array com as regras do usuário> 72 72 * @return <Regra de acordo com a sintaxe do Sieve> … … 109 109 $data['isExact'] == 'false' ? $script_match .= 'if anyof (' : $script_match .= 'if allof ('; 110 110 111 112 111 if( is_array($criteria) ) 113 112 foreach ($criteria as $j => $value); 114 113 { 115 114 116 115 switch($criteria[$j]['field']) { 117 116 case 'To': … … 174 173 /* 175 174 TO-DO: 176 Arrrumarregra do "não contém".175 Inconsistência na regra do "não contém". 177 176 */ 178 177 case '!*': … … 232 231 $i++; 233 232 $script_match = ""; 234 $script_criteria = ""; 235 233 $script_criteria = ""; 234 $data['applyMessages'] = ""; 236 235 } 237 236 … … 258 257 259 258 $content = $script_begin . $script_header . $script_rules . "\r\n\r\n#PseudoScript#" . "\r\n#" . $json_data; 260 //$content = "";261 259 262 260 return( $content ); … … 269 267 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 270 268 * @sponsor Caixa EconÃŽmica Federal 271 * @author Airton Bordin Junior 272 * @author Gustavo Pereira dos Santos 269 * @author Airton Bordin Junior <airton@prognus.com.br> 270 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 273 271 * @param <$scriptName> <Regras do usuário> 274 272 * @return <Regra do usuário parseada> … … 285 283 286 284 // Recebe o tamanho do script, pela primeira linha; 287 $this->size = trim($size_rule);285 //$this->size = trim($size_rule); 288 286 289 287 // Verifica a composição do script; */ 290 288 $line = array_shift($lines); 291 289 292 290 // Variaveis para a regra e o campo ferias; 293 $regexps = array(' ^ *##PSEUDO', '^ *#rule', '^ *#vacation', '^ *#mode');291 $regexps = array('##PSEUDO', '#rule', '#vacation', '#mode'); 294 292 $retorno['rule'] = array(); 295 293 296 294 $line = array_shift($lines); 297 while (isset($line)) { 295 while (isset($line)) { 298 296 foreach ($regexps as $regp) { 299 if (preg_match("/$regp/i", $line)) { 297 if (preg_match("/$regp/i", $line)) { 300 298 // Recebe todas as regras criadas no servidor; 301 if (preg_match("/ ^ *#rule&&/i", $line)) {302 $retorno['rule'][] = $line . "\n";299 if (preg_match("/#rule&&/i", $line)) { 300 $retorno['rule'][] = ltrim($line) . "\n"; 303 301 } 304 302 } … … 319 317 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 320 318 * @sponsor Caixa EconÃŽmica Federal 321 * @author Airton Bordin Junior 322 * @author Gustavo Pereira dos Santos 319 * @author Airton Bordin Junior <airton@prognus.com.br> 320 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 323 321 * @param <String> <$script> <Script Sieve com as regras do usuário> 324 322 * @return <Regras do usuário em Array> … … 327 325 public function parseSieveScript( $script ) 328 326 { 329 /* 327 /* Faz a verificação por filtros criados com a funcionalidade antiga */ 330 328 $old_rule = strripos($script, "##PSEUDO script start"); 331 329 332 330 if($old_rule) { 333 334 $parsed_rule = $this->readOldScript($old_script); 335 $array_rule = explode("&&", $parsed_rule['rule'][0]); 336 337 $old_retorno = array(); 338 $old_retorno['isExact'] = false; 339 $old_retorno['name'] = $array_rule[1]; 340 $old_retorno['criteria'] = array(); 341 $old_retorno['criteria'][0] = array(); 342 $old_retorno['criteria'][0]['value'] = $array_rule[5]; 343 $old_retorno['criteria'][0]['operator'] = '='; 344 $old_retorno['criteria'][0]['field'] = 'subject'; 345 $old_retorno['actions'] = array(); 346 $old_retorno['actions'][0] = array(); 347 $old_retorno['actions'][0]['parameter'] = $array_rule[7]; 348 $old_retorno['actions'][0]['type'] = $array_rule[6]; 349 $old_retorno['enabled'] = true; 350 $old_retorno['id'] = $array_rule[1]; 351 $old_retorno['applyMessages'] = ''; 352 353 return $old_retorno; 331 $parsed_rule = $this->readOldScript($script); 332 $old_rules = array(); 333 $j = 0; 334 foreach ($parsed_rule['rule'] as $i => $value) { 335 336 $array_rule = explode("&&", $parsed_rule['rule'][$i]); 337 338 /* TO-DO: Ver as actions possÃveis além de reject e fileinto */ 339 switch($array_rule[6]) { 340 case 'reject': 341 $action_type = 'reject'; 342 $action_parameter = $array_rule[7]; 343 break; 344 case 'folder': 345 $action_type = 'fileinto'; 346 $action_parameter = $array_rule[7]; 347 break; 348 } 349 350 if($array_rule[3] != "") { 351 $criteria_value = $array_rule[3]; 352 $criteria_operator = '='; 353 $criteria_field = 'from'; 354 } 355 else 356 { 357 $criteria_value = $array_rule[5]; 358 $criteria_operator = '='; 359 $criteria_field = 'subject'; 360 } 361 362 $old_retorno = array(); 363 $old_retorno['isExact'] = true; 364 $old_retorno['name'] = 'regra_migrada_' . $array_rule[1]; 365 $old_retorno['criteria'] = array(); 366 $old_retorno['criteria'][0] = array(); 367 $old_retorno['criteria'][0]['value'] = $criteria_value; 368 $old_retorno['criteria'][0]['operator'] = $criteria_operator; 369 $old_retorno['criteria'][0]['field'] = $criteria_field; 370 $old_retorno['actions'] = array(); 371 $old_retorno['actions'][0] = array(); 372 $old_retorno['actions'][0]['parameter'] = $action_parameter; 373 $old_retorno['actions'][0]['type'] = $action_type; 374 $old_retorno['enabled'] = ($array_rule[2] == 'ENABLED') ? true: false; 375 $old_retorno['id'] = 'regra_migrada_' . $array_rule[1]; 376 $old_retorno['applyMessages'] = ''; 377 378 $old_rules[$j] = $old_retorno; 379 $j++; 380 } 381 return $old_rules; 354 382 } 355 */383 /* Não tem regra antiga */ 356 384 $pos = strripos($script, "#PseudoScript#"); 357 385 $pseudo_script = substr( $script, $pos+17 ); 358 386 359 387 $return = json_decode( $pseudo_script, true ); 360 388 361 389 return $return; 362 390 } … … 370 398 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 371 399 * @sponsor Caixa EconÃŽmica Federal 372 * @author Airton Bordin Junior 373 * @author Gustavo Pereira dos Santos 400 * @author Airton Bordin Junior <airton@prognus.com.br> 401 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 374 402 * @access <public> 375 403 */ … … 386 414 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 387 415 * @sponsor Caixa EconÃŽmica Federal 388 * @author Airton Bordin Junior 389 * @author Gustavo Pereira dos Santos 416 * @author Airton Bordin Junior <airton@prognus.com.br> 417 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 390 418 * @return <Regras do usuário> 391 419 * @access <public> … … 398 426 $this->rules = array(); 399 427 } 428 400 429 return( $this->rules ); 401 430 } … … 408 437 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 409 438 * @sponsor Caixa EconÃŽmica Federal 410 * @author Airton Bordin Junior 411 * @author Gustavo Pereira dos Santos 439 * @author Airton Bordin Junior <airton@prognus.com.br> 440 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 412 441 * @param <$uri> 413 442 * @param <$result> … … 418 447 public function applySieveFilter( &$uri , &$result , &$criteria , $original ) 419 448 { 420 /*421 $result['id'] = $uri['id'];422 $rule_apply = array();423 449 424 $filter = Controller::read($uri); 425 $filter_ = $this->parseSieveScript($filter['content']); 426 427 foreach ($filter_ as $f_) { 428 if($f_['id'] == $uri['id']) { 429 $rule_apply = $f_; 450 //if() 451 //{ 452 $result['id'] = $uri['id']; 453 $rule_apply = array(); 454 455 $filter = Controller::read($uri); 456 $filter_ = $this->parseSieveScript($filter['content']); 457 458 foreach ($filter_ as $f_) { 459 if($f_['id'] == $uri['id']) { 460 $rule_apply = $f_; 461 } 430 462 } 431 } 432 433 $actions = array(); 434 $actions['type'] = $rule_apply['actions'][0]['type']; 435 $actions['parameter'] = $rule_apply['actions'][0]['parameter']; 436 437 $messages = $rule_apply['applyMessages']; 438 439 440 $proc = array(); 441 $proc['keep'] = false; 442 */ 443 444 //$imap = Controller::service( 'Imap' ); 445 //$imap->apliSieveFilter($original['properties']['applyMessages'] , $proc ); 446 //$imap->apliSieveFilter($messages , $actions ); 447 //return $result; 463 464 $actions = array(); 465 $actions['type'] = $rule_apply['actions'][0]['type']; 466 $actions['parameter'] = $rule_apply['actions'][0]['parameter']; 467 /* Hardcoded */ 468 $actions['keep'] = false; 469 470 $messages_to_apply = array(); 471 472 $messages = $rule_apply['applyMessages']; 473 /* 474 $proc = array(); 475 $proc['keep'] = false; 476 477 */ 478 $imap = Controller::service( 'Imap' ); 479 $imap->apliSieveFilter($messages , $actions); 480 return $result; 481 //} 448 482 } 449 483 … … 455 489 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 456 490 * @sponsor Caixa EconÃŽmica Federal 457 * @author Airton Bordin Junior 458 * @author Gustavo Pereira dos Santos 491 * @author Airton Bordin Junior <airton@prognus.com.br> 492 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 459 493 * @param <$uri> 460 494 * @param <$result> … … 476 510 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 477 511 * @sponsor Caixa EconÃŽmica Federal 478 * @author Airton Bordin Junior 479 * @author Gustavo Pereira dos Santos 512 * @author Airton Bordin Junior <airton@prognus.com.br> 513 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 480 514 * @param <$uri> 481 515 * @param <$result> … … 510 544 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 511 545 * @sponsor Caixa EconÃŽmica Federal 512 * @author Airton Bordin Junior 513 * @author Gustavo Pereira dos Santos 546 * @author Airton Bordin Junior <airton@prognus.com.br> 547 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 514 548 * @param <$uri> 515 549 * @param <$result> … … 554 588 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 555 589 * @sponsor Caixa EconÃŽmica Federal 556 * @author Airton Bordin Junior 557 * @author Gustavo Pereira dos Santos 590 * @author Airton Bordin Junior <airton@prognus.com.br> 591 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 558 592 * @param <$uri> 559 593 * @param <$result> … … 580 614 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 581 615 * @sponsor Caixa EconÃŽmica Federal 582 * @author Airton Bordin Junior 583 * @author Gustavo Pereira dos Santos 616 * @author Airton Bordin Junior <airton@prognus.com.br> 617 * @author Gustavo Pereira dos Santos <gustavo@prognus.com.br> 584 618 * @param <$uri> 585 619 * @param <$result>
Note: See TracChangeset
for help on using the changeset viewer.