1 <?php
2 class sieve_redirect
3 {
4 var $data = array();
5 var $object_id = -1;
6 var $LastError ="";
8 function save_object()
9 {
10 if(isset($_POST['redirect_to_'.$this->object_id])){
11 $rt = stripslashes($_POST['redirect_to_'.$this->object_id]);
13 $rt = "\"".trim(preg_replace("/\"/","",$rt))."\"";
14 $this->data = $rt;
15 }
16 }
19 function check()
20 {
21 $msgs = array();
23 if(!is_email(preg_replace("/\"/","",$this->data))){
24 $msgs[] =_("Please specify a valid email address.");
25 }
27 return($msgs);
28 }
30 function sieve_redirect($data,$object_id)
31 {
32 $this->object_id = $object_id;
34 if($data == NULL){
35 $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => _("Put a mail address here"))));
36 }
38 foreach($data['ELEMENTS'] as $node ){
39 if(in_array($node['class'],array("quoted-string","text"))){
40 $this->data = $node['text'];
41 }
42 }
43 }
46 function get_sieve_script_part()
47 {
48 return("redirect ".sieve_create_strings($this->data).";\n");
49 }
52 function execute()
53 {
54 $values = $this->data;
56 $smarty = get_smarty();
57 $smarty->assign("ID", $this->object_id);
58 $smarty->assign("Destinations" , $values);
59 $smarty->assign("LastError" , $this->check());
60 $smarty->assign("LastErrorCnt" , count($this->check()));
61 $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
62 $object= $smarty->fetch(get_template_path("templates/element_redirect.tpl",TRUE,dirname(__FILE__)));
63 $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
64 return($str);
65 }
66 }
67 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
68 ?>