1 <?php
3 class sieve_reject
4 {
5 var $data = "";
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;
27 /* If the given data is emtpy
28 * (This is the case when we add new elements in the ui)
29 * Set a default text.
30 */
31 if($data == NULL){
32 $this->data = _("Your reject text here");
33 }else{
35 /* Get reject text */
36 $str = "";
37 foreach($data['ELEMENTS'] as $node ){
38 if(in_array($node['class'],array("quoted-string","text","multi-line"))){
40 if($node['class'] == "multi-line"){
41 $str .= preg_replace("/^text:[ \n\r]*/","",$node['text']);
42 $str = preg_replace("/[ \n\r]*\.[ \n\r]*$/","",$str);
43 }else{
44 $str .= $node['text'];
45 }
46 }
47 }
48 $this->data = preg_replace("/\"/","",$str);
49 }
50 }
52 function get_sieve_script_part()
53 {
54 return("reject ".sieve_create_strings($this->data).";\n");
55 }
57 function execute()
58 {
59 /* check if this will be a
60 * - single string ""
61 * - or a multi line text: ... ;
62 */
63 $Multiline = preg_match("/\n/",$this->data);
65 $smarty = get_smarty();
66 $smarty->assign("ID", $this->object_id);
67 $smarty->assign("Message",$this->data);
68 $smarty->assign("Multiline",$Multiline);
69 $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
70 $object= $smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__)));
71 $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
72 return($str);
73 }
74 }
75 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
76 ?>