Code

Updated dialog names
[gosa.git] / gosa-plugins / groupware / personal / groupware / class_filterEditor.inc
1 <?php
3 class filterManager extends plugin{
5     var $filterListing   = NULL;
6     var $filterRules = array();
8     function __construct($config,$parent,$rules)
9     {
10         plugin::plugin($config);
11         
12         $this->parent = &$parent;
14         $this->filterRules = $rules;
15         $this->filterListing= new sortableListing();
16         $this->filterListing->setDeleteable(true);
17         $this->filterListing->setEditable(true);
18         $this->filterListing->setColspecs(array('*'));
19         $this->filterListing->setWidth("100%");
20         $this->filterListing->setHeight("200px;");
21         $this->filterListing->setAcl($this->parent->getacl('mailFilter'));
24         $this->filter = array(); 
25         $this->filter[] =   array (
26                 'TYPE' => 'AND',
27                 'NAME' => 'MuellRaus',
28                 'DESC' => 'Spam loeschen',
29                 'CONDITIONS' => array  (
30                     array('FIELD' => 'from',
31                         'COMPARATOR' => 'equals',
32                         'MATCH' => 'herbert'),
33                     array('FIELD' => 'subject',
34                         'COMPARATOR' => 'contains',
35                         'MATCH' => 'advertising'),
36                     ),
37                 'ACTION' => array (
38                     array('ACTION'=>'MARK',
39                         'VALUE' => 'SPAM'),
40                     array('ACTION'=>'MOVE',
41                         'VALUE' => 'gosa+shared/hickert/trash')
42                     )
43                 );
45         $this->filter[] =   array (
46                 'TYPE' => 'OR',
47                 'NAME' => 'Kunden',
48                 'DESC' => 'Kunden Mails in Wichtig schieben',
49                 'CONDITIONS' => array  (
50                     array('FIELD' => 'from',
51                         'COMPARATOR' => 'contains',
52                         'MATCH' => 'gonicus'),
53                     array('FIELD' => 'from',
54                         'COMPARATOR' => 'contains',
55                         'MATCH' => 'lka'),
56                     ),
57                 'ACTION' => array (
58                     array('ACTION'=>'MARK',
59                         'VALUE' => 'HAM'),
60                     array('ACTION'=>'MOVE',
61                         'VALUE' => 'gosa+shared/hickert/wichtig')
62                     )
63                 );
65     }
67     function execute()
68     {
70         $smarty = get_smarty();
72         $data = $lData = array();
73         foreach($this->filter as $key => $filter){
74             $data[$key] = $filter;
75             $lData[$key] = array('data' => array($filter['NAME'], $filter['DESC']));
76         }
77         $this->filterListing->setListData($data,$lData);
78         $this->filterListing->update();
82         $smarty->assign('list', $this->filterListing->render());
84         return($smarty->fetch(get_template_path('filterManager.tpl',TRUE,dirname(__FILE__))));
85     }
87     function save_object()
88     {
89         $this->filterListing->save_object();
90         $action = $this->filterListing->getAction();
92         // Remove filter was requested.
93         if($action['action'] == 'delete'){
94             $key = $action['targets'][0];
95             $key = $this->filterListing->getKey($key);
96             if(isset($this->filter[$key])){
97                 unset($this->filter[$key]);
98                 $this->filter = array_values($this->filter);
99             }
100         }
102         // Edit filter was requested.
103         if($action['action'] == 'edit'){
104             $key = $action['targets'][0];
105             $key = $this->filterListing->getKey($key);
106             if(isset($this->filter[$key])){
107                 
108             
109             }
110         }
111     }
114 ?>