Code

Fixed save method to prevent errors
[gosa.git] / plugins / admin / systems / class_goMailServer.inc
1 <?php
3 class goMailServer extends plugin{
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 $conflicts        = array("goMailServer");
15   var $DisplayName      = "";
16   var $dn               = NULL;
17   var $StatusFlag       = "goMailServerStatus";
18   var $attributes       = array("goMailServerStatus","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();
42   function goMailServer($config,$dn)
43   {
44     plugin::plugin($config,$dn);
45     $this->DisplayName = _("Mail service (SMTP)");
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("ADDITIONALRESTRICTIONFILTERS"=>"RestrictionFilters",
56           "ADDITIONALPROTOCOLLS"        =>"TransportProtocols") as $file => $var){
57       if(isset($this->config->data['MAIN'][$file])){
58         $file = $this->config->data['MAIN'][$file];
59         if((isset($file)) && is_readable($file)){
60           $tmp = file_get_contents($file);
61           $tmp2= split("\n",$tmp);
62           foreach($tmp2 as $entry){
63             if(empty($entry)) continue;
64             if(preg_match("/:/",$entry)){
65               $tmp3 = split(":",$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     if(isset($this->attrs['postfixMyNetworks'][0])){
83       $tmp = split(",",$this->attrs['postfixMyNetworks'][0]);
84       foreach($tmp as $str){
85         if(!empty($str)){
86           $this->postfixMyNetworks[base64_encode($str)] = $str;
87         }
88       }
89     }
92     /* Create full name */
93     if(isset($this->attrs['postfixMyDomain'][0])){
94       $this->postfixMyhostname .= ".".$this->attrs['postfixMyDomain'][0];
95     }
96   
98     /* Get postfix my domains */
99     $this->postfixMyDestinations = array(); 
100     if(isset($this->attrs['postfixMyDestinations'][0])){
101       unset($this->attrs['postfixMyDestinations']['count']);
102       foreach($this->attrs['postfixMyDestinations'] as $str){
103         $this->postfixMyDestinations[base64_encode($str)] = $str;
104       }
105     }
108     /* Get transport tables */
109     $this->postfixTransportTable = array();
110     if(isset($this->attrs['postfixTransportTable'])){
111       $tmp = array();
112       unset($this->attrs['postfixTransportTable']['count']);
113       foreach($this->attrs['postfixTransportTable'] as $entry){ 
114         $nr  = preg_replace("/:.*$/","",$entry);
115         $rest= trim(preg_replace("/^[^:]+:/","",$entry));
116         $src = preg_replace("/ .*$/","",$rest);
117         $rest= preg_replace("/^[^ ]+ /","",$rest);
118         $dst = preg_replace("/^.*:/","",$rest); 
119         $prt = preg_replace("/:.*$/","",$rest);
120       
121         $tmp[$nr]['src'] = $src;
122         $tmp[$nr]['dst'] = $dst;
123         $tmp[$nr]['prt'] = $prt;
124         
125       }
126       ksort($tmp);
127       foreach($tmp as $entry){
128         $this->postfixTransportTable[] = $entry;
129       }
130     }
131    
133     /* Get sender restrictions */
134     $this->postfixSenderRestrictions = array();
135     if(isset($this->attrs['postfixSenderRestrictions'])){
136       unset($this->attrs['postfixSenderRestrictions']['count']);
137       foreach($this->attrs['postfixSenderRestrictions'] as $entry){
138         $nr  = preg_replace("/:.*$/","",$entry);
139         $rest= trim(preg_replace("/^[^:]+:/","",$entry));
140         $src = preg_replace("/ .*$/","",$rest);
141         $rest= preg_replace("/^[^ ]+ /","",$rest);
142         $dst = preg_replace("/^.* /","",$rest);
143         $prt = preg_replace("/ .*$/","",$rest);
144  
145         $tmp[$nr]['src'] = $src;
146         $tmp[$nr]['dst'] = $dst;
147         $tmp[$nr]['filter'] = $prt;
148       }
149       ksort($tmp);
150       foreach($tmp as $entry){
151         $this->postfixSenderRestrictions[] = $entry;
152       }
153     }
155  
156     /* Get sender restrictions */
157     $this->postfixRecipientRestrictions = array();
158     if(isset($this->attrs['postfixRecipientRestrictions'])){
159       unset($this->attrs['postfixRecipientRestrictions']['count']);
160       foreach($this->attrs['postfixRecipientRestrictions'] as $entry){
161         $nr  = preg_replace("/:.*$/","",$entry);
162         $rest= trim(preg_replace("/^[^:]+:/","",$entry));
163         $src = preg_replace("/ .*$/","",$rest);
164         $rest= preg_replace("/^[^ ]+ /","",$rest);
165         $dst = preg_replace("/^.* /","",$rest);
166         $prt = preg_replace("/ .*$/","",$rest);
167  
168         $tmp[$nr]['src'] = $src;
169         $tmp[$nr]['dst'] = $dst;
170         $tmp[$nr]['filter'] = $prt;
171       }
172       ksort($tmp);
173       foreach($tmp as $entry){
174         $this->postfixRecipientRestrictions[] = $entry;
175       }
176     }
178   }
180   function execute()
181   { 
182     $smarty   = get_smarty();
183     $delAr    = array( "TranslationDel_"=>"TranslationDel",
184                     "SenderRestrictDel_"=>"SenderRestrictDel",
185                     "RecipientRestrictDel_"=>"RecipientRestrictDel");
186  
187     $once     = true;
188     $s_action = "";
189     $s_entry  = "";
190   
191     /* Check posts for some intruductions */
192     foreach($_POST as $name => $value){
193       foreach($delAr as $preg => $type){
194         if((preg_match("/^".$preg."/",$name)) && ($once)){
195           $once = false;
196           $s_action = $type; 
197           $s_entry = preg_replace("/^".$preg."/","",$name);
198           $s_entry = preg_replace("/_[xy]$/","",$s_entry);
199         }
200       }
201   
203       if(preg_match("/^TranslationUp_/",$name) && $once){
204         $once = false;
205         $key = preg_replace("/^TranslationUp_/","",$name);
206         $key = preg_replace("/_[xy]$/","",$key);
207         $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ;
208       }
209       if(preg_match("/^TranslationDown_/",$name) && $once){
210         $once = false;
211         $key = preg_replace("/^TranslationDown_/","",$name);
212         $key = preg_replace("/_[xy]$/","",$key);
213         $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ;
214       }
215       if(preg_match("/^SenderRestrictUp_/",$name) && $once){
216         $once = false;
217         $key = preg_replace("/^SenderRestrictUp_/","",$name);
218         $key = preg_replace("/_[xy]$/","",$key);
219         $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ;
220       }
221       if(preg_match("/^SenderRestrictDown_/",$name) && $once){
222         $once = false;
223         $key = preg_replace("/^SenderRestrictDown_/","",$name);
224         $key = preg_replace("/_[xy]$/","",$key);
225         $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ;
226       }
227       if(preg_match("/^RecipientRestrictUp_/",$name) && $once){
228         $once = false;
229         $key = preg_replace("/^RecipientRestrictUp_/","",$name);
230         $key = preg_replace("/_[xy]$/","",$key);
231         $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ;
232       }
233       if(preg_match("/^RecipientRestrictDown_/",$name) && $once){
234         $once = false;
235         $key = preg_replace("/^RecipientRestrictDown_/","",$name);
236         $key = preg_replace("/_[xy]$/","",$key);
237         $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ;
238       }
239     }
242     /* Add delete my network entry */
243     if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){
244       $str = $_POST['NewString_postfixMyNetworks'];
245       $this->postfixMyNetworks[base64_encode($str)] = $str;
246     }
248     if((isset($_POST['DelpostfixMyNetworks'])) && isset($_POST['Select_postfixMyNetworks']) &&(count($_POST['Select_postfixMyNetworks']))){
249       foreach($_POST['Select_postfixMyNetworks'] as $str ){
250         unset($this->postfixMyNetworks[$str]);
251       }
252     }
255     /* Add delete my domain entry */
256     if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){
257       $str = $_POST['NewString_postfixMyDestinations'];
258       $this->postfixMyDestinations[base64_encode($str)] = $str;
259     }
261     if((isset($_POST['DelpostfixMyDestinations'])) && isset($_POST['Select_postfixMyDestinations']) &&(count($_POST['Select_postfixMyDestinations']))){
262       foreach($_POST['Select_postfixMyDestinations'] as $str ){
263         unset($this->postfixMyDestinations[$str]);
264       }
265     }
268     /* Add sender restriction */
269     if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){
270       unset($this->postfixSenderRestrictions[$s_entry]);
271     }
273     if(isset($_POST['AddpostfixSenderRestrictions'])){
274       $src      = $_POST['Source_postfixSenderRestrictions'];
275       $dst      = $_POST['Destination_postfixSenderRestrictions'];
276       $Filter   = $_POST['SenderRestrictionFilter'];
277       $tmp['src']     = $src;
278       $tmp['dst']     = $dst;
279       $tmp['filter']  = $Filter;
280       $this->postfixSenderRestrictions[] = $tmp;
281     }
284     /* Add sender restriction */
285     if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){
286       unset($this->postfixRecipientRestrictions[$s_entry]);
287     }
289     if(isset($_POST['AddpostfixRecipientRestrictions'])){
290       $src      = $_POST['Source_postfixRecipientRestrictions'];
291       $dst      = $_POST['Destination_postfixRecipientRestrictions'];
292       $Filter   = $_POST['RecipientRestrictionFilter'];
293       $tmp['src']     = $src;
294       $tmp['dst']     = $dst;
295       $tmp['filter']  = $Filter;
296       $this->postfixRecipientRestrictions[] = $tmp;
297     }
300     /* Handle transports */
301     if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){
302       unset($this->postfixTransportTable[$s_entry]);
303     }
304     
305     if(isset($_POST['AddpostfixTransportTable'])){
306       $src = trim($_POST['Source_postfixTransportTable']);  
307       $dst = trim($_POST['Destination_postfixTransportTable']);    
308       $prt = trim($_POST['TransportProtocol']);
310       if((!empty($src)) && (!empty($dst))){
311         if(preg_match("/:/",$dst)){
312           $tmp = split("\:",$dst);
313           $port = trim($tmp[1]);
314           $ip   = trim($tmp[0]);
315     
316           if((is_ip($ip)) && (is_numeric($port))){
317             $dst = "[".$ip."]:".$port;
318           }
319         }
320         if(is_ip($dst)){
321           $dst = "[".$dst."]";
322         }
323         $tmp2 ['src'] = $src;
324         $tmp2 ['dst'] = $dst;
325         $tmp2 ['prt'] = $prt;
327         $this->postfixTransportTable[] = $tmp2;  
328       } 
329     }
332     /* Set attributes */
333     foreach($this->attributes as $attr){
334       $smarty->assign($attr,$this->$attr);
335     }
338     /* Create divList for translation tables */
339     $divTranslation = new divSelectBox("TransportProtocols");
340     $divTranslation->SetHeight(90);
341     foreach($this->postfixTransportTable as $key => $entry){
342       $img = "";
344       if($key != 0){
345         $img.= "<input type='image' src='images/sort_up.png' name='TranslationUp_".$key."' class='center'>&nbsp;";      
346       }else{
347         $img.= "<img src='images/empty.png' style='width:10px;'>";
348       }
349       if(($key+1) < count($this->postfixTransportTable)){
350         $img.= "<input type='image' src='images/sort_down.png' name='TranslationDown_".$key."' class='center'>&nbsp;";      
351       }else{
352         $img.= "<img src='images/empty.png' style='width:10px;'>";
353       }
355       $img.= "<input type='image' src='images/edittrash.png' name='TranslationDel_".$key."' class='center'>&nbsp;";      
356       $field1 = array("string"=> $entry['src']);
357       $field2 = array("string"=> $entry['dst']);
358       $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'");
359       $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
360       $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,));
361     }
362     $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList());
365     /* Create divList for sender restrictions */
366     $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions");
367     $DivSenderRestrict->SetHeight(90);
368     foreach($this->postfixSenderRestrictions as $key => $entry){
369       $img ="";
371       if($key != 0){
372         $img.= "<input type='image' src='images/sort_up.png' name='SenderRestrictUp_".$key."' class='center'>&nbsp;";      
373       }else{
374         $img.= "<img src='images/empty.png' style='width:10px;'>";
375       }
376       if(($key+1) < count($this->postfixSenderRestrictions)){
377         $img.= "<input type='image' src='images/sort_down.png' name='SenderRestrictDown_".$key."' class='center'>&nbsp;";      
378       }else{
379         $img.= "<img src='images/empty.png' style='width:10px;'>";
380       }
382       $img.= "<input type='image' src='images/edittrash.png' name='SenderRestrictDel_".$key."' class='center'>&nbsp;";     
383  
384       $field1 = array("string"=> $entry['src']);
385       $field2 = array("string"=> $entry['dst']);
386       $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
387       $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
388       $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
389     }
390     $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList());
393     /* Create divList for translation tables */
394     $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions");
395     $DivRecipientRestrict->SetHeight(90);
397     foreach($this->postfixRecipientRestrictions as $key => $entry){
398       $img = "";
399       if($key != 0){
400         $img.= "<input type='image' src='images/sort_up.png' name='RecipientRestrictUp_".$key."' class='center'>&nbsp;";      
401       }else{
402         $img.= "<img src='images/empty.png' style='width:10px;'>";
403       }
404       if(($key+1) < count($this->postfixRecipientRestrictions)){
405         $img.= "<input type='image' src='images/sort_down.png' name='RecipientRestrictDown_".$key."' class='center'>&nbsp;";      
406       }else{
407         $img.= "<img src='images/empty.png' style='width:10px;'>";
408       }
409       $img.= "<input type='image' src='images/edittrash.png' name='RecipientRestrictDel_".$key."' class='center'>&nbsp;";      
410       $field1 = array("string"=> $entry['src']);
411       $field2 = array("string"=> $entry['dst']);
412       $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
413       $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
414       $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
415     }
416     $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList());
418     
419     /* set new status */
420     if(isset($_POST['ExecAction'])){
421       if(isset($this->Actions[$_POST['action']])){
422         $this->setStatus($_POST['action']);
423       }
424     }
427     $smarty->assign("is_new",                       $this->dn);
428     $smarty->assign("is_acc",                       $this->initially_was_account);
429     $smarty->assign("TransportProtocols",           $this->TransportProtocols);
430     $smarty->assign("Actions",                      $this->Actions);
431     $smarty->assign("RestrictionFilters",           $this->RestrictionFilters);
432     $smarty->assign("postfixTransportTable" ,       $this->getTransports());
433     $smarty->assign("postfixSenderRestrictions" ,   $this->getSenderRestrictions());
434     $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions());
436     return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__))));
437   }
439  
440   /* return transports formated for select box */ 
441   function getTransports()
442   {
443     $ret = array();
444     foreach($this->postfixTransportTable as $key => $vals){
445       $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst'];
446     }
447     return($ret);
448   }
451   /* return sender restriction formated for select box */ 
452   function getSenderRestrictions()
453   {
454     $ret = array();
455     foreach($this->postfixSenderRestrictions as $key => $vals){
456       $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
457     }
458     return($ret);
459   }
462   /* return recipient restriction formated for select box */ 
463   function getRecipientRestrictions()
464   {
465     $ret = array();
466     foreach($this->postfixRecipientRestrictions as $key => $vals){
467       $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
468     }
469     return($ret);
470   }
473   /* Return list entry */
474   function getListEntry()
475   {
476     $flag = $this->StatusFlag;
477     $fields['Status']     = $this->$flag;
478     $fields['Message']    = _("Postfix")." ["._("configured for")." ".$this->postfixMyhostname."] ";
479     $fields['AllowStart'] = true;
480     $fields['AllowStop']  = true;
481     $fields['AllowRestart'] = true;
482     $fields['AllowRemove']= true;
483     $fields['AllowEdit']  = true;
484     return($fields);
485   }
488   function remove_from_parent()
489   {
490     plugin::remove_from_parent();
491     /* Check if this is a new entry ... add/modify */
492     $ldap = $this->config->get_ldap_link();
493     $ldap->cat($this->dn,array("objectClass"));
494     if($ldap->count()){
495       $ldap->cd($this->dn);
496       $ldap->modify($this->attrs);
497     }else{
498       $ldap->cd($this->dn);
499       $ldap->add($this->attrs);
500     }
501     show_ldap_error($ldap->get_error());
502   }
505   function save()
506   {
507     $this->postfixMyDomain   = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname);
508     $this->postfixMyhostname = preg_replace("/\..*$/","",$this->postfixMyhostname);
510     plugin::save();
512     /* Fix transport table*/
513     $i = 0 ; 
514     $this->attrs['postfixTransportTable'] = array();
515     foreach($this->postfixTransportTable as $key => $entry){
516       $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst'];
517       $i ++;
518     }
521     /* Fix sender restrictions */
522     $i = 0;
523     $this->attrs['postfixSenderRestrictions'] =array();
524     foreach($this->postfixSenderRestrictions as $key => $entry){
525       $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst']; 
526       $i ++;  
527     }
528   
529   
530     /* Fix recipient restrictions */
531     $i = 0;
532     $this->attrs['postfixRecipientRestrictions'] =array();
533     foreach($this->postfixRecipientRestrictions as $key => $entry){
534       $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst']; 
535       $i ++;  
536     }
539     /* Fix mydomains */
540     $this->attrs['postfixMyDestinations']  = array();
541     foreach($this->postfixMyDestinations as $entry){
542       $this->attrs['postfixMyDestinations'][] =$entry;
543     }
546     /* Fix mydomains */
547     if(count($this->postfixMyNetworks)){
548       $this->attrs['postfixMyNetworks']  = "";
549       foreach($this->postfixMyNetworks as $entry){
550         $this->attrs['postfixMyNetworks'] .=$entry.",";
551       }
552       $this->postfixMyNetworks = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']);
553     }else{
554       $this->attrs['postfixMyNetworks']  = array();
555     }
557  
558     /* Check if this is a new entry ... add/modify */
559     $ldap = $this->config->get_ldap_link();
560     $ldap->cat($this->dn,array("objectClass"));
561     if($ldap->count()){
562       $ldap->cd($this->dn);
563       $ldap->modify($this->attrs);
564     }else{
565       $ldap->cd($this->dn);
566       $ldap->add($this->attrs);
567     }
568     show_ldap_error($ldap->get_error());
569   }
572   /* Directly save new status flag */
573   function setStatus($value)
574   {
575     if($value == "none") return;
576     if(!$this->initially_was_account) return;
577     $ldap = $this->config->get_ldap_link();
578     $ldap->cd($this->dn);
579     $ldap->cat($this->dn,array("objectClass"));
580     if($ldap->count()){
582       $tmp = $ldap->fetch();
583       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
584         $attrs['objectClass'][] = $tmp['objectClass'][$i];
585       }
586       $flag = $this->StatusFlag;
587       $attrs[$flag] = $value;
588       $this->$flag = $value;
589       $ldap->modify($attrs);
590       show_ldap_error($ldap->get_error());
591     }
592   }
595   function check()
596   { 
597     $message =plugin::check();
598   
599     if(!is_numeric($this->postfixHeaderSizeLimit)){
600       $message[] = _("Please specify a numeric value for header size limit.");
601     }
603     if(!is_numeric($this->postfixMailboxSizeLimit)){
604       $message[] = _("Please specify a numeric value for mailbox size limit.");
605     }
607     if(!is_numeric($this->postfixMessageSizeLimit)){
608       $message[] = _("Please specify a numeric value for message size limit.");
609     }
611     return $message;
612   }
615   /* Combine new array */
616   function combineArrays($ar0,$ar1,$ar2)
617   {
618     $ret = array();
619     if(is_array($ar0))
620     foreach($ar0 as $ar => $a){
621         $ret[]=$a;
622     }
623     if(is_array($ar1))
624     foreach($ar1 as $ar => $a){
625         $ret[]=$a;
626     }
627     if(is_array($ar2))
628     foreach($ar2 as $ar => $a){
629         $ret[]=$a;
630     }
631     return($ret);
632   }
635   function getpos($atr,$attrs)
636   {
637     $i = 0;
638     foreach($attrs as $attr => $name)    {
639       $i++;
640       if($attr == $atr){
641         return($i);
642       }
643     }
645     return(-1);
646   }
649   /* TRansports the geiven Arraykey one position up*/
650   function ArrayUp($atr,$attrs)
651   {
652     $ret = $attrs;
653     $pos = $this->getpos($atr,$attrs) ;
654     $cn = count($attrs);
655     if(!(($pos == -1)||($pos == 1))){
656       $before = array_slice($attrs,0,($pos-2));
657       $mitte  = array_reverse(array_slice($attrs,($pos-2),2));
658       $unten  = array_slice($attrs,$pos);
659       $ret = array();
660       $ret = $this->combineArrays($before,$mitte,$unten);
661     }
662     return($ret);
663   }
666   /* TRansports the geiven Arraykey one position up*/
667   function ArrayDown($atr,$attrs)
668   {
669     $ret = $attrs;
670     $pos = $this->getpos($atr,$attrs) ;
671     $cn = count($attrs);
672     if(!(($pos == -1)||($pos == $cn))){
673       $before = array_slice($attrs,0,($pos-1));
674       $mitte  = array_reverse(array_slice($attrs,($pos-1),2));
675       $unten  = array_slice($attrs,($pos+1));
676       $ret = array();
677       $ret = $this->combineArrays($before,$mitte,$unten);
678     }
679     return($ret);
680   }
683   function save_object()
684   {
685     plugin::save_object();  
686   }
688 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
689 ?>