d6ae1a90327e62e2f04e4aebae6bbd890a217556
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 $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 }
79 /* Get postfix my networks */
80 $this->postfixMyNetworks = array();
81 if(isset($this->attrs['postfixMyNetworks'][0])){
82 $tmp = split(",",$this->attrs['postfixMyNetworks'][0]);
83 foreach($tmp as $str){
84 if(!empty($str)){
85 $this->postfixMyNetworks[base64_encode($str)] = $str;
86 }
87 }
88 }
91 /* Create full name */
92 if(isset($this->attrs['postfixMyDomain'][0])){
93 $this->postfixMyhostname .= ".".$this->attrs['postfixMyDomain'][0];
94 }
97 /* Get postfix my domains */
98 $this->postfixMyDestinations = array();
99 if(isset($this->attrs['postfixMyDestinations'][0])){
100 unset($this->attrs['postfixMyDestinations']['count']);
101 foreach($this->attrs['postfixMyDestinations'] as $str){
102 $this->postfixMyDestinations[base64_encode($str)] = $str;
103 }
104 }
107 /* Get transport tables */
108 $this->postfixTransportTable = array();
109 if(isset($this->attrs['postfixTransportTable'])){
110 $tmp = array();
111 unset($this->attrs['postfixTransportTable']['count']);
112 foreach($this->attrs['postfixTransportTable'] as $entry){
113 $nr = preg_replace("/:.*$/","",$entry);
114 $rest= trim(preg_replace("/^[^:]+:/","",$entry));
115 $src = preg_replace("/ .*$/","",$rest);
116 $rest= preg_replace("/^[^ ]+ /","",$rest);
117 $dst = preg_replace("/^.*:/","",$rest);
118 $prt = preg_replace("/:.*$/","",$rest);
120 $tmp[$nr]['src'] = $src;
121 $tmp[$nr]['dst'] = $dst;
122 $tmp[$nr]['prt'] = $prt;
124 }
125 ksort($tmp);
126 foreach($tmp as $entry){
127 $this->postfixTransportTable[] = $entry;
128 }
129 }
132 /* Get sender restrictions */
133 $this->postfixSenderRestrictions = array();
134 if(isset($this->attrs['postfixSenderRestrictions'])){
135 unset($this->attrs['postfixSenderRestrictions']['count']);
136 foreach($this->attrs['postfixSenderRestrictions'] as $entry){
137 $nr = preg_replace("/:.*$/","",$entry);
138 $rest= trim(preg_replace("/^[^:]+:/","",$entry));
139 $src = preg_replace("/ .*$/","",$rest);
140 $rest= preg_replace("/^[^ ]+ /","",$rest);
141 $dst = preg_replace("/^.* /","",$rest);
142 $prt = preg_replace("/ .*$/","",$rest);
144 $tmp[$nr]['src'] = $src;
145 $tmp[$nr]['dst'] = $dst;
146 $tmp[$nr]['filter'] = $prt;
147 }
148 ksort($tmp);
149 foreach($tmp as $entry){
150 $this->postfixSenderRestrictions[] = $entry;
151 }
152 }
155 /* Get sender restrictions */
156 $this->postfixRecipientRestrictions = array();
157 if(isset($this->attrs['postfixRecipientRestrictions'])){
158 unset($this->attrs['postfixRecipientRestrictions']['count']);
159 foreach($this->attrs['postfixRecipientRestrictions'] as $entry){
160 $nr = preg_replace("/:.*$/","",$entry);
161 $rest= trim(preg_replace("/^[^:]+:/","",$entry));
162 $src = preg_replace("/ .*$/","",$rest);
163 $rest= preg_replace("/^[^ ]+ /","",$rest);
164 $dst = preg_replace("/^.* /","",$rest);
165 $prt = preg_replace("/ .*$/","",$rest);
167 $tmp[$nr]['src'] = $src;
168 $tmp[$nr]['dst'] = $dst;
169 $tmp[$nr]['filter'] = $prt;
170 }
171 ksort($tmp);
172 foreach($tmp as $entry){
173 $this->postfixRecipientRestrictions[] = $entry;
174 }
175 }
177 }
179 function execute()
180 {
181 $smarty = get_smarty();
182 $delAr = array( "TranslationDel_"=>"TranslationDel",
183 "SenderRestrictDel_"=>"SenderRestrictDel",
184 "RecipientRestrictDel_"=>"RecipientRestrictDel");
186 $once = true;
187 $s_action = "";
188 $s_entry = "";
190 /* Check posts for some intruductions */
191 foreach($_POST as $name => $value){
192 foreach($delAr as $preg => $type){
193 if((preg_match("/^".$preg."/",$name)) && ($once)){
194 $once = false;
195 $s_action = $type;
196 $s_entry = preg_replace("/^".$preg."/","",$name);
197 $s_entry = preg_replace("/_[xy]$/","",$s_entry);
198 }
199 }
202 if(preg_match("/^TranslationUp_/",$name) && $once){
203 $once = false;
204 $key = preg_replace("/^TranslationUp_/","",$name);
205 $key = preg_replace("/_[xy]$/","",$key);
206 $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ;
207 }
208 if(preg_match("/^TranslationDown_/",$name) && $once){
209 $once = false;
210 $key = preg_replace("/^TranslationDown_/","",$name);
211 $key = preg_replace("/_[xy]$/","",$key);
212 $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ;
213 }
214 if(preg_match("/^SenderRestrictUp_/",$name) && $once){
215 $once = false;
216 $key = preg_replace("/^SenderRestrictUp_/","",$name);
217 $key = preg_replace("/_[xy]$/","",$key);
218 $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ;
219 }
220 if(preg_match("/^SenderRestrictDown_/",$name) && $once){
221 $once = false;
222 $key = preg_replace("/^SenderRestrictDown_/","",$name);
223 $key = preg_replace("/_[xy]$/","",$key);
224 $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ;
225 }
226 if(preg_match("/^RecipientRestrictUp_/",$name) && $once){
227 $once = false;
228 $key = preg_replace("/^RecipientRestrictUp_/","",$name);
229 $key = preg_replace("/_[xy]$/","",$key);
230 $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ;
231 }
232 if(preg_match("/^RecipientRestrictDown_/",$name) && $once){
233 $once = false;
234 $key = preg_replace("/^RecipientRestrictDown_/","",$name);
235 $key = preg_replace("/_[xy]$/","",$key);
236 $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ;
237 }
238 }
241 /* Add delete my network entry */
242 if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){
243 $str = $_POST['NewString_postfixMyNetworks'];
244 $this->postfixMyNetworks[base64_encode($str)] = $str;
245 }
247 if((isset($_POST['DelpostfixMyNetworks'])) && (count($_POST['Select_postfixMyNetworks']))){
248 foreach($_POST['Select_postfixMyNetworks'] as $str ){
249 unset($this->postfixMyNetworks[$str]);
250 }
251 }
254 /* Add delete my domain entry */
255 if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){
256 $str = $_POST['NewString_postfixMyDestinations'];
257 $this->postfixMyDestinations[base64_encode($str)] = $str;
258 }
260 if((isset($_POST['DelpostfixMyDestinations'])) && (count($_POST['Select_postfixMyDestinations']))){
261 foreach($_POST['Select_postfixMyDestinations'] as $str ){
262 unset($this->postfixMyDestinations[$str]);
263 }
264 }
267 /* Add sender restriction */
268 if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){
269 unset($this->postfixSenderRestrictions[$s_entry]);
270 }
272 if(isset($_POST['AddpostfixSenderRestrictions'])){
273 $src = $_POST['Source_postfixSenderRestrictions'];
274 $dst = $_POST['Destination_postfixSenderRestrictions'];
275 $Filter = $_POST['SenderRestrictionFilter'];
276 $tmp['src'] = $src;
277 $tmp['dst'] = $dst;
278 $tmp['filter'] = $Filter;
279 $this->postfixSenderRestrictions[] = $tmp;
280 }
283 /* Add sender restriction */
284 if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){
285 unset($this->postfixRecipientRestrictions[$s_entry]);
286 }
288 if(isset($_POST['AddpostfixRecipientRestrictions'])){
289 $src = $_POST['Source_postfixRecipientRestrictions'];
290 $dst = $_POST['Destination_postfixRecipientRestrictions'];
291 $Filter = $_POST['RecipientRestrictionFilter'];
292 $tmp['src'] = $src;
293 $tmp['dst'] = $dst;
294 $tmp['filter'] = $Filter;
295 $this->postfixRecipientRestrictions[] = $tmp;
296 }
299 /* Handle transports */
300 if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){
301 unset($this->postfixTransportTable[$s_entry]);
302 }
304 if(isset($_POST['AddpostfixTransportTable'])){
305 $src = trim($_POST['Source_postfixTransportTable']);
306 $dst = trim($_POST['Destination_postfixTransportTable']);
307 $prt = trim($_POST['TransportProtocol']);
309 if((!empty($src)) && (!empty($dst))){
310 if(preg_match("/:/",$dst)){
311 $tmp = split("\:",$dst);
312 $port = trim($tmp[1]);
313 $ip = trim($tmp[0]);
315 if((is_ip($ip)) && (is_numeric($port))){
316 $dst = "[".$ip."]:".$port;
317 }
318 }
319 if(is_ip($dst)){
320 $dst = "[".$dst."]";
321 }
322 $tmp2 ['src'] = $src;
323 $tmp2 ['dst'] = $dst;
324 $tmp2 ['prt'] = $prt;
326 $this->postfixTransportTable[] = $tmp2;
327 }
328 }
331 /* Set attributes */
332 foreach($this->attributes as $attr){
333 $smarty->assign($attr,$this->$attr);
334 }
337 /* Create divList for translation tables */
338 $divTranslation = new divSelectBox("TransportProtocols");
339 $divTranslation->SetHeight(110);
340 foreach($this->postfixTransportTable as $key => $entry){
341 $img = "";
343 if($key != 0){
344 $img.= "<input type='image' src='images/sort_up.png' name='TranslationUp_".$key."' class='center'> ";
345 }else{
346 $img.= "<img src='images/empty.png' style='width:10px;'>";
347 }
348 if(($key+1) < count($this->postfixTransportTable)){
349 $img.= "<input type='image' src='images/sort_down.png' name='TranslationDown_".$key."' class='center'> ";
350 }else{
351 $img.= "<img src='images/empty.png' style='width:10px;'>";
352 }
354 $img.= "<input type='image' src='images/edittrash.png' name='TranslationDel_".$key."' class='center'> ";
355 $field1 = array("string"=> $entry['src']);
356 $field2 = array("string"=> $entry['dst']);
357 $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'");
358 $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
359 $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,));
360 }
361 $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList());
364 /* Create divList for sender restrictions */
365 $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions");
366 $DivSenderRestrict->SetHeight(110);
367 foreach($this->postfixSenderRestrictions as $key => $entry){
368 $img ="";
370 if($key != 0){
371 $img.= "<input type='image' src='images/sort_up.png' name='SenderRestrictUp_".$key."' class='center'> ";
372 }else{
373 $img.= "<img src='images/empty.png' style='width:10px;'>";
374 }
375 if(($key+1) < count($this->postfixSenderRestrictions)){
376 $img.= "<input type='image' src='images/sort_down.png' name='SenderRestrictDown_".$key."' class='center'> ";
377 }else{
378 $img.= "<img src='images/empty.png' style='width:10px;'>";
379 }
381 $img.= "<input type='image' src='images/edittrash.png' name='SenderRestrictDel_".$key."' class='center'> ";
383 $field1 = array("string"=> $entry['src']);
384 $field2 = array("string"=> $entry['dst']);
385 $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
386 $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
387 $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
388 }
389 $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList());
392 /* Create divList for translation tables */
393 $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions");
394 $DivRecipientRestrict->SetHeight(110);
395 foreach($this->postfixRecipientRestrictions as $key => $entry){
396 $img = "";
397 if($key != 0){
398 $img.= "<input type='image' src='images/sort_up.png' name='RecipientRestrictUp_".$key."' class='center'> ";
399 }else{
400 $img.= "<img src='images/empty.png' style='width:10px;'>";
401 }
402 if(($key+1) < count($this->postfixRecipientRestrictions)){
403 $img.= "<input type='image' src='images/sort_down.png' name='RecipientRestrictDown_".$key."' class='center'> ";
404 }else{
405 $img.= "<img src='images/empty.png' style='width:10px;'>";
406 }
407 $img.= "<input type='image' src='images/edittrash.png' name='RecipientRestrictDel_".$key."' class='center'> ";
408 $field1 = array("string"=> $entry['src']);
409 $field2 = array("string"=> $entry['dst']);
410 $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
411 $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
412 $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
413 }
414 $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList());
417 /* set new status */
418 if(isset($_POST['ExecAction'])){
419 if(isset($this->Actions[$_POST['action']])){
420 $this->setStatus($_POST['action']);
421 }
422 }
425 $smarty->assign("is_new", $this->dn);
426 $smarty->assign("TransportProtocols", $this->TransportProtocols);
427 $smarty->assign("Actions", $this->Actions);
428 $smarty->assign("RestrictionFilters", $this->RestrictionFilters);
429 $smarty->assign("postfixTransportTable" , $this->getTransports());
430 $smarty->assign("postfixSenderRestrictions" , $this->getSenderRestrictions());
431 $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions());
433 return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__))));
434 }
437 /* return transports formated for select box */
438 function getTransports()
439 {
440 $ret = array();
441 foreach($this->postfixTransportTable as $key => $vals){
442 $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst'];
443 }
444 return($ret);
445 }
448 /* return sender restriction formated for select box */
449 function getSenderRestrictions()
450 {
451 $ret = array();
452 foreach($this->postfixSenderRestrictions as $key => $vals){
453 $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
454 }
455 return($ret);
456 }
459 /* return recipient restriction formated for select box */
460 function getRecipientRestrictions()
461 {
462 $ret = array();
463 foreach($this->postfixRecipientRestrictions as $key => $vals){
464 $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
465 }
466 return($ret);
467 }
470 /* Return list entry */
471 function getListEntry()
472 {
473 $flag = $this->StatusFlag;
474 $fields['Status'] = $this->$flag;
475 $fields['Message'] = _("Postfix"). " - ".$this->postfixMyhostname;
476 $fields['AllowStart'] = true;
477 $fields['AllowStop'] = true;
478 $fields['AllowReset'] = true;
479 $fields['AllowRemove']= true;
480 $fields['AllowEdit'] = true;
481 return($fields);
482 }
485 function remove_from_parent()
486 {
487 plugin::remove_from_parent();
488 /* Check if this is a new entry ... add/modify */
489 $ldap = $this->config->get_ldap_link();
490 $ldap->cat($this->dn,array("objectClass"));
491 if($ldap->count()){
492 $ldap->cd($this->dn);
493 $ldap->modify($this->attrs);
494 }else{
495 $ldap->cd($this->dn);
496 $ldap->add($this->attrs);
497 }
498 show_ldap_error($ldap->get_error());
499 }
502 function save()
503 {
504 plugin::save();
506 /* Fix transport table*/
507 $i = 0 ;
508 $this->attrs['postfixTransportTable'] = array();
509 foreach($this->postfixTransportTable as $key => $entry){
510 $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst'];
511 $i ++;
512 }
515 /* Fix sender restrictions */
516 $i = 0;
517 $this->attrs['postfixSenderRestrictions'] =array();
518 foreach($this->postfixSenderRestrictions as $key => $entry){
519 $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
520 $i ++;
521 }
524 /* Fix recipient restrictions */
525 $i = 0;
526 $this->attrs['postfixRecipientRestrictions'] =array();
527 foreach($this->postfixRecipientRestrictions as $key => $entry){
528 $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
529 $i ++;
530 }
533 /* Fix mydomains */
534 $this->attrs['postfixMyDestinations'] = array();
535 foreach($this->postfixMyDestinations as $entry){
536 $this->attrs['postfixMyDestinations'][] =$entry;
537 }
540 /* Fix mydomains */
541 if(count($this->postfixMyNetworks)){
542 $this->attrs['postfixMyNetworks'] = "";
543 foreach($this->postfixMyNetworks as $entry){
544 $this->attrs['postfixMyNetworks'] .=$entry.",";
545 }
546 }else{
547 $this->attrs['postfixMyNetworks'] = array();
548 }
550 $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']);
552 $this->attrs['postfixMyhostname'] = preg_replace("/\..*$/","",$this->postfixMyhostname);
553 $this->attrs['postfixMyDomain'] = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname);
555 /* Check if this is a new entry ... add/modify */
556 $ldap = $this->config->get_ldap_link();
557 $ldap->cat($this->dn,array("objectClass"));
558 if($ldap->count()){
559 $ldap->cd($this->dn);
560 $ldap->modify($this->attrs);
561 }else{
562 $ldap->cd($this->dn);
563 $ldap->add($this->attrs);
564 }
565 show_ldap_error($ldap->get_error());
566 }
569 /* Directly save new status flag */
570 function setStatus($value)
571 {
572 $ldap = $this->config->get_ldap_link();
573 $ldap->cd($this->dn);
574 $ldap->cat($this->dn,array("objectClass"));
576 if($ldap->count()){
578 $attrs =array();
579 $tmp = $ldap->fetch();
580 for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
581 $attrs['objectClass'][] = $tmp['objectClass'][$i];
582 }
583 if(!in_array("goMailServer",$attrs['objectClass'])){
584 $attrs['objectClass'][] = "goMailServer";
585 }
587 $flag = $this->StatusFlag;
588 $attrs[$flag] = $value;
589 $this->$flag = $value;
590 $ldap->modify($attrs);
591 show_ldap_error($ldap->get_error());
592 }
593 }
596 function check()
597 {
598 $message =plugin::check();
600 if(!is_numeric($this->postfixHeaderSizeLimit)){
601 $message[] = _("Please specify a numeric value for header size limit.");
602 }
604 if(!is_numeric($this->postfixMailboxSizeLimit)){
605 $message[] = _("Please specify a numeric value for mailbox size limit.");
606 }
608 if(!is_numeric($this->postfixMessageSizeLimit)){
609 $message[] = _("Please specify a numeric value for message size limit.");
610 }
612 return $message;
613 }
616 /* Combine new array */
617 function combineArrays($ar0,$ar1,$ar2)
618 {
619 $ret = array();
620 if(is_array($ar0))
621 foreach($ar0 as $ar => $a){
622 $ret[]=$a;
623 }
624 if(is_array($ar1))
625 foreach($ar1 as $ar => $a){
626 $ret[]=$a;
627 }
628 if(is_array($ar2))
629 foreach($ar2 as $ar => $a){
630 $ret[]=$a;
631 }
632 return($ret);
633 }
636 function getpos($atr,$attrs)
637 {
638 $i = 0;
639 foreach($attrs as $attr => $name) {
640 $i++;
641 if($attr == $atr){
642 return($i);
643 }
644 }
646 return(-1);
647 }
650 /* TRansports the geiven Arraykey one position up*/
651 function ArrayUp($atr,$attrs)
652 {
653 $ret = $attrs;
654 $pos = $this->getpos($atr,$attrs) ;
655 $cn = count($attrs);
656 if(!(($pos == -1)||($pos == 1))){
657 $before = array_slice($attrs,0,($pos-2));
658 $mitte = array_reverse(array_slice($attrs,($pos-2),2));
659 $unten = array_slice($attrs,$pos);
660 $ret = array();
661 $ret = $this->combineArrays($before,$mitte,$unten);
662 }
663 return($ret);
664 }
667 /* TRansports the geiven Arraykey one position up*/
668 function ArrayDown($atr,$attrs)
669 {
670 $ret = $attrs;
671 $pos = $this->getpos($atr,$attrs) ;
672 $cn = count($attrs);
673 if(!(($pos == -1)||($pos == $cn))){
674 $before = array_slice($attrs,0,($pos-1));
675 $mitte = array_reverse(array_slice($attrs,($pos-1),2));
676 $unten = array_slice($attrs,($pos+1));
677 $ret = array();
678 $ret = $this->combineArrays($before,$mitte,$unten);
679 }
680 return($ret);
681 }
684 function save_object()
685 {
686 plugin::save_object();
687 }
688 }
689 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
690 ?>