Code

Fixed some errors
[gosa.git] / include / sieve / class_sieveElement_Comment.inc
1 <?php
3 /* Sieve comment tag */
4 class sieve_comment 
5 {
6   var $data = "";
7   var $object_id= -1;
9   function get_sieve_script_part()
10   {
11     return($this->data."\n");
12   } 
13     
14   function sieve_comment($data,$object_id)
15   {
16     $this->object_id = $object_id;
18     if($data == NULL){
19       $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => _("Your comment here"))));
20     }
22     foreach($data['ELEMENTS'] as $node){
23        $this->data .= $node['text'];
24     }
25   }
27   function check()
28   {
29     return(array())  ;
30   }
32   function save_object()
33   {
34     if(isset($_POST['comment_'.$this->object_id])){
35       $cm = $_POST['comment_'.$this->object_id];
36       $this->data = "/*".$cm."*/";
37     }
38   }
40   function execute()
41   {
42     $smarty = get_smarty();
43     $smarty->assign("ID", $this->object_id);
44     $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
45     $Comment = $this->data;
47     /* Remove comment tags */
48     if(preg_match("/^#/",$Comment)){
49       $Comment = preg_replace("/^#/","",$Comment);
50     }elseif(preg_match("#\/\*#",$Comment)){
51       $Comment = preg_replace("#^\/\*#","",$Comment);
52       $Comment = preg_replace("#\*\/$#","",$Comment);
53     }
54  
55     /* Create html object */ 
56     $smarty = get_smarty();
57     $smarty->assign("Comment",$Comment);
58     $smarty->assign("ID",$this->object_id);
59     $object = $smarty->fetch(get_template_path("templates/element_comment.tpl",TRUE,dirname(__FILE__)));    
60     $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
61     return($str);
62   }
63 }
64 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
65 ?>