1 <?php
3 class goMailServer extends goService{
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("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 $tmp = array();
83 if(isset($this->attrs['postfixMyNetworks'][0])){
84 $tmp = split(",",$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 }
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 }
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);
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 }
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);
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");
209 $once = true;
210 $s_action = "";
211 $s_entry = "";
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 }
225 if(preg_match("/^TranslationUp_/",$name) && $once && ($this->acl_is_writeablei("postfixTransportTableACL"))){
226 $once = false;
227 $key = preg_replace("/^TranslationUp_/","",$name);
228 $key = preg_replace("/_[xy]$/","",$key);
229 $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ;
230 }
231 if(preg_match("/^TranslationDown_/",$name) && $once && ($this->acl_is_writeable("postfixTransportTableACL"))){
232 $once = false;
233 $key = preg_replace("/^TranslationDown_/","",$name);
234 $key = preg_replace("/_[xy]$/","",$key);
235 $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ;
236 }
237 if(preg_match("/^SenderRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
238 $once = false;
239 $key = preg_replace("/^SenderRestrictUp_/","",$name);
240 $key = preg_replace("/_[xy]$/","",$key);
241 $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ;
242 }
243 if(preg_match("/^SenderRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
244 $once = false;
245 $key = preg_replace("/^SenderRestrictDown_/","",$name);
246 $key = preg_replace("/_[xy]$/","",$key);
247 $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ;
248 }
249 if(preg_match("/^RecipientRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
250 $once = false;
251 $key = preg_replace("/^RecipientRestrictUp_/","",$name);
252 $key = preg_replace("/_[xy]$/","",$key);
253 $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ;
254 }
255 if(preg_match("/^RecipientRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
256 $once = false;
257 $key = preg_replace("/^RecipientRestrictDown_/","",$name);
258 $key = preg_replace("/_[xy]$/","",$key);
259 $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ;
260 }
261 }
264 /* Add delete my network entry */
265 if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){
266 $str = $_POST['NewString_postfixMyNetworks'];
267 $this->postfixMyNetworks[base64_encode($str)] = $str;
268 }
270 if((isset($_POST['DelpostfixMyNetworks'])) && isset($_POST['Select_postfixMyNetworks']) &&(count($_POST['Select_postfixMyNetworks']))){
271 foreach($_POST['Select_postfixMyNetworks'] as $str ){
272 unset($this->postfixMyNetworks[$str]);
273 }
274 }
277 /* Add delete my domain entry */
278 if($this->acl_is_writeable("postfixMyDestinations")){
279 if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){
280 $str = $_POST['NewString_postfixMyDestinations'];
281 $this->postfixMyDestinations[base64_encode($str)] = $str;
282 }
284 if((isset($_POST['DelpostfixMyDestinations'])) && isset($_POST['Select_postfixMyDestinations']) &&(count($_POST['Select_postfixMyDestinations']))){
285 foreach($_POST['Select_postfixMyDestinations'] as $str ){
286 unset($this->postfixMyDestinations[$str]);
287 }
288 }
289 }
292 /* Add sender restriction */
293 if($this->acl_is_writeable("postfixSenderRestrictions")){
294 if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){
295 unset($this->postfixSenderRestrictions[$s_entry]);
296 }
298 if(isset($_POST['AddpostfixSenderRestrictions'])){
299 $src = $_POST['Source_postfixSenderRestrictions'];
300 $dst = $_POST['Destination_postfixSenderRestrictions'];
301 $Filter = $_POST['SenderRestrictionFilter'];
302 $tmp['src'] = $src;
303 $tmp['dst'] = $dst;
304 $tmp['filter'] = $Filter;
305 $this->postfixSenderRestrictions[] = $tmp;
306 }
307 }
310 /* Add sender restriction */
311 if($this->acl_is_writeable("postfixRecipientRestrictions")){
312 if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){
313 unset($this->postfixRecipientRestrictions[$s_entry]);
314 }
316 if(isset($_POST['AddpostfixRecipientRestrictions'])){
317 $src = $_POST['Source_postfixRecipientRestrictions'];
318 $dst = $_POST['Destination_postfixRecipientRestrictions'];
319 $Filter = $_POST['RecipientRestrictionFilter'];
320 $tmp['src'] = $src;
321 $tmp['dst'] = $dst;
322 $tmp['filter'] = $Filter;
323 $this->postfixRecipientRestrictions[] = $tmp;
324 }
325 }
327 /* Handle transports */
328 if($this->acl_is_writeable("postfixTransportTable")){
329 if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){
330 unset($this->postfixTransportTable[$s_entry]);
331 }
333 if(isset($_POST['AddpostfixTransportTable'])){
334 $src = trim($_POST['Source_postfixTransportTable']);
335 $dst = trim($_POST['Destination_postfixTransportTable']);
336 $prt = trim($_POST['TransportProtocol']);
338 if((!empty($src)) && (!empty($dst))){
339 if(preg_match("/:/",$dst)){
340 $tmp = split("\:",$dst);
341 $port = trim($tmp[1]);
342 $ip = trim($tmp[0]);
344 if((tests::is_ip($ip)) && (is_numeric($port))){
345 $dst = "[".$ip."]:".$port;
346 }
347 }
348 if(tests::is_ip($dst)){
349 $dst = "[".$dst."]";
350 }
351 $tmp2 ['src'] = $src;
352 $tmp2 ['dst'] = $dst;
353 $tmp2 ['prt'] = $prt;
355 $this->postfixTransportTable[] = $tmp2;
356 }
357 }
358 }
360 /* Set attributes */
361 foreach($this->attributes as $attr){
362 $smarty->assign($attr,$this->$attr);
363 }
366 /* Create divList for translation tables */
367 $divTranslation = new divSelectBox("TransportProtocols");
368 $divTranslation->SetHeight(90);
369 foreach($this->postfixTransportTable as $key => $entry){
370 $img = "";
372 if($key != 0 && $this->acl_is_writeable("postfixTransportTable")){
373 $img.= "<input type='image' src='images/lists/sort-up.png' name='TranslationUp_".$key."' class='center'> ";
374 }else{
375 $img.= "<img src='images/empty.png' style='width:10px;'>";
376 }
377 if(($key+1) < count($this->postfixTransportTable) && $this->acl_is_writeable("postfixTransportTable")){
378 $img.= "<input type='image' src='images/lists/sort-down.png' name='TranslationDown_".$key."' class='center'> ";
379 }else{
380 $img.= "<img src='images/empty.png' style='width:10px;'>";
381 }
383 if($this->acl_is_writeable("postfixTransportTable")){
384 $img.= "<input type='image' src='images/lists/trash.png' name='TranslationDel_".$key."' class='center'> ";
385 }
386 $field1 = array("string"=> $entry['src']);
387 $field2 = array("string"=> $entry['dst']);
388 $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'");
389 $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
390 $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,));
391 }
392 $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList());
395 /* Create divList for sender restrictions */
396 $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions");
397 $DivSenderRestrict->SetHeight(90);
398 foreach($this->postfixSenderRestrictions as $key => $entry){
399 $img ="";
401 if($key != 0 && $this->acl_is_writeable("postfixSenderRestrictions")){
402 $img.= "<input type='image' src='images/lists/sort-up.png' name='SenderRestrictUp_".$key."' class='center'> ";
403 }else{
404 $img.= "<img src='images/empty.png' style='width:10px;'>";
405 }
406 if(($key+1) < count($this->postfixSenderRestrictions) && $this->acl_is_writeable("postfixSenderRestrictions")){
407 $img.= "<input type='image' src='images/lists/sort-down.png' name='SenderRestrictDown_".$key."' class='center'> ";
408 }else{
409 $img.= "<img src='images/empty.png' style='width:10px;'>";
410 }
412 if($this->acl_is_writeable("postfixSenderRestrictions")){
413 $img.= "<input type='image' src='images/lists/trash.png' name='SenderRestrictDel_".$key."' class='center'> ";
414 }
416 $field1 = array("string"=> $entry['src']);
417 $field2 = array("string"=> $entry['dst']);
418 $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
419 $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
420 $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
421 }
422 $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList());
425 /* Create divList for translation tables */
426 $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions");
427 $DivRecipientRestrict->SetHeight(90);
429 foreach($this->postfixRecipientRestrictions as $key => $entry){
430 $img = "";
431 if($key != 0 && $this->acl_is_writeable("postfixRecipientRestrictions")){
432 $img.= "<input type='image' src='images/lists/sort-up.png' name='RecipientRestrictUp_".$key."' class='center'> ";
433 }else{
434 $img.= "<img src='images/empty.png' style='width:10px;'>";
435 }
436 if(($key+1) < count($this->postfixRecipientRestrictions) && $this->acl_is_writeable("postfixRecipientRestrictions")){
437 $img.= "<input type='image' src='images/lists/sort-down.png' name='RecipientRestrictDown_".$key."' class='center'> ";
438 }else{
439 $img.= "<img src='images/empty.png' style='width:10px;'>";
440 }
442 if($this->acl_is_writeable("postfixRecipientRestrictions")){
443 $img.= "<input type='image' src='images/lists/trash.png' name='RecipientRestrictDel_".$key."' class='center'> ";
444 }
445 $field1 = array("string"=> $entry['src']);
446 $field2 = array("string"=> $entry['dst']);
447 $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
448 $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
449 $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
450 }
451 $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList());
454 /* set new status */
455 if(isset($_POST['ExecAction'])){
456 if(isset($this->Actions[$_POST['action']])){
457 $this->setStatus($_POST['action']);
458 }
459 }
462 $smarty->assign("is_new", $this->dn);
463 $smarty->assign("is_acc", $this->initially_was_account);
464 $smarty->assign("TransportProtocols", $this->TransportProtocols);
465 $smarty->assign("Actions", $this->Actions);
466 $smarty->assign("RestrictionFilters", $this->RestrictionFilters);
467 $smarty->assign("postfixTransportTable" , $this->getTransports());
468 $smarty->assign("postfixSenderRestrictions" , $this->getSenderRestrictions());
469 $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions());
471 return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__))));
472 }
475 /* return transports formated for select box */
476 function getTransports()
477 {
478 $ret = array();
479 foreach($this->postfixTransportTable as $key => $vals){
480 $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst'];
481 }
482 return($ret);
483 }
486 /* return sender restriction formated for select box */
487 function getSenderRestrictions()
488 {
489 $ret = array();
490 foreach($this->postfixSenderRestrictions as $key => $vals){
491 $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
492 }
493 return($ret);
494 }
497 /* return recipient restriction formated for select box */
498 function getRecipientRestrictions()
499 {
500 $ret = array();
501 foreach($this->postfixRecipientRestrictions as $key => $vals){
502 $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
503 }
504 return($ret);
505 }
508 /* Return list entry */
509 function getListEntry()
510 {
511 $fields = goService::getListEntry();
512 $fields['Message'] = _("Mail smtp service (Postfix)");
513 #$fields['AllowEdit'] = true;
514 return($fields);
515 }
518 function save()
519 {
520 $this->postfixMyDomain = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname);
521 $this->postfixMyhostname = preg_replace("/\..*$/","",$this->postfixMyhostname);
523 plugin::save();
525 /* Fix transport table*/
526 $i = 0 ;
527 $this->attrs['postfixTransportTable'] = array();
528 foreach($this->postfixTransportTable as $key => $entry){
529 $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst'];
530 $i ++;
531 }
534 /* Fix sender restrictions */
535 $i = 0;
536 $this->attrs['postfixSenderRestrictions'] =array();
537 foreach($this->postfixSenderRestrictions as $key => $entry){
538 $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
539 $i ++;
540 }
543 /* Fix recipient restrictions */
544 $i = 0;
545 $this->attrs['postfixRecipientRestrictions'] =array();
546 foreach($this->postfixRecipientRestrictions as $key => $entry){
547 $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
548 $i ++;
549 }
552 /* Fix mydomains */
553 $this->attrs['postfixMyDestinations'] = array();
554 foreach($this->postfixMyDestinations as $entry){
555 $this->attrs['postfixMyDestinations'][] =$entry;
556 }
559 /* Fix mydomains */
560 if(count($this->postfixMyNetworks)){
561 $this->attrs['postfixMyNetworks'] = "";
562 foreach($this->postfixMyNetworks as $entry){
563 $this->attrs['postfixMyNetworks'] .=$entry.",";
564 }
565 $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']);
566 }else{
567 $this->attrs['postfixMyNetworks'] = array();
568 }
571 /* Check if this is a new entry ... add/modify */
572 $ldap = $this->config->get_ldap_link();
573 $ldap->cat($this->dn,array("objectClass"));
574 if($ldap->count()){
575 $ldap->cd($this->dn);
576 $ldap->modify($this->attrs);
577 }else{
578 $ldap->cd($this->dn);
579 $ldap->add($this->attrs);
580 }
581 if (!$ldap->success()){
582 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
583 }
585 if($this->initially_was_account){
586 $this->handle_post_events("modify");
587 new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
588 }else{
589 $this->handle_post_events("add");
590 new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
591 }
593 }
596 function check()
597 {
598 $message =plugin::check();
599 if(!is_numeric($this->postfixHeaderSizeLimit)){
600 $message[] = msgPool::invalid(_("Header size limit",$this->postfixHeaderSizeLimit,"/[0-9]/"));
601 }
602 if(!is_numeric($this->postfixMailboxSizeLimit)){
603 $message[] = msgPool::invalid(_("Mailbox size limit",$this->postfixMailboxSizeLimit,"/[0-9]/"));
604 }
605 if(!is_numeric($this->postfixMessageSizeLimit)){
606 $message[] = msgPool::invalid(_("Message size limit",$this->postfixMessageSizeLimit,"/[0-9]/"));
607 }
608 return $message;
609 }
612 /* Combine new array */
613 function combineArrays($ar0,$ar1,$ar2)
614 {
615 $ret = array();
616 if(is_array($ar0))
617 foreach($ar0 as $ar => $a){
618 $ret[]=$a;
619 }
620 if(is_array($ar1))
621 foreach($ar1 as $ar => $a){
622 $ret[]=$a;
623 }
624 if(is_array($ar2))
625 foreach($ar2 as $ar => $a){
626 $ret[]=$a;
627 }
628 return($ret);
629 }
632 function getpos($atr,$attrs)
633 {
634 $i = 0;
635 foreach($attrs as $attr => $name) {
636 $i++;
637 if($attr == $atr){
638 return($i);
639 }
640 }
642 return(-1);
643 }
646 /* TRansports the geiven Arraykey one position up*/
647 function ArrayUp($atr,$attrs)
648 {
649 $ret = $attrs;
650 $pos = $this->getpos($atr,$attrs) ;
651 $cn = count($attrs);
652 if(!(($pos == -1)||($pos == 1))){
653 $before = array_slice($attrs,0,($pos-2));
654 $mitte = array_reverse(array_slice($attrs,($pos-2),2));
655 $unten = array_slice($attrs,$pos);
656 $ret = array();
657 $ret = $this->combineArrays($before,$mitte,$unten);
658 }
659 return($ret);
660 }
663 /* TRansports the geiven Arraykey one position up*/
664 function ArrayDown($atr,$attrs)
665 {
666 $ret = $attrs;
667 $pos = $this->getpos($atr,$attrs) ;
668 $cn = count($attrs);
669 if(!(($pos == -1)||($pos == $cn))){
670 $before = array_slice($attrs,0,($pos-1));
671 $mitte = array_reverse(array_slice($attrs,($pos-1),2));
672 $unten = array_slice($attrs,($pos+1));
673 $ret = array();
674 $ret = $this->combineArrays($before,$mitte,$unten);
675 }
676 return($ret);
677 }
679 function save_object()
680 {
681 plugin::save_object();
682 }
685 function PrepareForCopyPaste($source)
686 {
687 plugin::PrepareForCopyPaste($source);
689 $source_o = new goMailServer($this->config,$source['dn']);
690 foreach(array("postfixMyDomain","postfixMyhostname","postfixMyNetworks","postfixTransportTable","postfixSenderRestrictions","postfixRecipientRestrictions","postfixMyDestinations") as $attr){
691 $this->$attr = $source_o->$attr;
692 }
693 }
696 /* Return plugin informations for acl handling */
697 static function plInfo()
698 {
699 return (array(
700 "plShortName" => _("Mail smtp (Postfix)"),
701 "plDescription" => _("Mail smtp - Postfix")." ("._("Services").")",
702 "plSelfModify" => FALSE,
703 "plDepends" => array(),
704 "plPriority" => 98,
705 "plSection" => array("administration"),
706 "plCategory" => array("server"),
708 "plProvidedAcls"=> array(
709 "postfixMyhostname" => _("Visible full qualified hostname"),
710 "description" => _("Description"),
711 "postfixHeaderSizeLimit" => _("Header size limit"),
712 "postfixMailboxSizeLimit" => _("Max mailbox size"),
713 "postfixMessageSizeLimit" => _("Max message size"),
714 "postfixMyDestinations" => _("Domains to accept mail for"),
715 "postfixMyNetworks" => _("Local networks"),
716 "postfixRelayhost" => _("Relay host"),
717 "postfixTransportTable" => _("Transport table"),
718 "postfixSenderRestrictions" => _("Restrictions for sender"),
719 "postfixRecipientRestrictions"=> _("Restrictions for recipient"))
720 ));
721 }
722 }
723 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
724 ?>