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