Code

Put each class in a single file.
[gosa.git] / include / sieve / class_sieveElement_Reject.inc
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 sieve_reject($data,$object_id)
19   {
20     $this->object_id = $object_id;
21     $str = "";
22     foreach($data['ELEMENTS'] as $node ){
23       if(in_array($node['class'],array("quoted-string","text","multi-line"))){
25         if($node['class'] == "multi-line"){
26           $str .= preg_replace("/^text:[ \n\r]*/","",$node['text']);
27           $str =  preg_replace("/[  \n\r]*\.[  \n\r]*$/","",$str);
28         }else{
29           $str .= $node['text'];
30         }
31       }
32     }
33     $this->data = preg_replace("/\"/","",$str);
34   }
36   function get_sieve_script_part()
37   {
38     return("reject ".sieve_create_strings($this->data).";\n");
39   } 
40     
41   function execute()
42   {
43     /* check if this will be a 
44      *   - single string ""
45      *   - or a multi line text: ... ; 
46      */
47     $Multiline = preg_match("/\n/",$this->data);
49     $smarty = get_smarty();
50     $smarty->assign("ID", $this->object_id);
51     $smarty->assign("Message",$this->data);
52     $smarty->assign("Multiline",$Multiline);
53     $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
54     $object= $smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__)));
55     $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
56     return($str);
57   }
58 }