Code

Move object first.
[gosa.git] / plugins / admin / systems / class_goMailServer.inc
1 <?php
3 require_once("class_goService.inc");
5 class goMailServer extends goService{
6         
7   var $cli_summary      = "This pluign is used within the ServerService Pluign \nand indicates that this server supports mailqueue listings and so on.";
8   var $cli_description  = "Some longer text\nfor help";
9   var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
11   /* This plugin only writes its objectClass */
12   var $objectclasses    = array("goMailServer");
14   /* This class can't be assigned twice so it conflicts with itsself */
15   var $DisplayName      = "";
16   var $dn               = NULL;
17   var $StatusFlag       = "goMailServerStatus";
18   var $attributes       = array("description","postfixHeaderSizeLimit",
19       "postfixMailboxSizeLimit","postfixMessageSizeLimit",
20       "postfixMyDestinations","postfixMyDomain","postfixMyhostname",
21       "postfixMyNetworks","postfixRelayhost","postfixTransportTable",
22       "postfixSenderRestrictions","postfixRecipientRestrictions");
24   var $goMailServerStatus               ;
25   var $postfixHeaderSizeLimit           = 0;
26   var $postfixMailboxSizeLimit          = 0;
27   var $postfixMessageSizeLimit          = 0;
28   var $postfixMyDestinations            = array();
29   var $postfixMyDomain                  = "";
30   var $postfixMyhostname                = "";
31   var $postfixMyNetworks                = array();
32   var $postfixRelayhost                 = "";
33   var $postfixTransportTable            = array();
34   var $postfixSenderRestrictions        = array();
35   var $postfixRecipientRestrictions     = array();
36   var $description                      = "";
37   var $RestrictionFilters               = array();
38   var $TransportProtocols               = array(); 
39   var $Actions                          = array();
40   var $cn                               = "";
41   var $conflicts                        = array("goMailServer","kolab");
43   function goMailServer($config,$dn)
44   {
45     plugin::plugin($config,$dn);
46     $this->DisplayName = _("Mail smtp service (Postfix)");
48     $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
49                             SERVICE_STARTED => SERVICE_STARTED,
50                             SERVICE_RESTARTED=>SERVICE_RESTARTED); 
52     /* Fill  RestrictionFilters   TransportProtocols  from external hooks */
53     $str = $this->config->data['TABS']['SERVERSERVICE'];
54     $this->TransportProtocols =array("smtp"=>"SMTP");
55     $this->RestrictionFilters = array("FILTER"=>"FILTER"); 
56     foreach(array("ADDITIONALRESTRICTIONFILTERS"=>"RestrictionFilters",
57           "ADDITIONALPROTOCOLLS"        =>"TransportProtocols") as $file => $var){
58       if(isset($this->config->data['MAIN'][$file])){
59         $file = $this->config->data['MAIN'][$file];
60         if((isset($file)) && is_readable($file)){
61           $tmp = file_get_contents($file);
62           $tmp2= split("\n",$tmp);
63           foreach($tmp2 as $entry){
64             if(empty($entry)) continue;
65             if(preg_match("/:/",$entry)){
66               $tmp3 = split(":",$entry);
67               $r = $this->$var;
68               $r[$tmp3[0]]=$tmp3[1];
69               $this->$var = $r;
70             }else{
71               $r = $this->$var;
72               $r[$entry] =$entry;
73               $this->$var = $r;
74             }
75           }
76         }
77       }
78     }
81     /* Get postfix my networks */
82     $this->postfixMyNetworks = array();
83     $tmp = array();
84     if(isset($this->attrs['postfixMyNetworks'][0])){
85       $tmp = split(",",$this->attrs['postfixMyNetworks'][0]);
86       foreach($tmp as $str){
87         if(!empty($str)){
88           $this->postfixMyNetworks[base64_encode($str)] = $str;
89         }
90       }
91     }
94     /* Create full name */
95     if(isset($this->attrs['postfixMyDomain'][0])){
96       $this->postfixMyhostname .= ".".$this->attrs['postfixMyDomain'][0];
97     }
98   
100     /* Get postfix my domains */
101     $this->postfixMyDestinations = array(); 
102     if(isset($this->attrs['postfixMyDestinations'][0])){
103       unset($this->attrs['postfixMyDestinations']['count']);
104       foreach($this->attrs['postfixMyDestinations'] as $str){
105         $this->postfixMyDestinations[base64_encode($str)] = $str;
106       }
107     }
110     /* Get transport tables */
111     $tmp = array();
112     $this->postfixTransportTable = array();
113     if(isset($this->attrs['postfixTransportTable'])){
114       $tmp = array();
115       unset($this->attrs['postfixTransportTable']['count']);
116       foreach($this->attrs['postfixTransportTable'] as $entry){
118         //0: offshore.vip.ms-europa.lhsystems.com smtp:172.28.0.2
120         $Number   = preg_replace('/^([^:]+):.*$/', '\\1', $entry);
121         $Rest     = trim(preg_replace("/^[0-9]*:/","",$entry));
123         $Protocol_Destination = preg_replace("/^.*\ /","",$Rest);
124         $Source               = preg_replace("/\ .*$/","",$Rest);
126         $Protocol     = preg_replace ('/^([^:]+):.*$/', '\\1' ,trim($Protocol_Destination));
127         $Destination  = preg_replace ('/^[^:]+:(.*)$/', '\\1'    ,trim($Protocol_Destination));
129         $Destination  = preg_replace ("/[\[\]]/","",$Destination);
131         $tmp[$Number]['src'] = $Source;
132         $tmp[$Number]['dst'] = $Destination;
133         $tmp[$Number]['prt'] = $Protocol;
134       }
135       ksort($tmp);
136       foreach($tmp as $entry){
137         $this->postfixTransportTable[] = $entry;
138       }
139     }
140    
142     /* Get sender restrictions */
143     $tmp = array();
144     $this->postfixSenderRestrictions = array();
145     if(isset($this->attrs['postfixSenderRestrictions'])){
146       unset($this->attrs['postfixSenderRestrictions']['count']);
147       foreach($this->attrs['postfixSenderRestrictions'] as $entry){
148         $nr  = preg_replace("/:.*$/","",$entry);
149         $rest= trim(preg_replace("/^[^:]+:/","",$entry));
150         $src = preg_replace("/ .*$/","",$rest);
151         $rest= preg_replace("/^[^ ]+ /","",$rest);
152         $dst = preg_replace("/^.* /","",$rest);
153         $prt = preg_replace("/ .*$/","",$rest);
154  
155         $tmp[$nr]['src'] = $src;
156         $tmp[$nr]['dst'] = $dst;
157         $tmp[$nr]['filter'] = $prt;
158       }
159       ksort($tmp);
160       foreach($tmp as $entry){
161         $this->postfixSenderRestrictions[] = $entry;
162       }
163     }
165  
166     /* Get sender restrictions */
167     $tmp = array();
168     $this->postfixRecipientRestrictions = array();
169     if(isset($this->attrs['postfixRecipientRestrictions'])){
170       unset($this->attrs['postfixRecipientRestrictions']['count']);
171       foreach($this->attrs['postfixRecipientRestrictions'] as $entry){
172         $nr  = preg_replace("/:.*$/","",$entry);
173         $rest= trim(preg_replace("/^[^:]+:/","",$entry));
174         $src = preg_replace("/ .*$/","",$rest);
175         $rest= preg_replace("/^[^ ]+ /","",$rest);
176         $dst = preg_replace("/^.* /","",$rest);
177         $prt = preg_replace("/ .*$/","",$rest);
178  
179         $tmp[$nr]['src'] = $src;
180         $tmp[$nr]['dst'] = $dst;
181         $tmp[$nr]['filter'] = $prt;
182       }
183       ksort($tmp);
184       foreach($tmp as $entry){
185         $this->postfixRecipientRestrictions[] = $entry;
186       }
187     }
189   }
191   function execute()
192   { 
193     $smarty   = get_smarty();
195     $tmp = $this->plInfo();
196     foreach($tmp['plProvidedAcls'] as $name => $translation){
197       $smarty->assign($name."ACL",$this->getacl($name));
198     }
200     $delAr    = array( 
201                     "TranslationDel_"=>"TranslationDel",
202                     "SenderRestrictDel_"=>"SenderRestrictDel",
203                     "RecipientRestrictDel_"=>"RecipientRestrictDel");
204  
205     $once     = true;
206     $s_action = "";
207     $s_entry  = "";
208   
209     /* Check posts for some intruductions */
210     foreach($_POST as $name => $value){
211       foreach($delAr as $preg => $type){
212         if((preg_match("/^".$preg."/",$name)) && ($once)){
213           $once = false;
214           $s_action = $type; 
215           $s_entry = preg_replace("/^".$preg."/","",$name);
216           $s_entry = preg_replace("/_[xy]$/","",$s_entry);
217         }
218       }
219   
221       if(preg_match("/^TranslationUp_/",$name) && $once && ($this->acl_is_writeablei("postfixTransportTableACL"))){
222         $once = false;
223         $key = preg_replace("/^TranslationUp_/","",$name);
224         $key = preg_replace("/_[xy]$/","",$key);
225         $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ;
226       }
227       if(preg_match("/^TranslationDown_/",$name) && $once && ($this->acl_is_writeable("postfixTransportTableACL"))){
228         $once = false;
229         $key = preg_replace("/^TranslationDown_/","",$name);
230         $key = preg_replace("/_[xy]$/","",$key);
231         $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ;
232       }
233       if(preg_match("/^SenderRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
234         $once = false;
235         $key = preg_replace("/^SenderRestrictUp_/","",$name);
236         $key = preg_replace("/_[xy]$/","",$key);
237         $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ;
238       }
239       if(preg_match("/^SenderRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
240         $once = false;
241         $key = preg_replace("/^SenderRestrictDown_/","",$name);
242         $key = preg_replace("/_[xy]$/","",$key);
243         $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ;
244       }
245       if(preg_match("/^RecipientRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
246         $once = false;
247         $key = preg_replace("/^RecipientRestrictUp_/","",$name);
248         $key = preg_replace("/_[xy]$/","",$key);
249         $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ;
250       }
251       if(preg_match("/^RecipientRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
252         $once = false;
253         $key = preg_replace("/^RecipientRestrictDown_/","",$name);
254         $key = preg_replace("/_[xy]$/","",$key);
255         $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ;
256       }
257     }
260     /* Add delete my network entry */
261     if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){
262       $str = $_POST['NewString_postfixMyNetworks'];
263       $this->postfixMyNetworks[base64_encode($str)] = $str;
264     }
266     if((isset($_POST['DelpostfixMyNetworks'])) && isset($_POST['Select_postfixMyNetworks']) &&(count($_POST['Select_postfixMyNetworks']))){
267       foreach($_POST['Select_postfixMyNetworks'] as $str ){
268         unset($this->postfixMyNetworks[$str]);
269       }
270     }
273     /* Add delete my domain entry */
274     if($this->acl_is_writeable("postfixMyDestinations")){
275       if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){
276         $str = $_POST['NewString_postfixMyDestinations'];
277         $this->postfixMyDestinations[base64_encode($str)] = $str;
278       }
280       if((isset($_POST['DelpostfixMyDestinations'])) && isset($_POST['Select_postfixMyDestinations']) &&(count($_POST['Select_postfixMyDestinations']))){
281         foreach($_POST['Select_postfixMyDestinations'] as $str ){
282           unset($this->postfixMyDestinations[$str]);
283         }
284       }
285     }
288     /* Add sender restriction */
289     if($this->acl_is_writeable("postfixSenderRestrictions")){
290       if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){
291         unset($this->postfixSenderRestrictions[$s_entry]);
292       }
294       if(isset($_POST['AddpostfixSenderRestrictions'])){
295         $src      = $_POST['Source_postfixSenderRestrictions'];
296         $dst      = $_POST['Destination_postfixSenderRestrictions'];
297         $Filter   = $_POST['SenderRestrictionFilter'];
298         $tmp['src']     = $src;
299         $tmp['dst']     = $dst;
300         $tmp['filter']  = $Filter;
301         $this->postfixSenderRestrictions[] = $tmp;
302       }
303     }
306     /* Add sender restriction */
307     if($this->acl_is_writeable("postfixRecipientRestrictions")){
308       if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){
309         unset($this->postfixRecipientRestrictions[$s_entry]);
310       }
312       if(isset($_POST['AddpostfixRecipientRestrictions'])){
313         $src      = $_POST['Source_postfixRecipientRestrictions'];
314         $dst      = $_POST['Destination_postfixRecipientRestrictions'];
315         $Filter   = $_POST['RecipientRestrictionFilter'];
316         $tmp['src']     = $src;
317         $tmp['dst']     = $dst;
318         $tmp['filter']  = $Filter;
319         $this->postfixRecipientRestrictions[] = $tmp;
320       }
321     }
323     /* Handle transports */
324     if($this->acl_is_writeable("postfixTransportTable")){
325       if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){
326         unset($this->postfixTransportTable[$s_entry]);
327       }
329       if(isset($_POST['AddpostfixTransportTable'])){
330         $src = trim($_POST['Source_postfixTransportTable']);  
331         $dst = trim($_POST['Destination_postfixTransportTable']);    
332         $prt = trim($_POST['TransportProtocol']);
334         if((!empty($src)) && (!empty($dst))){
335           if(preg_match("/:/",$dst)){
336             $tmp = split("\:",$dst);
337             $port = trim($tmp[1]);
338             $ip   = trim($tmp[0]);
340             if((is_ip($ip)) && (is_numeric($port))){
341               $dst = "[".$ip."]:".$port;
342             }
343           }
344           if(is_ip($dst)){
345             $dst = "[".$dst."]";
346           }
347           $tmp2 ['src'] = $src;
348           $tmp2 ['dst'] = $dst;
349           $tmp2 ['prt'] = $prt;
351           $this->postfixTransportTable[] = $tmp2;  
352         } 
353       }
354     }
356     /* Set attributes */
357     foreach($this->attributes as $attr){
358       $smarty->assign($attr,$this->$attr);
359     }
362     /* Create divList for translation tables */
363     $divTranslation = new divSelectBox("TransportProtocols");
364     $divTranslation->SetHeight(90);
365     foreach($this->postfixTransportTable as $key => $entry){
366       $img = "";
368       if($key != 0 && $this->acl_is_writeable("postfixTransportTable")){
369         $img.= "<input type='image' src='images/sort_up.png' name='TranslationUp_".$key."' class='center'>&nbsp;";      
370       }else{
371         $img.= "<img src='images/empty.png' style='width:10px;'>";
372       }
373       if(($key+1) < count($this->postfixTransportTable) && $this->acl_is_writeable("postfixTransportTable")){
374         $img.= "<input type='image' src='images/sort_down.png' name='TranslationDown_".$key."' class='center'>&nbsp;";      
375       }else{
376         $img.= "<img src='images/empty.png' style='width:10px;'>";
377       }
379       if($this->acl_is_writeable("postfixTransportTable")){
380         $img.= "<input type='image' src='images/edittrash.png' name='TranslationDel_".$key."' class='center'>&nbsp;";      
381       }
382       $field1 = array("string"=> $entry['src']);
383       $field2 = array("string"=> $entry['dst']);
384       $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'");
385       $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
386       $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,));
387     }
388     $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList());
391     /* Create divList for sender restrictions */
392     $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions");
393     $DivSenderRestrict->SetHeight(90);
394     foreach($this->postfixSenderRestrictions as $key => $entry){
395       $img ="";
397       if($key != 0 && $this->acl_is_writeable("postfixSenderRestrictions")){
398         $img.= "<input type='image' src='images/sort_up.png' name='SenderRestrictUp_".$key."' class='center'>&nbsp;";      
399       }else{
400         $img.= "<img src='images/empty.png' style='width:10px;'>";
401       }
402       if(($key+1) < count($this->postfixSenderRestrictions) && $this->acl_is_writeable("postfixSenderRestrictions")){
403         $img.= "<input type='image' src='images/sort_down.png' name='SenderRestrictDown_".$key."' class='center'>&nbsp;";      
404       }else{
405         $img.= "<img src='images/empty.png' style='width:10px;'>";
406       }
408       if($this->acl_is_writeable("postfixSenderRestrictions")){
409         $img.= "<input type='image' src='images/edittrash.png' name='SenderRestrictDel_".$key."' class='center'>&nbsp;";     
410       }
411  
412       $field1 = array("string"=> $entry['src']);
413       $field2 = array("string"=> $entry['dst']);
414       $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
415       $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
416       $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
417     }
418     $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList());
421     /* Create divList for translation tables */
422     $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions");
423     $DivRecipientRestrict->SetHeight(90);
425     foreach($this->postfixRecipientRestrictions as $key => $entry){
426       $img = "";
427       if($key != 0 && $this->acl_is_writeable("postfixRecipientRestrictions")){
428         $img.= "<input type='image' src='images/sort_up.png' name='RecipientRestrictUp_".$key."' class='center'>&nbsp;";      
429       }else{
430         $img.= "<img src='images/empty.png' style='width:10px;'>";
431       }
432       if(($key+1) < count($this->postfixRecipientRestrictions) && $this->acl_is_writeable("postfixRecipientRestrictions")){
433         $img.= "<input type='image' src='images/sort_down.png' name='RecipientRestrictDown_".$key."' class='center'>&nbsp;";      
434       }else{
435         $img.= "<img src='images/empty.png' style='width:10px;'>";
436       }
438       if($this->acl_is_writeable("postfixRecipientRestrictions")){
439         $img.= "<input type='image' src='images/edittrash.png' name='RecipientRestrictDel_".$key."' class='center'>&nbsp;";      
440       }
441       $field1 = array("string"=> $entry['src']);
442       $field2 = array("string"=> $entry['dst']);
443       $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
444       $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
445       $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
446     }
447     $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList());
449     
450     /* set new status */
451     if(isset($_POST['ExecAction'])){
452       if(isset($this->Actions[$_POST['action']])){
453         $this->setStatus($_POST['action']);
454       }
455     }
458     $smarty->assign("is_new",                       $this->dn);
459     $smarty->assign("is_acc",                       $this->initially_was_account);
460     $smarty->assign("TransportProtocols",           $this->TransportProtocols);
461     $smarty->assign("Actions",                      $this->Actions);
462     $smarty->assign("RestrictionFilters",           $this->RestrictionFilters);
463     $smarty->assign("postfixTransportTable" ,       $this->getTransports());
464     $smarty->assign("postfixSenderRestrictions" ,   $this->getSenderRestrictions());
465     $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions());
467     return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__))));
468   }
470  
471   /* return transports formated for select box */ 
472   function getTransports()
473   {
474     $ret = array();
475     foreach($this->postfixTransportTable as $key => $vals){
476       $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst'];
477     }
478     return($ret);
479   }
482   /* return sender restriction formated for select box */ 
483   function getSenderRestrictions()
484   {
485     $ret = array();
486     foreach($this->postfixSenderRestrictions as $key => $vals){
487       $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
488     }
489     return($ret);
490   }
493   /* return recipient restriction formated for select box */ 
494   function getRecipientRestrictions()
495   {
496     $ret = array();
497     foreach($this->postfixRecipientRestrictions as $key => $vals){
498       $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
499     }
500     return($ret);
501   }
504   /* Return list entry */
505   function getListEntry()
506   {
507     $fields               = goService::getListEntry();
508     $fields['Message']    = _("Mail smtp service (Postfix)");
509     $fields['AllowEdit']  = true;
510     return($fields);
511   }
514   function save()
515   {
516     $this->postfixMyDomain   = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname);
517     $this->postfixMyhostname = preg_replace("/\..*$/","",$this->postfixMyhostname);
519     plugin::save();
521     /* Fix transport table*/
522     $i = 0 ; 
523     $this->attrs['postfixTransportTable'] = array();
524     foreach($this->postfixTransportTable as $key => $entry){
525       $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst'];
526       $i ++;
527     }
530     /* Fix sender restrictions */
531     $i = 0;
532     $this->attrs['postfixSenderRestrictions'] =array();
533     foreach($this->postfixSenderRestrictions as $key => $entry){
534       $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst']; 
535       $i ++;  
536     }
537   
538   
539     /* Fix recipient restrictions */
540     $i = 0;
541     $this->attrs['postfixRecipientRestrictions'] =array();
542     foreach($this->postfixRecipientRestrictions as $key => $entry){
543       $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst']; 
544       $i ++;  
545     }
548     /* Fix mydomains */
549     $this->attrs['postfixMyDestinations']  = array();
550     foreach($this->postfixMyDestinations as $entry){
551       $this->attrs['postfixMyDestinations'][] =$entry;
552     }
555     /* Fix mydomains */
556     if(count($this->postfixMyNetworks)){
557       $this->attrs['postfixMyNetworks']  = "";
558       foreach($this->postfixMyNetworks as $entry){
559         $this->attrs['postfixMyNetworks'] .=$entry.",";
560       }
561       $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']);
562     }else{
563       $this->attrs['postfixMyNetworks']  = array();
564     }
566  
567     /* Check if this is a new entry ... add/modify */
568     $ldap = $this->config->get_ldap_link();
569     $ldap->cat($this->dn,array("objectClass"));
570     if($ldap->count()){
571       $ldap->cd($this->dn);
572       $ldap->modify($this->attrs);
573     }else{
574       $ldap->cd($this->dn);
575       $ldap->add($this->attrs);
576     }
577     show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/mail with dn '%s' failed."),$this->dn));
578     if($this->initially_was_account){
579       $this->handle_post_events("modify");
580     }else{
581       $this->handle_post_events("add");
582     }
584   }
587   function check()
588   { 
589     $message =plugin::check();
590   
591     if(!is_numeric($this->postfixHeaderSizeLimit)){
592       $message[] = _("Please specify a numeric value for header size limit.");
593     }
595     if(!is_numeric($this->postfixMailboxSizeLimit)){
596       $message[] = _("Please specify a numeric value for mailbox size limit.");
597     }
599     if(!is_numeric($this->postfixMessageSizeLimit)){
600       $message[] = _("Please specify a numeric value for message size limit.");
601     }
603     return $message;
604   }
607   /* Combine new array */
608   function combineArrays($ar0,$ar1,$ar2)
609   {
610     $ret = array();
611     if(is_array($ar0))
612     foreach($ar0 as $ar => $a){
613         $ret[]=$a;
614     }
615     if(is_array($ar1))
616     foreach($ar1 as $ar => $a){
617         $ret[]=$a;
618     }
619     if(is_array($ar2))
620     foreach($ar2 as $ar => $a){
621         $ret[]=$a;
622     }
623     return($ret);
624   }
627   function getpos($atr,$attrs)
628   {
629     $i = 0;
630     foreach($attrs as $attr => $name)    {
631       $i++;
632       if($attr == $atr){
633         return($i);
634       }
635     }
637     return(-1);
638   }
641   /* TRansports the geiven Arraykey one position up*/
642   function ArrayUp($atr,$attrs)
643   {
644     $ret = $attrs;
645     $pos = $this->getpos($atr,$attrs) ;
646     $cn = count($attrs);
647     if(!(($pos == -1)||($pos == 1))){
648       $before = array_slice($attrs,0,($pos-2));
649       $mitte  = array_reverse(array_slice($attrs,($pos-2),2));
650       $unten  = array_slice($attrs,$pos);
651       $ret = array();
652       $ret = $this->combineArrays($before,$mitte,$unten);
653     }
654     return($ret);
655   }
658   /* TRansports the geiven Arraykey one position up*/
659   function ArrayDown($atr,$attrs)
660   {
661     $ret = $attrs;
662     $pos = $this->getpos($atr,$attrs) ;
663     $cn = count($attrs);
664     if(!(($pos == -1)||($pos == $cn))){
665       $before = array_slice($attrs,0,($pos-1));
666       $mitte  = array_reverse(array_slice($attrs,($pos-1),2));
667       $unten  = array_slice($attrs,($pos+1));
668       $ret = array();
669       $ret = $this->combineArrays($before,$mitte,$unten);
670     }
671     return($ret);
672   }
674   function save_object()
675   {
676     plugin::save_object();  
677   }
681   /* Return plugin informations for acl handling */
682   function plInfo()
683   {
684     return (array(
685           "plShortName"   => _("Mail smtp (Postfix)"),
686           "plDescription" => _("Mail smtp - Postfix")." ("._("Services").")",
687           "plSelfModify"  => FALSE,
688           "plDepends"     => array(),
689           "plPriority"    => 98,
690           "plSection"     => array("administration"),
691           "plCategory"    => array("server"),
693           "plProvidedAcls"=> array(
694             "postfixMyhostname"           => _("Visible full qualified hostname"),
695             "description"                 => _("Description"), 
696             "postfixHeaderSizeLimit"      => _("Header size limit"), 
697             "postfixMailboxSizeLimit"     => _("Max mailbox size"), 
698             "postfixMessageSizeLimit"     => _("Max message size"), 
699             "postfixMyDestinations"       => _("Domains to accept mail for"), 
700             "postfixMyNetworks"           => _("Local networks"), 
701             "postfixRelayhost"            => _("Relay host"), 
702             "postfixTransportTable"       => _("Transport table"), 
703             "postfixSenderRestrictions"   => _("Restrictions for sender"), 
704             "postfixRecipientRestrictions"=> _("Restrictions for recipient"))
705             ));
706   }
708 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
709 ?>