- Timestamp:
- 05/31/12 15:25:39 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/filters/interceptors/FilterMapping.php
r6348 r6363 357 357 public function parseSieveScript( $script ) 358 358 { 359 360 359 $old_rule = strripos($script, "##PSEUDO script start"); 360 /* Tem regra antiga */ 361 361 if($old_rule) { 362 362 $parsed_rule = $this->readOldScript($script); 363 363 $old_rules = array(); 364 $ j= 0;364 $i_return = 0; 365 365 foreach ($parsed_rule['rule'] as $i => $value) { 366 367 366 $array_rule = explode("&&", $parsed_rule['rule'][$i]); 367 368 $action_type = array(); 369 $action_parameter = array(); 370 $criteria_value = array(); 371 $criteria_operator = array(); 372 $criteria_field = array(); 373 374 $i_criteria = 0; 375 $i_action = 0; 368 376 369 377 /* TO-DO: Ver as actions possíveis além de reject e fileinto */ 370 378 switch($array_rule[6]) { 371 379 case 'reject': 372 $action_type = 'reject'; 373 $action_parameter = $array_rule[7]; 380 $action_type[$i_action] = 'reject'; 381 $action_parameter[$i_action] = $array_rule[7]; 382 $i_action++; 374 383 break; 375 384 case 'folder': 376 $action_type = 'fileinto'; 377 $action_parameter = $array_rule[7]; 378 break; 379 } 380 385 $action_type[$i_action] = 'fileinto'; 386 $action_parameter[$i_action] = $array_rule[7]; 387 $i_action++; 388 break; 389 case 'flagged': 390 $action_type[$i_action] = 'setflag'; 391 $action_parameter[$i_action] = 'flagged'; 392 $i_action++; 393 break; 394 case 'address': 395 $action_type[$i_action] = 'redirect'; 396 $action_parameter[$i_action] = $array_rule[7]; 397 $i_action++; 398 break; 399 /* Somente para tratar casos em que a ação não é suportada */ 400 default: 401 $action_type[$i_action] = 'setflag'; 402 $action_parameter[$i_action] = 'flagged'; 403 $i_action++; 404 break; 405 // Recuperar o cyrus_delimiter para forçar um fileinto para INBOX/trash 406 //case 'discard': 407 //$action_type[$i_action] = 'fileinto'; 408 //$action_parameter[$i_action] =; 409 //$i_action++; 410 //break; 411 } 381 412 if($array_rule[3] != "") { 382 $criteria_value = $array_rule[3]; 383 $criteria_operator = '='; 384 $criteria_field = 'from'; 413 $criteria_value[$i_criteria] = $array_rule[3]; 414 $criteria_operator[$i_criteria] = '='; 415 $criteria_field[$i_criteria] = 'from'; 416 $i_criteria++; 385 417 } 386 else 387 { 388 $criteria_value = $array_rule[5]; 389 $criteria_operator = '='; 390 $criteria_field = 'subject'; 391 } 392 418 if($array_rule[4] != "") { 419 $criteria_value[$i_criteria] = $array_rule[4]; 420 $criteria_operator[$i_criteria] = '='; 421 $criteria_field[$i_criteria] = 'to'; 422 $i_criteria++; 423 } 424 if($array_rule[5] != "") { 425 $criteria_value[$i_criteria] = $array_rule[5]; 426 $criteria_operator[$i_criteria] = '='; 427 $criteria_field[$i_criteria] = 'subject'; 428 $i_criteria++; 429 } 393 430 $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++; 431 $old_retorno['isExact'] = true; 432 $old_retorno['name'] = 'regra_migrada_' . $array_rule[1]; 433 434 $old_retorno['criteria'] = array(); 435 foreach($criteria_value as $j => $value) { 436 $old_retorno['criteria'][$j] = array(); 437 $old_retorno['criteria'][$j]['value'] = $criteria_value[$j]; 438 $old_retorno['criteria'][$j]['operator'] = $criteria_operator[$j]; 439 $old_retorno['criteria'][$j]['field'] = $criteria_field[$j]; 440 } 441 442 $old_retorno['actions'] = array(); 443 foreach($action_parameter as $j => $value) { 444 $old_retorno['actions'][$j] = array(); 445 $old_retorno['actions'][$j]['parameter'] = $action_parameter[$j]; 446 $old_retorno['actions'][$j]['type'] = $action_type[$j]; 447 } 448 449 $old_retorno['enabled'] = ($array_rule[2] == 'ENABLED') ? 'true' : 'false'; 450 $old_retorno['id'] = 'Regra_migrada_' . $i_return; 451 $old_retorno['applyMessages'] = ''; 452 453 $old_rules[$i_return] = $old_retorno; 454 $i_return++; 411 455 } 412 456 return $old_rules;
Note: See TracChangeset
for help on using the changeset viewer.