1 <?php
2 class sieve_redirect
3 {
4 var $data = "";
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($rt);
14 $this->data = $rt;
15 }
16 }
19 function check()
20 {
21 $msgs = array();
23 if(!is_email($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" => _("Place a mail address here"))));
36 }
38 for($i = 0 ; $i < count($data['ELEMENTS']) ; $i++){
39 $tmp = sieve_get_strings($data['ELEMENTS'],$i);
40 $i = $i + $tmp['OFFSET'];
41 foreach($tmp['STRINGS'] as $str){
42 $this->data .= $str;
43 }
44 }
45 }
48 function get_sieve_script_part()
49 {
50 return("redirect ".sieve_create_strings($this->data).";");
51 }
54 function execute()
55 {
56 $values = htmlentities($this->data);
57 $smarty = get_smarty();
58 $smarty->assign("ID", $this->object_id);
59 $smarty->assign("Destinations" , $values);
60 $smarty->assign("LastError" , $this->check());
61 $smarty->assign("LastErrorCnt" , count($this->check()));
62 $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
63 $object= $smarty->fetch(get_template_path("templates/element_redirect.tpl",TRUE,dirname(__FILE__)));
64 $str = preg_replace("/%%OBJECT_CONTENT%%/",addcslashes($object,"\\"),$object_container);
65 return($str);
66 }
67 }
68 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
69 ?>