From 2d8d1591ce65f74306fd0e7e7b4b273db53b3a3b Mon Sep 17 00:00:00 2001 From: psc Date: Thu, 4 Jun 2009 09:07:35 +0000 Subject: [PATCH] - Make indices in FAIclasses numeric - Make getpos work properly with numeric indices - Don't show 'Move Up' link on first item and no 'Move Down' on last item. - Remove cobineArrays function, because its not needed anymore These changes fixes various behaviour problems with the Move Up/Down functionality. (Trac #2637) git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13694 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiProfile.inc | 98 +++++++++---------- 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/trunk/gosa-plugins/fai/admin/fai/class_faiProfile.inc b/trunk/gosa-plugins/fai/admin/fai/class_faiProfile.inc index d92e5178b..1faedc2f2 100644 --- a/trunk/gosa-plugins/fai/admin/fai/class_faiProfile.inc +++ b/trunk/gosa-plugins/fai/admin/fai/class_faiProfile.inc @@ -36,14 +36,15 @@ class faiProfile extends plugin $tmp2 = array(); foreach($tmp as $class){ if(!empty($class)){ - $tmp2[trim($class)] = trim($class); + $class = trim($class); + $tmp2[] = $class; } } /* Sort assigned classes */ if(is_array($tmp2)){ foreach($tmp2 as $class){ - $this->FAIclasses[$class]=$class; + $this->FAIclasses[]=$class; } } @@ -95,27 +96,6 @@ class faiProfile extends plugin $this->old_cn = $this->cn; } - - /* Combine new array, used for up down buttons */ - function combineArrays($ar0,$ar1,$ar2) - { - $ret = array(); - if(is_array($ar0)) - foreach($ar0 as $ar => $a){ - $ret[$ar]=$a; - } - if(is_array($ar1)) - foreach($ar1 as $ar => $a){ - $ret[$ar]=$a; - } - if(is_array($ar2)) - foreach($ar2 as $ar => $a){ - $ret[$ar]=$a; - } - return($ret); - } - - function acl_base_for_current_object($dn) { if($dn == "new" || $dn == ""){ @@ -133,46 +113,47 @@ class faiProfile extends plugin function getpos($atr,$attrs) { $i = 0; - foreach($attrs as $attr => $name) { - $i++; - if($attr == $atr){ + foreach($attrs as $value) { + if($atr == $value) { return($i); } + $i++; } - return(-1); } /* Transports the given Arraykey one position up*/ function ArrayUp($atr,$attrs) { - $ret = $attrs; - $pos = $this->getpos($atr,$attrs) ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == 1))){ - $before = array_slice($attrs,0,($pos-2)); - $mitte = array_reverse(array_slice($attrs,($pos-2),2)); - $unten = array_slice($attrs,$pos); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); + $index = $this->getpos($atr,$attrs); + $res = $attrs; + + for($i=0;$igetpos($atr,$attrs) ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == $cn))){ - $before = array_slice($attrs,0,($pos-1)); - $mitte = array_reverse(array_slice($attrs,($pos-1),2)); - $unten = array_slice($attrs,($pos+1)); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); + $index = $this->getpos($atr,$attrs); + $res = $attrs; + + for($i=0;$idialog->save(); foreach($ret as $class){ - $this->FAIclasses[$class] =$class; + $this->FAIclasses[] =$class; } $this->is_dialog=false; unset($this->dialog); @@ -300,12 +281,21 @@ class faiProfile extends plugin $actions = ""; /* Up down buttons */ - $linkupdown = " "; - $linkupdown.= ""; - + $linkup = "  "; + $linkdown = "  "; /* Append fai classes to divlist */ if($this->acl_is_readable("FAIclass")){ + $i = 1; foreach($this->FAIclasses as $usedClass){ + if($i==1) { + $linkupdown = "    " . $linkdown; + } elseif ($iFAIclasses)) { + $linkupdown = $linkup . $linkdown; + } + else { + $linkupdown = $linkup; + } + $str = " "; $act = ""; @@ -325,6 +315,7 @@ class faiProfile extends plugin $field3 = array("string"=>" ", "attach"=>"style='border-right:none;'"); } $divlist->AddEntry(array($field1,$field2,$field3)); + $i++; } } @@ -450,14 +441,15 @@ class faiProfile extends plugin $tmp2 = array(); foreach($tmp as $class){ if(!empty($class)){ - $tmp2[trim($class)] = trim($class); + $class = trim($class); + $tmp2[] = $class; } } /* Sort assigned classes */ if(is_array($tmp2)){ foreach($tmp2 as $class){ - $this->FAIclasses[$class]=$class; + $this->FAIclasses[]=$class; } } } -- 2.30.2