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]);
13 $this->data = $msg;
14 }
15 }
17 function check()
18 {
19 return(array());
20 }
22 function sieve_reject($data,$object_id,$parent)
23 {
24 $this->object_id = $object_id;
25 $this->parent = $parent;
26 $this->parent->add_require("reject");
28 /* If the given data is emtpy
29 * (This is the case when we add new elements in the ui)
30 * Set a default text.
31 */
32 if($data == NULL){
33 $this->data = _("Your reject text here");
34 }else{
36 for($i = 0 ; $i < count($data['ELEMENTS']) ; $i++){
37 $tmp = sieve_get_strings($data['ELEMENTS'],$i);
38 $i = $i + $tmp['OFFSET'];
39 foreach($tmp['STRINGS'] as $str){
40 $this->data .= $str;
41 }
42 }
43 }
44 }
46 function get_sieve_script_part()
47 {
48 return("reject ".sieve_create_strings($this->data).";");
49 }
51 function execute()
52 {
53 /* check if this will be a
54 * - single string ""
55 * - or a multi line text: ... ;
56 */
57 $Multiline = preg_match("/\n/",$this->data);
59 $smarty = get_smarty();
60 $smarty->assign("ID", $this->object_id);
61 $smarty->assign("Message",$this->data);
62 $smarty->assign("Multiline",$Multiline);
63 $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
64 $object= $smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__)));
65 $str = preg_replace("/%%OBJECT_CONTENT%%/",addcslashes($object,"\\"),$object_container);
66 return($str);
67 }
68 }
69 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
70 ?>