Code

Added some checks
[gosa.git] / include / sieve / class_sieveElement_Fileinto.inc
1 <?php
3 class sieve_fileinto 
4 {
5   var $data     = array();
6   var $object_id= -1;
7   var $options  = array();
9   function save_object()
10   {
11     $mbs = $this->get_mail_boxes();
12     
13     if(isset($_POST['fileinto_'.$this->object_id])){
14       $mb = $_POST['fileinto_'.$this->object_id];
16       if(isset($mbs[$mb])) {
17         $this->data[0] = $mb; 
18       }
19     }
20   }
22   function sieve_fileinto($data,$object_id)
23   {
24     $this->object_id = $object_id;
26     if($data == NULL){
27       $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => _(""))));
28     }
30     foreach($data['ELEMENTS'] as $node ){
31       if(in_array($node['class'],array("quoted-string","text"))){
32         $this->data[] = preg_replace("/\"/","",$node['text']);
33       }
34     }
35   }
37   function get_sieve_script_part()
38   {
39     $tmp = "";
40     foreach($this->data as $dat){
41       $tmp.= "\"".$dat."\", ";
42     }
43     $tmp = preg_replace("/,$/","",trim($tmp));
44     $tmp = preg_replace ("/\"\"/","\"",$tmp);
45     return("fileinto ".$tmp.";\n");
46   } 
47     
48   function execute()
49   {
50     $smarty = get_smarty();
51     $smarty->assign("Selected",$this->data[0]);
52     $smarty->assign("Boxes", $this->get_mail_boxes());
53     $smarty->assign("ID", $this->object_id);
54     $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
55     $object= $smarty->fetch(get_template_path("templates/element_fileinto.tpl",TRUE,dirname(__FILE__)));
56     $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
58     return($str);
59   }
61   function check()
62   {
63     return(array());
64   }
66   function get_mail_boxes()
67   {
68     return(array("not"=>"not","impplemented/yet"=>"impplemented/yet"));
69   }
70 }
72 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
73 ?>