Code

Some changes for the sieve filter
[gosa.git] / include / sieve / class_sieveElements.inc
1 <?php
4 class sieve_elsif extends sieve_if 
5 {
6   var $TYPE = "elsif";
7 }
10 class sieve_comment 
11 {
12   var $data = "";
13  
14     
15   function sieve_comment($data)
16   {
17     foreach($data['ELEMENTS'] as $node){
18        $this->data .= $node['text'];
19     }
20   }
22   function execute()
23   {
24     $str  ="<table cellspacing=0 width='100%'><tr><td style='width:100%;background-color:#DDFFDD;'>"._("Comment");
25     $str .="<input type='text' name='comment_' value='".$this->data."'>";
26     $str .="</td></tr></table>";
27     return($str);
28   }
29 }
32 class sieve_require 
34 {
35   var $data = array();
37   function sieve_require($data)
38   {
39     foreach($data['ELEMENTS'] as $node ){
40       if(in_array($node['class'],array("quoted-string","text"))){
41         $this->data[] = preg_replace("/\"/","",$node['text']);
42       }
43     }
44   }
46   function execute()
47   {
48     $str = "<table cellspacing=0 width='100%'><tr><td style='width:100%;background-color:#DDDDFF;'>"._("Script includes");
49     foreach($this->data as $req){
50       $str .= "&nbsp;<i>".$req."</i>";
51     }
52     $str .="</td></tr></table>";
53     return($str);
54   }
55 }
57 class sieve_discard 
58 {
59   var $data = array();
61   function sieve_discard($data)
62   {
63   }
65   function execute()
66   {
67     $str = "<table cellspacing=0 width='100%'><tr><td style='width:100%;background-color:red;'>"._("Discard message");
68     $str .="</td></tr></table>";
69     return($str);
70   }
71 }
75 class sieve_reject 
76 {
77   var $data = array();
79   function sieve_reject($data)
80   {
81     $str = "";
82     foreach($data['ELEMENTS'] as $node ){
83       if(in_array($node['class'],array("quoted-string","text"))){
84         $str .= $node['text'];
85       }
86     }
87     $this->data = preg_replace("/\"/","",$str);
88   }
90   function execute()
91   {
92     $str = "<table cellspacing=0 width='100%'><tr><td style='width:100%;background-color:gray;'>"._("Reject mail");
93     $str .= "&nbsp;<textarea name='test' style='width:90%'>".$this->data."</textarea>";
94     $str .="</td></tr></table>";
95     return($str);
96   }
97 }
99 class sieve_redirect 
101   var $data = array();
103   function sieve_redirect($data)
104   {
105     foreach($data['ELEMENTS'] as $node ){
106       if(in_array($node['class'],array("quoted-string","text"))){
107         $this->data[] = $node['text'];
108       }
109     }
110   }
112   function execute()
113   {
114     $str = "<table cellspacing=0 width='100%'><tr><td style='width:100%;background-color:brown;'>"._("Redirect to");
115     foreach($this->data as $dest){
116       $str .= "<input type='text' name='bal' value='".$dest."'><br> ";
117     }
118     $str .="</td></tr></table>";
119     return($str);
120   }
123 class sieve_fileinto 
125   var $data = array();
127   function sieve_fileinto($data)
128   {
129     foreach($data['ELEMENTS'] as $node ){
130       if(in_array($node['class'],array("quoted-string","text"))){
131         $this->data[] = preg_replace("/\"/","",$node['text']);
132       }
133     }
134   }
136   function execute()
137   {
138     $str = "<table cellspacing=0 width='100%'><tr><td style='width:100%;background-color:green;'>"._("File into");
139     $str .= "<select name='test'>";
140     foreach($this->data as $folder){
141       $str .= "<option>".$folder."</option>";
142     }
143     $str .= "</select>";
144     $str .="</td></tr></table>";
146     return($str);
147   }
150 class sieve_vacation 
152   var $days     = FALSE;
153   var $subject  = FALSE;
154   var $from     = "";
155   var $mime     = "";
156   var $hanlde   = "";
157   var $reason   = "";
158   var $addresses= array();
160   function sieve_vacation($data)
161   {
162     /* Usage:   vacation [":days" number] [":subject" string]
163        [":from" string] [":addresses" string-list]
164        [":mime"] [":handle" string] <reason: string> */
166     /* Not all attribute types are supported by the sieve class right now */
167     $known_attrs = array(":days",":subject",":from",":mime",":handle");
169     /* Walk through elements */
170     for($i = 0 ; $i < count($data['ELEMENTS']) ; $i ++){
172       /* get current element */
173       $node = $data['ELEMENTS'][$i];
175       /* Check if tag is in the specified list of attributes */
176       if($node['class'] == "tag" && in_array($node['text'],$known_attrs)){
178         $var = preg_replace("/\:/","",$node['text']);
179         $this->$var = $data['ELEMENTS'][$i+1]['text'];
180         $i ++;
181       }
183       /* Check for addresses */
184       if($node['class'] == "tag" && $node['text'] == ":addresses") {
185         $this->addresses = array();
186         $i ++;
188         /* Multiple or single address given */
189         if($data['ELEMENTS'][$i]['class'] == "left-bracket"){
190           while($data['ELEMENTS'][$i]['class'] != "right-bracket" && ($i < count($data['ELEMENTS']))){
191             $i ++;
192             if($data['ELEMENTS'][$i]['class'] == "quoted-string"){
193               $this->addresses[] = preg_replace("/\"/i","",$data['ELEMENTS'][$i]['text']);
194             }
195           }
196         }else{
197           $this->addresses[] = $data['ELEMENTS'][$i]['text'] ;
198         }
199       }
201       /* Add the vacation message */
202       if($node['class'] == "quoted-string"){
203         $this->reason = $node['text'];
204       }
205     }
206   }
209   function execute()
210   {
211     $str ="";
212     $str .="<b>"._("Vacation message")."</b>";
213     foreach($this->addresses as $addr){ 
214       $str .="<br><input type='text' value='".$addr."' style='width:50%;'>";
215     }
216     $str .="<br><textarea style='width:100%;height:60px;'>".$this->reason."</textarea>";
217     
218     return($str);
219   }
222 class sieve_block_start 
224   function execute()
225   {
226     return("<table cellspacing=0 width='100%'>
227               <tr>
228                 <td style='width:20px;'>
229                   <img src='images/forward.png' class='center'>
230                 </td>
231                 <td style='background-color:#BBBBBB;border: solid 2px #FFFFFF;'>");
232   }
235 class sieve_block_end 
237   function execute()
238   {
239     return("    </td>
240               </tr>
241             </table>");
242   }
245 /* This class handles the keep statement */
246 class sieve_keep 
248   function execute()
249   {
250     $str = "<table cellspacing=0 width='100%'>
251               <tr>
252                 <td style='width:100%;background-color:green;'>".
253                   _("Keep message");
254     $str .="    </td>
255               </tr>
256             </table>";
257     return($str);
258   }
261 /* This class handles the stop statement */
262 class sieve_stop 
264   function execute()
265   {
266     $str = "<table cellspacing=0 width='100%'>
267               <tr>
268                 <td style='width:100%;background-color:orange;'>".
269                   _("Stop here");
270     $str .="    </td>
271               </tr>
272             </table>";
273     return($str);
274   }
276 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
277 ?>