Code

Updated apache service
[gosa.git] / gosa-plugins / mail / admin / systems / services / mail / class_goMailServer.inc
1 <?php
3 class goMailServer extends goService{
4         
5   var $cli_summary      = "This pluign is used within the ServerService Pluign \nand indicates that this server supports mailqueue listings and so on.";
6   var $cli_description  = "Some longer text\nfor help";
7   var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
9   /* This plugin only writes its objectClass */
10   var $objectclasses    = array("goMailServer");
12   /* This class can't be assigned twice so it conflicts with itsself */
13   var $DisplayName      = "";
14   var $dn               = NULL;
15   var $StatusFlag       = "goMailServerStatus";
16   var $attributes       = array("description","postfixHeaderSizeLimit",
17       "postfixMailboxSizeLimit","postfixMessageSizeLimit",
18       "postfixMyDestinations","postfixMyDomain","postfixMyhostname",
19       "postfixMyNetworks","postfixRelayhost","postfixTransportTable",
20       "postfixSenderRestrictions","postfixRecipientRestrictions");
22   var $goMailServerStatus               ;
23   var $postfixHeaderSizeLimit           = 0;
24   var $postfixMailboxSizeLimit          = 0;
25   var $postfixMessageSizeLimit          = 0;
26   var $postfixMyDestinations            = array();
27   var $postfixMyDomain                  = "";
28   var $postfixMyhostname                = "";
29   var $postfixMyNetworks                = array();
30   var $postfixRelayhost                 = "";
31   var $postfixTransportTable            = array();
32   var $postfixSenderRestrictions        = array();
33   var $postfixRecipientRestrictions     = array();
34   var $description                      = "";
35   var $RestrictionFilters               = array();
36   var $TransportProtocols               = array(); 
37   var $Actions                          = array();
38   var $cn                               = "";
39   var $conflicts                        = array("goMailServer","kolab");
40   var $view_logged  =FALSE;
42   function goMailServer(&$config,$dn)
43   {
44     goService::goService($config,$dn);
45     $this->DisplayName = _("Mail smtp service (Postfix)");
47     $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
48                             SERVICE_STARTED => SERVICE_STARTED,
49                             SERVICE_RESTARTED=>SERVICE_RESTARTED); 
51     /* Fill  RestrictionFilters   TransportProtocols  from external hooks */
52     $str = $this->config->data['TABS']['SERVERSERVICE'];
53     $this->TransportProtocols =array("smtp"=>"SMTP");
54     $this->RestrictionFilters = array("FILTER"=>"FILTER"); 
55     foreach(array("POSTFIXRESTRICTIONFILTERS"=>"RestrictionFilters",
56           "POSTFIXPROTOCOLS"        =>"TransportProtocols") as $file => $var){
57       if($this->config->get_cfg_value($file) != ""){
58         $file = $this->config->get_cfg_value($file);
59         if((isset($file)) && is_readable($file)){
60           $tmp = file_get_contents($file);
61           $tmp2= preg_split("/\n/",$tmp);
62           foreach($tmp2 as $entry){
63             if(empty($entry)) continue;
64             if(preg_match("/:/",$entry)){
65               $tmp3 = explode(":",$entry);
66               $r = $this->$var;
67               $r[$tmp3[0]]=$tmp3[1];
68               $this->$var = $r;
69             }else{
70               $r = $this->$var;
71               $r[$entry] =$entry;
72               $this->$var = $r;
73             }
74           }
75         }
76       }
77     }
80     /* Get postfix my networks */
81     $this->postfixMyNetworks = array();
82     $tmp = array();
83     if(isset($this->attrs['postfixMyNetworks'][0])){
84       $tmp = explode(",",$this->attrs['postfixMyNetworks'][0]);
85       foreach($tmp as $str){
86         if(!empty($str)){
87           $this->postfixMyNetworks[base64_encode($str)] = $str;
88         }
89       }
90     }
93     /* Create full name */
94     if(isset($this->attrs['postfixMyDomain'][0])){
95       $this->postfixMyhostname .= ".".$this->attrs['postfixMyDomain'][0];
96     }
97   
99     /* Get postfix my domains */
100     $this->postfixMyDestinations = array(); 
101     if(isset($this->attrs['postfixMyDestinations'][0])){
102       unset($this->attrs['postfixMyDestinations']['count']);
103       foreach($this->attrs['postfixMyDestinations'] as $str){
104         $this->postfixMyDestinations[base64_encode($str)] = $str;
105       }
106     }
109     /* Get transport tables */
110     $tmp = array();
111     $this->postfixTransportTable = array();
112     if(isset($this->attrs['postfixTransportTable'])){
113       $tmp = array();
114       unset($this->attrs['postfixTransportTable']['count']);
115       foreach($this->attrs['postfixTransportTable'] as $entry){
117         //0: offshore.vip.ms-europa.lhsystems.com smtp:172.28.0.2
119         $Number   = preg_replace('/^([^:]+):.*$/', '\\1', $entry);
120         $Rest     = trim(preg_replace("/^[0-9]*:/","",$entry));
122         $Protocol_Destination = preg_replace("/^.*\ /","",$Rest);
123         $Source               = preg_replace("/\ .*$/","",$Rest);
125         $Protocol     = preg_replace ('/^([^:]+):.*$/', '\\1' ,trim($Protocol_Destination));
126         $Destination  = preg_replace ('/^[^:]+:(.*)$/', '\\1'    ,trim($Protocol_Destination));
128         $Destination  = preg_replace ("/[\[\]]/","",$Destination);
130         $tmp[$Number]['src'] = $Source;
131         $tmp[$Number]['dst'] = $Destination;
132         $tmp[$Number]['prt'] = $Protocol;
133       }
134       ksort($tmp);
135       foreach($tmp as $entry){
136         $this->postfixTransportTable[] = $entry;
137       }
138     }
139    
141     /* Get sender restrictions */
142     $tmp = array();
143     $this->postfixSenderRestrictions = array();
144     if(isset($this->attrs['postfixSenderRestrictions'])){
145       unset($this->attrs['postfixSenderRestrictions']['count']);
146       foreach($this->attrs['postfixSenderRestrictions'] as $entry){
147         $nr  = preg_replace("/:.*$/","",$entry);
148         $rest= trim(preg_replace("/^[^:]+:/","",$entry));
149         $src = preg_replace("/ .*$/","",$rest);
150         $rest= preg_replace("/^[^ ]+ /","",$rest);
151         $dst = preg_replace("/^.* /","",$rest);
152         $prt = preg_replace("/ .*$/","",$rest);
153  
154         $tmp[$nr]['src'] = $src;
155         $tmp[$nr]['dst'] = $dst;
156         $tmp[$nr]['filter'] = $prt;
157       }
158       ksort($tmp);
159       foreach($tmp as $entry){
160         $this->postfixSenderRestrictions[] = $entry;
161       }
162     }
164  
165     /* Get sender restrictions */
166     $tmp = array();
167     $this->postfixRecipientRestrictions = array();
168     if(isset($this->attrs['postfixRecipientRestrictions'])){
169       unset($this->attrs['postfixRecipientRestrictions']['count']);
170       foreach($this->attrs['postfixRecipientRestrictions'] as $entry){
171         $nr  = preg_replace("/:.*$/","",$entry);
172         $rest= trim(preg_replace("/^[^:]+:/","",$entry));
173         $src = preg_replace("/ .*$/","",$rest);
174         $rest= preg_replace("/^[^ ]+ /","",$rest);
175         $dst = preg_replace("/^.* /","",$rest);
176         $prt = preg_replace("/ .*$/","",$rest);
177  
178         $tmp[$nr]['src'] = $src;
179         $tmp[$nr]['dst'] = $dst;
180         $tmp[$nr]['filter'] = $prt;
181       }
182       ksort($tmp);
183       foreach($tmp as $entry){
184         $this->postfixRecipientRestrictions[] = $entry;
185       }
186     }
188   }
190   function execute()
191   { 
192     $smarty   = get_smarty();
194     if($this->is_account && !$this->view_logged){
195       $this->view_logged = TRUE;
196       new log("view","server/".get_class($this),$this->dn);
197     }
199     $tmp = $this->plInfo();
200     foreach($tmp['plProvidedAcls'] as $name => $translation){
201       $smarty->assign($name."ACL",$this->getacl($name));
202     }
204     $delAr    = array( 
205                     "TranslationDel_"=>"TranslationDel",
206                     "SenderRestrictDel_"=>"SenderRestrictDel",
207                     "RecipientRestrictDel_"=>"RecipientRestrictDel");
208  
209     $once     = true;
210     $s_action = "";
211     $s_entry  = "";
212   
213     /* Check posts for some intruductions */
214     foreach($_POST as $name => $value){
215       foreach($delAr as $preg => $type){
216         if((preg_match("/^".$preg."/",$name)) && ($once)){
217           $once = false;
218           $s_action = $type; 
219           $s_entry = preg_replace("/^".$preg."/","",$name);
220           $s_entry = preg_replace("/_[xy]$/","",$s_entry);
221         }
222       }
224       if(preg_match("/^TranslationUp_/",$name) && $once && ($this->acl_is_writeable("postfixTransportTableACL"))){
225         $once = false;
226         $key = preg_replace("/^TranslationUp_/","",$name);
227         $key = preg_replace("/_[xy]$/","",$key);
228         $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ;
229       }
230       if(preg_match("/^TranslationDown_/",$name) && $once && ($this->acl_is_writeable("postfixTransportTableACL"))){
231         $once = false;
232         $key = preg_replace("/^TranslationDown_/","",$name);
233         $key = preg_replace("/_[xy]$/","",$key);
234         $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ;
235       }
236       if(preg_match("/^SenderRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
237         $once = false;
238         $key = preg_replace("/^SenderRestrictUp_/","",$name);
239         $key = preg_replace("/_[xy]$/","",$key);
240         $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ;
241       }
242       if(preg_match("/^SenderRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
243         $once = false;
244         $key = preg_replace("/^SenderRestrictDown_/","",$name);
245         $key = preg_replace("/_[xy]$/","",$key);
246         $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ;
247       }
248       if(preg_match("/^RecipientRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
249         $once = false;
250         $key = preg_replace("/^RecipientRestrictUp_/","",$name);
251         $key = preg_replace("/_[xy]$/","",$key);
252         $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ;
253       }
254       if(preg_match("/^RecipientRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
255         $once = false;
256         $key = preg_replace("/^RecipientRestrictDown_/","",$name);
257         $key = preg_replace("/_[xy]$/","",$key);
258         $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ;
259       }
260     }
263     /* Add delete my network entry */
264     if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){
265       $str = $_POST['NewString_postfixMyNetworks'];
266       $this->postfixMyNetworks[base64_encode($str)] = $str;
267     }
269     if((isset($_POST['DelpostfixMyNetworks'])) && isset($_POST['Select_postfixMyNetworks']) &&(count($_POST['Select_postfixMyNetworks']))){
270       foreach($_POST['Select_postfixMyNetworks'] as $str ){
271         unset($this->postfixMyNetworks[$str]);
272       }
273     }
276     /* Add delete my domain entry */
277     if($this->acl_is_writeable("postfixMyDestinations")){
278       if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){
279         $str = $_POST['NewString_postfixMyDestinations'];
280         $this->postfixMyDestinations[base64_encode($str)] = $str;
281       }
283       if((isset($_POST['DelpostfixMyDestinations'])) && isset($_POST['Select_postfixMyDestinations']) &&(count($_POST['Select_postfixMyDestinations']))){
284         foreach($_POST['Select_postfixMyDestinations'] as $str ){
285           unset($this->postfixMyDestinations[$str]);
286         }
287       }
288     }
291     /* Add sender restriction */
292     if($this->acl_is_writeable("postfixSenderRestrictions")){
293       if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){
294         unset($this->postfixSenderRestrictions[$s_entry]);
295       }
297       if(isset($_POST['AddpostfixSenderRestrictions'])){
298         $src      = $_POST['Source_postfixSenderRestrictions'];
299         $dst      = $_POST['Destination_postfixSenderRestrictions'];
300         $Filter   = $_POST['SenderRestrictionFilter'];
301         $tmp['src']     = $src;
302         $tmp['dst']     = $dst;
303         $tmp['filter']  = $Filter;
304         $this->postfixSenderRestrictions[] = $tmp;
305       }
306     }
309     /* Add sender restriction */
310     if($this->acl_is_writeable("postfixRecipientRestrictions")){
311       if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){
312         unset($this->postfixRecipientRestrictions[$s_entry]);
313       }
315       if(isset($_POST['AddpostfixRecipientRestrictions'])){
316         $src      = $_POST['Source_postfixRecipientRestrictions'];
317         $dst      = $_POST['Destination_postfixRecipientRestrictions'];
318         $Filter   = $_POST['RecipientRestrictionFilter'];
319         $tmp['src']     = $src;
320         $tmp['dst']     = $dst;
321         $tmp['filter']  = $Filter;
322         $this->postfixRecipientRestrictions[] = $tmp;
323       }
324     }
326     /* Handle transports */
327     if($this->acl_is_writeable("postfixTransportTable")){
328       if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){
329         unset($this->postfixTransportTable[$s_entry]);
330       }
332       if(isset($_POST['AddpostfixTransportTable'])){
333         $src = trim($_POST['Source_postfixTransportTable']);  
334         $dst = trim($_POST['Destination_postfixTransportTable']);    
335         $prt = trim($_POST['TransportProtocol']);
337         if((!empty($src)) && (!empty($dst))){
338           if(preg_match("/:/",$dst)){
339             $tmp = explode(":",$dst);
340             $port = trim($tmp[1]);
341             $ip   = trim($tmp[0]);
343             if((tests::is_ip($ip)) && (is_numeric($port))){
344               $dst = "[".$ip."]:".$port;
345             }
346           }
347           if(tests::is_ip($dst)){
348             $dst = "[".$dst."]";
349           }
350           $tmp2 ['src'] = $src;
351           $tmp2 ['dst'] = $dst;
352           $tmp2 ['prt'] = $prt;
354           $this->postfixTransportTable[] = $tmp2;  
355         } 
356       }
357     }
359     /* Set attributes */
360     foreach($this->attributes as $attr){
361       $smarty->assign($attr,$this->$attr);
362     }
365     /* Create divList for translation tables */
366     $divTranslation = new divSelectBox("TransportProtocols");
367     $divTranslation->SetHeight(90);
368     foreach($this->postfixTransportTable as $key => $entry){
369       $img = "";
370       $img.= image('images/lists/sort-up.png','TranslationUp_'.$key);
371       $img.= image('images/lists/sort-down.png','TranslationDown_'.$key);
373       if($this->acl_is_writeable("postfixTransportTable")){
374         $img.= image('images/lists/trash.png','TranslationDel_'.$key);
375       }
376       $field1 = array("string"=> $entry['src']);
377       $field2 = array("string"=> $entry['dst']);
378       $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'");
379       $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
380       $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,));
381     }
382     $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList());
385     /* Create divList for sender restrictions */
386     $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions");
387     $DivSenderRestrict->SetHeight(90);
388     foreach($this->postfixSenderRestrictions as $key => $entry){
389       $img ="";
390       $img.= image('images/lists/sort-up.png','SenderRestrictUp_'.$key);
391       $img.= image('images/lists/sort-down.png','SenderRestrictDown_'.$key);
393       if($this->acl_is_writeable("postfixSenderRestrictions")){
394         $img.= image('images/lists/trash.png','SenderRestrictDel_'.$key);
395       }
396  
397       $field1 = array("string"=> $entry['src']);
398       $field2 = array("string"=> $entry['dst']);
399       $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
400       $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
401       $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
402     }
403     $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList());
406     /* Create divList for translation tables */
407     $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions");
408     $DivRecipientRestrict->SetHeight(90);
410     foreach($this->postfixRecipientRestrictions as $key => $entry){
411       $img = "";
412       $img.= image('images/lists/sort-up.png','RecipientRestrictUp_'.$key);
413       $img.= image('images/lists/sort-down.png','RecipientRestrictDown_'.$key);
415       if($this->acl_is_writeable("postfixRecipientRestrictions")){
416         $img.= image('images/lists/trash.png','RecipientRestrictDel_'.$key);
417       }
418       $field1 = array("string"=> $entry['src']);
419       $field2 = array("string"=> $entry['dst']);
420       $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
421       $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
422       $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
423     }
424     $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList());
426     
427     /* set new status */
428     if(isset($_POST['ExecAction'])){
429       if(isset($this->Actions[$_POST['action']])){
430         $this->setStatus($_POST['action']);
431       }
432     }
435     $smarty->assign("is_new",                       $this->dn);
436     $smarty->assign("is_acc",                       $this->initially_was_account);
437     $smarty->assign("TransportProtocols",           $this->TransportProtocols);
438     $smarty->assign("Actions",                      $this->Actions);
439     $smarty->assign("RestrictionFilters",           $this->RestrictionFilters);
440     $smarty->assign("postfixTransportTable" ,       $this->getTransports());
441     $smarty->assign("postfixSenderRestrictions" ,   $this->getSenderRestrictions());
442     $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions());
444     return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__))));
445   }
447  
448   /* return transports formated for select box */ 
449   function getTransports()
450   {
451     $ret = array();
452     foreach($this->postfixTransportTable as $key => $vals){
453       $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst'];
454     }
455     return($ret);
456   }
459   /* return sender restriction formated for select box */ 
460   function getSenderRestrictions()
461   {
462     $ret = array();
463     foreach($this->postfixSenderRestrictions as $key => $vals){
464       $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
465     }
466     return($ret);
467   }
470   /* return recipient restriction formated for select box */ 
471   function getRecipientRestrictions()
472   {
473     $ret = array();
474     foreach($this->postfixRecipientRestrictions as $key => $vals){
475       $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
476     }
477     return($ret);
478   }
481   /* Return list entry */
482   function getListEntry()
483   {
484     $fields               = goService::getListEntry();
485     $fields['Message']    = _("Mail smtp service (Postfix)");
486     #$fields['AllowEdit']  = true;
487     return($fields);
488   }
491   function save()
492   {
493     $this->postfixMyDomain   = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname);
494     $this->postfixMyhostname = preg_replace("/\..*$/","",$this->postfixMyhostname);
496     plugin::save();
498     /* Fix transport table*/
499     $i = 0 ; 
500     $this->attrs['postfixTransportTable'] = array();
501     foreach($this->postfixTransportTable as $key => $entry){
502       $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst'];
503       $i ++;
504     }
507     /* Fix sender restrictions */
508     $i = 0;
509     $this->attrs['postfixSenderRestrictions'] =array();
510     foreach($this->postfixSenderRestrictions as $key => $entry){
511       $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst']; 
512       $i ++;  
513     }
514   
515   
516     /* Fix recipient restrictions */
517     $i = 0;
518     $this->attrs['postfixRecipientRestrictions'] =array();
519     foreach($this->postfixRecipientRestrictions as $key => $entry){
520       $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst']; 
521       $i ++;  
522     }
525     /* Fix mydomains */
526     $this->attrs['postfixMyDestinations']  = array();
527     foreach($this->postfixMyDestinations as $entry){
528       $this->attrs['postfixMyDestinations'][] =$entry;
529     }
532     /* Fix mydomains */
533     if(count($this->postfixMyNetworks)){
534       $this->attrs['postfixMyNetworks']  = "";
535       foreach($this->postfixMyNetworks as $entry){
536         $this->attrs['postfixMyNetworks'] .=$entry.",";
537       }
538       $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']);
539     }else{
540       $this->attrs['postfixMyNetworks']  = array();
541     }
543  
544     /* Check if this is a new entry ... add/modify */
545     $ldap = $this->config->get_ldap_link();
546     $ldap->cat($this->dn,array("objectClass"));
547     if($ldap->count()){
548       $ldap->cd($this->dn);
549       $ldap->modify($this->attrs);
550     }else{
551       $ldap->cd($this->dn);
552       $ldap->add($this->attrs);
553     }
554     if (!$ldap->success()){
555       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
556     }
558     if($this->initially_was_account){
559       $this->handle_post_events("modify");
560       new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());  
561     }else{
562       $this->handle_post_events("add");
563       new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());  
564     }
566   }
569   function check()
570   { 
571     $message =plugin::check();
572     if(!is_numeric($this->postfixHeaderSizeLimit)){
573       $message[] = msgPool::invalid(_("Header size limit",$this->postfixHeaderSizeLimit,"/[0-9]/"));
574     }
575     if(!is_numeric($this->postfixMailboxSizeLimit)){
576       $message[] = msgPool::invalid(_("Mailbox size limit",$this->postfixMailboxSizeLimit,"/[0-9]/"));
577     }
578     if(!is_numeric($this->postfixMessageSizeLimit)){
579       $message[] = msgPool::invalid(_("Message size limit",$this->postfixMessageSizeLimit,"/[0-9]/"));
580     }
581     return $message;
582   }
585   /* Combine new array */
586   function combineArrays($ar0,$ar1,$ar2)
587   {
588     $ret = array();
589     if(is_array($ar0))
590     foreach($ar0 as $ar => $a){
591         $ret[]=$a;
592     }
593     if(is_array($ar1))
594     foreach($ar1 as $ar => $a){
595         $ret[]=$a;
596     }
597     if(is_array($ar2))
598     foreach($ar2 as $ar => $a){
599         $ret[]=$a;
600     }
601     return($ret);
602   }
605   function getpos($atr,$attrs)
606   {
607     $i = 0;
608     foreach($attrs as $attr => $name)    {
609       $i++;
610       if($attr == $atr){
611         return($i);
612       }
613     }
615     return(-1);
616   }
619   /* TRansports the geiven Arraykey one position up*/
620   function ArrayUp($atr,$attrs)
621   {
622     $ret = $attrs;
623     $pos = $this->getpos($atr,$attrs) ;
624     $cn = count($attrs);
625     if(!(($pos == -1)||($pos == 1))){
626       $before = array_slice($attrs,0,($pos-2));
627       $mitte  = array_reverse(array_slice($attrs,($pos-2),2));
628       $unten  = array_slice($attrs,$pos);
629       $ret = array();
630       $ret = $this->combineArrays($before,$mitte,$unten);
631     }
632     return($ret);
633   }
636   /* TRansports the geiven Arraykey one position up*/
637   function ArrayDown($atr,$attrs)
638   {
639     $ret = $attrs;
640     $pos = $this->getpos($atr,$attrs) ;
641     $cn = count($attrs);
642     if(!(($pos == -1)||($pos == $cn))){
643       $before = array_slice($attrs,0,($pos-1));
644       $mitte  = array_reverse(array_slice($attrs,($pos-1),2));
645       $unten  = array_slice($attrs,($pos+1));
646       $ret = array();
647       $ret = $this->combineArrays($before,$mitte,$unten);
648     }
649     return($ret);
650   }
652   function save_object()
653   {
654     plugin::save_object();  
655   }
658   function PrepareForCopyPaste($source)
659   {
660     plugin::PrepareForCopyPaste($source);
662     $source_o = new goMailServer($this->config,$source['dn']);
663     foreach(array("postfixMyDomain","postfixMyhostname","postfixMyNetworks","postfixTransportTable","postfixSenderRestrictions","postfixRecipientRestrictions","postfixMyDestinations") as $attr){
664       $this->$attr = $source_o->$attr;
665     }
666   }
669   /* Return plugin informations for acl handling */
670   static function plInfo()
671   {
672     return (array(
673           "plShortName"   => _("Mail smtp (Postfix)"),
674           "plDescription" => _("Mail smtp - Postfix")." ("._("Services").")",
675           "plSelfModify"  => FALSE,
676           "plDepends"     => array(),
677           "plPriority"    => 98,
678           "plSection"     => array("administration"),
679           "plCategory"    => array("server"),
681           "plProvidedAcls"=> array(
682             "postfixMyhostname"           => _("Visible full qualified hostname"),
683             "description"                 => _("Description"), 
684             "postfixHeaderSizeLimit"      => _("Header size limit"), 
685             "postfixMailboxSizeLimit"     => _("Max mailbox size"), 
686             "postfixMessageSizeLimit"     => _("Max message size"), 
687             "postfixMyDestinations"       => _("Domains to accept mail for"), 
688             "postfixMyNetworks"           => _("Local networks"), 
689             "postfixRelayhost"            => _("Relay host"), 
690             "postfixTransportTable"       => _("Transport table"), 
691             "postfixSenderRestrictions"   => _("Restrictions for sender"), 
692             "postfixRecipientRestrictions"=> _("Restrictions for recipient"))
693             ));
694   }
696 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
697 ?>