1 <?php
3 class goMailServer extends plugin{
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 = _("Postfix service");
47 $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
48 SERVICE_STARTED => SERVICE_STARTED,
49 SERVICE_RESETTED=>SERVICE_RESETTED,
50 "mailqueue"=>"mailqueue");
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 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 $this->postfixTransportTable = array();
111 if(isset($this->attrs['postfixTransportTable'])){
112 $tmp = array();
113 unset($this->attrs['postfixTransportTable']['count']);
114 foreach($this->attrs['postfixTransportTable'] as $entry){
115 $nr = preg_replace("/:.*$/","",$entry);
116 $rest= trim(preg_replace("/^[^:]+:/","",$entry));
117 $src = preg_replace("/ .*$/","",$rest);
118 $rest= preg_replace("/^[^ ]+ /","",$rest);
119 $dst = preg_replace("/^.*:/","",$rest);
120 $prt = preg_replace("/:.*$/","",$rest);
122 $tmp[$nr]['src'] = $src;
123 $tmp[$nr]['dst'] = $dst;
124 $tmp[$nr]['prt'] = $prt;
126 }
127 ksort($tmp);
128 foreach($tmp as $entry){
129 $this->postfixTransportTable[] = $entry;
130 }
131 }
134 /* Get sender restrictions */
135 $this->postfixSenderRestrictions = array();
136 if(isset($this->attrs['postfixSenderRestrictions'])){
137 unset($this->attrs['postfixSenderRestrictions']['count']);
138 foreach($this->attrs['postfixSenderRestrictions'] as $entry){
139 $nr = preg_replace("/:.*$/","",$entry);
140 $rest= trim(preg_replace("/^[^:]+:/","",$entry));
141 $src = preg_replace("/ .*$/","",$rest);
142 $rest= preg_replace("/^[^ ]+ /","",$rest);
143 $dst = preg_replace("/^.* /","",$rest);
144 $prt = preg_replace("/ .*$/","",$rest);
146 $tmp[$nr]['src'] = $src;
147 $tmp[$nr]['dst'] = $dst;
148 $tmp[$nr]['filter'] = $prt;
149 }
150 ksort($tmp);
151 foreach($tmp as $entry){
152 $this->postfixSenderRestrictions[] = $entry;
153 }
154 }
157 /* Get sender restrictions */
158 $this->postfixRecipientRestrictions = array();
159 if(isset($this->attrs['postfixRecipientRestrictions'])){
160 unset($this->attrs['postfixRecipientRestrictions']['count']);
161 foreach($this->attrs['postfixRecipientRestrictions'] as $entry){
162 $nr = preg_replace("/:.*$/","",$entry);
163 $rest= trim(preg_replace("/^[^:]+:/","",$entry));
164 $src = preg_replace("/ .*$/","",$rest);
165 $rest= preg_replace("/^[^ ]+ /","",$rest);
166 $dst = preg_replace("/^.* /","",$rest);
167 $prt = preg_replace("/ .*$/","",$rest);
169 $tmp[$nr]['src'] = $src;
170 $tmp[$nr]['dst'] = $dst;
171 $tmp[$nr]['filter'] = $prt;
172 }
173 ksort($tmp);
174 foreach($tmp as $entry){
175 $this->postfixRecipientRestrictions[] = $entry;
176 }
177 }
179 }
181 function execute()
182 {
183 $smarty = get_smarty();
184 $delAr = array( "TranslationDel_"=>"TranslationDel",
185 "SenderRestrictDel_"=>"SenderRestrictDel",
186 "RecipientRestrictDel_"=>"RecipientRestrictDel");
188 $once = true;
189 $s_action = "";
190 $s_entry = "";
192 /* Check posts for some intruductions */
193 foreach($_POST as $name => $value){
194 foreach($delAr as $preg => $type){
195 if((preg_match("/^".$preg."/",$name)) && ($once)){
196 $once = false;
197 $s_action = $type;
198 $s_entry = preg_replace("/^".$preg."/","",$name);
199 $s_entry = preg_replace("/_[xy]$/","",$s_entry);
200 }
201 }
204 if(preg_match("/^TranslationUp_/",$name) && $once){
205 $once = false;
206 $key = preg_replace("/^TranslationUp_/","",$name);
207 $key = preg_replace("/_[xy]$/","",$key);
208 $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ;
209 }
210 if(preg_match("/^TranslationDown_/",$name) && $once){
211 $once = false;
212 $key = preg_replace("/^TranslationDown_/","",$name);
213 $key = preg_replace("/_[xy]$/","",$key);
214 $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ;
215 }
216 if(preg_match("/^SenderRestrictUp_/",$name) && $once){
217 $once = false;
218 $key = preg_replace("/^SenderRestrictUp_/","",$name);
219 $key = preg_replace("/_[xy]$/","",$key);
220 $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ;
221 }
222 if(preg_match("/^SenderRestrictDown_/",$name) && $once){
223 $once = false;
224 $key = preg_replace("/^SenderRestrictDown_/","",$name);
225 $key = preg_replace("/_[xy]$/","",$key);
226 $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ;
227 }
228 if(preg_match("/^RecipientRestrictUp_/",$name) && $once){
229 $once = false;
230 $key = preg_replace("/^RecipientRestrictUp_/","",$name);
231 $key = preg_replace("/_[xy]$/","",$key);
232 $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ;
233 }
234 if(preg_match("/^RecipientRestrictDown_/",$name) && $once){
235 $once = false;
236 $key = preg_replace("/^RecipientRestrictDown_/","",$name);
237 $key = preg_replace("/_[xy]$/","",$key);
238 $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ;
239 }
240 }
243 /* Add delete my network entry */
244 if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){
245 $str = $_POST['NewString_postfixMyNetworks'];
246 $this->postfixMyNetworks[base64_encode($str)] = $str;
247 }
249 if((isset($_POST['DelpostfixMyNetworks'])) && (count($_POST['Select_postfixMyNetworks']))){
250 foreach($_POST['Select_postfixMyNetworks'] as $str ){
251 unset($this->postfixMyNetworks[$str]);
252 }
253 }
256 /* Add delete my domain entry */
257 if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){
258 $str = $_POST['NewString_postfixMyDestinations'];
259 $this->postfixMyDestinations[base64_encode($str)] = $str;
260 }
262 if((isset($_POST['DelpostfixMyDestinations'])) && (count($_POST['Select_postfixMyDestinations']))){
263 foreach($_POST['Select_postfixMyDestinations'] as $str ){
264 unset($this->postfixMyDestinations[$str]);
265 }
266 }
269 /* Add sender restriction */
270 if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){
271 unset($this->postfixSenderRestrictions[$s_entry]);
272 }
274 if(isset($_POST['AddpostfixSenderRestrictions'])){
275 $src = $_POST['Source_postfixSenderRestrictions'];
276 $dst = $_POST['Destination_postfixSenderRestrictions'];
277 $Filter = $_POST['SenderRestrictionFilter'];
278 $tmp['src'] = $src;
279 $tmp['dst'] = $dst;
280 $tmp['filter'] = $Filter;
281 $this->postfixSenderRestrictions[] = $tmp;
282 }
285 /* Add sender restriction */
286 if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){
287 unset($this->postfixRecipientRestrictions[$s_entry]);
288 }
290 if(isset($_POST['AddpostfixRecipientRestrictions'])){
291 $src = $_POST['Source_postfixRecipientRestrictions'];
292 $dst = $_POST['Destination_postfixRecipientRestrictions'];
293 $Filter = $_POST['RecipientRestrictionFilter'];
294 $tmp['src'] = $src;
295 $tmp['dst'] = $dst;
296 $tmp['filter'] = $Filter;
297 $this->postfixRecipientRestrictions[] = $tmp;
298 }
301 /* Handle transports */
302 if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){
303 unset($this->postfixTransportTable[$s_entry]);
304 }
306 if(isset($_POST['AddpostfixTransportTable'])){
307 $src = trim($_POST['Source_postfixTransportTable']);
308 $dst = trim($_POST['Destination_postfixTransportTable']);
309 $prt = trim($_POST['TransportProtocol']);
311 if((!empty($src)) && (!empty($dst))){
312 if(preg_match("/:/",$dst)){
313 $tmp = split("\:",$dst);
314 $port = trim($tmp[1]);
315 $ip = trim($tmp[0]);
317 if((is_ip($ip)) && (is_numeric($port))){
318 $dst = "[".$ip."]:".$port;
319 }
320 }
321 if(is_ip($dst)){
322 $dst = "[".$dst."]";
323 }
324 $tmp2 ['src'] = $src;
325 $tmp2 ['dst'] = $dst;
326 $tmp2 ['prt'] = $prt;
328 $this->postfixTransportTable[] = $tmp2;
329 }
330 }
333 /* Set attributes */
334 foreach($this->attributes as $attr){
335 $smarty->assign($attr,$this->$attr);
336 }
339 /* Create divList for translation tables */
340 $divTranslation = new divSelectBox("TransportProtocols");
341 $divTranslation->SetHeight(110);
342 foreach($this->postfixTransportTable as $key => $entry){
343 $img = "";
345 if($key != 0){
346 $img.= "<input type='image' src='images/sort_up.png' name='TranslationUp_".$key."' class='center'> ";
347 }else{
348 $img.= "<img src='images/empty.png' style='width:10px;'>";
349 }
350 if(($key+1) < count($this->postfixTransportTable)){
351 $img.= "<input type='image' src='images/sort_down.png' name='TranslationDown_".$key."' class='center'> ";
352 }else{
353 $img.= "<img src='images/empty.png' style='width:10px;'>";
354 }
356 $img.= "<input type='image' src='images/edittrash.png' name='TranslationDel_".$key."' class='center'> ";
357 $field1 = array("string"=> $entry['src']);
358 $field2 = array("string"=> $entry['dst']);
359 $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'");
360 $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
361 $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,));
362 }
363 $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList());
366 /* Create divList for sender restrictions */
367 $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions");
368 $DivSenderRestrict->SetHeight(110);
369 foreach($this->postfixSenderRestrictions as $key => $entry){
370 $img ="";
372 if($key != 0){
373 $img.= "<input type='image' src='images/sort_up.png' name='SenderRestrictUp_".$key."' class='center'> ";
374 }else{
375 $img.= "<img src='images/empty.png' style='width:10px;'>";
376 }
377 if(($key+1) < count($this->postfixSenderRestrictions)){
378 $img.= "<input type='image' src='images/sort_down.png' name='SenderRestrictDown_".$key."' class='center'> ";
379 }else{
380 $img.= "<img src='images/empty.png' style='width:10px;'>";
381 }
383 $img.= "<input type='image' src='images/edittrash.png' name='SenderRestrictDel_".$key."' class='center'> ";
385 $field1 = array("string"=> $entry['src']);
386 $field2 = array("string"=> $entry['dst']);
387 $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
388 $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
389 $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
390 }
391 $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList());
394 /* Create divList for translation tables */
395 $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions");
396 $DivRecipientRestrict->SetHeight(110);
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'> ";
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'> ";
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'> ";
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());
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("TransportProtocols", $this->TransportProtocols);
429 $smarty->assign("Actions", $this->Actions);
430 $smarty->assign("RestrictionFilters", $this->RestrictionFilters);
431 $smarty->assign("postfixTransportTable" , $this->getTransports());
432 $smarty->assign("postfixSenderRestrictions" , $this->getSenderRestrictions());
433 $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions());
435 return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__))));
436 }
439 /* return transports formated for select box */
440 function getTransports()
441 {
442 $ret = array();
443 foreach($this->postfixTransportTable as $key => $vals){
444 $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst'];
445 }
446 return($ret);
447 }
450 /* return sender restriction formated for select box */
451 function getSenderRestrictions()
452 {
453 $ret = array();
454 foreach($this->postfixSenderRestrictions as $key => $vals){
455 $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
456 }
457 return($ret);
458 }
461 /* return recipient restriction formated for select box */
462 function getRecipientRestrictions()
463 {
464 $ret = array();
465 foreach($this->postfixRecipientRestrictions as $key => $vals){
466 $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
467 }
468 return($ret);
469 }
472 /* Return list entry */
473 function getListEntry()
474 {
475 $flag = $this->StatusFlag;
476 $fields['Status'] = $this->$flag;
477 $fields['Message'] = _("Postfix"). " - ".$this->postfixMyhostname;
478 $fields['AllowStart'] = true;
479 $fields['AllowStop'] = true;
480 $fields['AllowReset'] = true;
481 $fields['AllowRemove']= true;
482 $fields['AllowEdit'] = true;
483 return($fields);
484 }
487 function remove_from_parent()
488 {
489 plugin::remove_from_parent();
490 /* Check if this is a new entry ... add/modify */
491 $ldap = $this->config->get_ldap_link();
492 $ldap->cat($this->dn,array("objectClass"));
493 if($ldap->count()){
494 $ldap->cd($this->dn);
495 $ldap->modify($this->attrs);
496 }else{
497 $ldap->cd($this->dn);
498 $ldap->add($this->attrs);
499 }
500 show_ldap_error($ldap->get_error());
501 }
504 function save()
505 {
506 plugin::save();
508 /* Fix transport table*/
509 $i = 0 ;
510 $this->attrs['postfixTransportTable'] = array();
511 foreach($this->postfixTransportTable as $key => $entry){
512 $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst'];
513 $i ++;
514 }
517 /* Fix sender restrictions */
518 $i = 0;
519 $this->attrs['postfixSenderRestrictions'] =array();
520 foreach($this->postfixSenderRestrictions as $key => $entry){
521 $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
522 $i ++;
523 }
526 /* Fix recipient restrictions */
527 $i = 0;
528 $this->attrs['postfixRecipientRestrictions'] =array();
529 foreach($this->postfixRecipientRestrictions as $key => $entry){
530 $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
531 $i ++;
532 }
535 /* Fix mydomains */
536 $this->attrs['postfixMyDestinations'] = array();
537 foreach($this->postfixMyDestinations as $entry){
538 $this->attrs['postfixMyDestinations'][] =$entry;
539 }
542 /* Fix mydomains */
543 if(count($this->postfixMyNetworks)){
544 $this->attrs['postfixMyNetworks'] = "";
545 foreach($this->postfixMyNetworks as $entry){
546 $this->attrs['postfixMyNetworks'] .=$entry.",";
547 }
548 }else{
549 $this->attrs['postfixMyNetworks'] = array();
550 }
552 $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']);
554 $this->attrs['postfixMyhostname'] = preg_replace("/\..*$/","",$this->postfixMyhostname);
555 $this->attrs['postfixMyDomain'] = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname);
557 /* Check if this is a new entry ... add/modify */
558 $ldap = $this->config->get_ldap_link();
559 $ldap->cat($this->dn,array("objectClass"));
560 if($ldap->count()){
561 $ldap->cd($this->dn);
562 $ldap->modify($this->attrs);
563 }else{
564 $ldap->cd($this->dn);
565 $ldap->add($this->attrs);
566 }
567 show_ldap_error($ldap->get_error());
568 }
571 /* Directly save new status flag */
572 function setStatus($value)
573 {
574 $ldap = $this->config->get_ldap_link();
575 $ldap->cd($this->dn);
576 $ldap->cat($this->dn,array("objectClass"));
578 if($ldap->count()){
580 $attrs =array();
581 $tmp = $ldap->fetch();
582 for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
583 $attrs['objectClass'][] = $tmp['objectClass'][$i];
584 }
585 if(!in_array("goMailServer",$attrs['objectClass'])){
586 $attrs['objectClass'][] = "goMailServer";
587 }
589 $flag = $this->StatusFlag;
590 $attrs[$flag] = $value;
591 $this->$flag = $value;
592 $ldap->modify($attrs);
593 show_ldap_error($ldap->get_error());
594 }
595 }
598 function check()
599 {
600 $message =plugin::check();
602 if(!is_numeric($this->postfixHeaderSizeLimit)){
603 $message[] = _("Please specify a numeric value for header size limit.");
604 }
606 if(!is_numeric($this->postfixMailboxSizeLimit)){
607 $message[] = _("Please specify a numeric value for mailbox size limit.");
608 }
610 if(!is_numeric($this->postfixMessageSizeLimit)){
611 $message[] = _("Please specify a numeric value for message size limit.");
612 }
614 return $message;
615 }
618 /* Combine new array */
619 function combineArrays($ar0,$ar1,$ar2)
620 {
621 $ret = array();
622 if(is_array($ar0))
623 foreach($ar0 as $ar => $a){
624 $ret[]=$a;
625 }
626 if(is_array($ar1))
627 foreach($ar1 as $ar => $a){
628 $ret[]=$a;
629 }
630 if(is_array($ar2))
631 foreach($ar2 as $ar => $a){
632 $ret[]=$a;
633 }
634 return($ret);
635 }
638 function getpos($atr,$attrs)
639 {
640 $i = 0;
641 foreach($attrs as $attr => $name) {
642 $i++;
643 if($attr == $atr){
644 return($i);
645 }
646 }
648 return(-1);
649 }
652 /* TRansports the geiven Arraykey one position up*/
653 function ArrayUp($atr,$attrs)
654 {
655 $ret = $attrs;
656 $pos = $this->getpos($atr,$attrs) ;
657 $cn = count($attrs);
658 if(!(($pos == -1)||($pos == 1))){
659 $before = array_slice($attrs,0,($pos-2));
660 $mitte = array_reverse(array_slice($attrs,($pos-2),2));
661 $unten = array_slice($attrs,$pos);
662 $ret = array();
663 $ret = $this->combineArrays($before,$mitte,$unten);
664 }
665 return($ret);
666 }
669 /* TRansports the geiven Arraykey one position up*/
670 function ArrayDown($atr,$attrs)
671 {
672 $ret = $attrs;
673 $pos = $this->getpos($atr,$attrs) ;
674 $cn = count($attrs);
675 if(!(($pos == -1)||($pos == $cn))){
676 $before = array_slice($attrs,0,($pos-1));
677 $mitte = array_reverse(array_slice($attrs,($pos-1),2));
678 $unten = array_slice($attrs,($pos+1));
679 $ret = array();
680 $ret = $this->combineArrays($before,$mitte,$unten);
681 }
682 return($ret);
683 }
686 function save_object()
687 {
688 plugin::save_object();
689 }
690 }
691 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
692 ?>