1 <?php
3 class sieve_reject
4 {
5 var $data = array();
6 var $object_id = -1;
9 function save_object()
10 {
11 if(isset($_POST['reject_message_'.$this->object_id])){
12 $msg = stripslashes($_POST['reject_message_'.$this->object_id]);
14 $this->data = $msg;
15 }
16 }
18 function check()
19 {
20 return(array());
21 }
23 function sieve_reject($data,$object_id)
24 {
25 $this->object_id = $object_id;
26 $str = "";
27 foreach($data['ELEMENTS'] as $node ){
28 if(in_array($node['class'],array("quoted-string","text","multi-line"))){
30 if($node['class'] == "multi-line"){
31 $str .= preg_replace("/^text:[ \n\r]*/","",$node['text']);
32 $str = preg_replace("/[ \n\r]*\.[ \n\r]*$/","",$str);
33 }else{
34 $str .= $node['text'];
35 }
36 }
37 }
38 $this->data = preg_replace("/\"/","",$str);
39 }
41 function get_sieve_script_part()
42 {
43 return("reject ".sieve_create_strings($this->data).";\n");
44 }
46 function execute()
47 {
48 /* check if this will be a
49 * - single string ""
50 * - or a multi line text: ... ;
51 */
52 $Multiline = preg_match("/\n/",$this->data);
54 $smarty = get_smarty();
55 $smarty->assign("ID", $this->object_id);
56 $smarty->assign("Message",$this->data);
57 $smarty->assign("Multiline",$Multiline);
58 $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
59 $object= $smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__)));
60 $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
61 return($str);
62 }
63 }