From: hickert Date: Wed, 21 Dec 2005 13:23:09 +0000 (+0000) Subject: Added up down button X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ae9405a8ed189bd873dc6afd3d33fd4a57bce4fb;p=gosa.git Added up down button git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2365 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/fai/class_faiProfile.inc b/plugins/admin/fai/class_faiProfile.inc index 15f2ff7db..ff2b4923f 100644 --- a/plugins/admin/fai/class_faiProfile.inc +++ b/plugins/admin/fai/class_faiProfile.inc @@ -37,19 +37,33 @@ class faiProfile extends plugin $ldap=$this->config->get_ldap_link(); $tmp = split(" ",$this->FAIclass); - + $tmp3 = $tmp2 = array(); foreach($tmp as $class){ if(!empty($class)){ - $this->FAIclasses[trim($class)] = trim($class); + if(preg_match("/|/",$class)){ + $o = split("\|",$class); + $tmp3[$o[1]] = trim($o[0]); + }else{ + $tmp2[trim($class)] = trim($class); + } + } + } + $this->FAIclasses = array(); + ksort($tmp3); + if(is_array($tmp3)){ + foreach($tmp3 as $class){ + $this->FAIclasses[$class]=$class; } } - natcasesort($this->FAIclasses); - reset($this->FAIclasses) ; - + + if(is_array($tmp2)){ + foreach($tmp2 as $class){ + $this->FAIclasses[$class]=$class; + } + } + $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTAble","FAIpackage"); - $sort = array(); - $base = $_SESSION['faifilter']['base']; $ldap->cd($base); $ldap->search("(objectClass=*)",array("*")); @@ -74,11 +88,89 @@ class faiProfile extends plugin $this->old_cn = $this->cn; } - function execute() + + /* Combine new array */ + 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 getpos($atr,$attrs) + { + $i = 0; + foreach($attrs as $attr => $name) { + $i++; + if($attr == $atr){ + return($i); + } + } + return(-1); + } + + /* TRansports the geiven 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); + } + return($ret); + } + + + /* TRansports the geiven Arraykey one position up*/ + function ArrayDown($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($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); + } + return($ret); + } + + function catUp($id) + { + /* Get all cats depinding on current dir */ + $cats = $this->FAIclasses; + $this->FAIclasses =$this->ArrayUp($id,$cats); + } + + function catDown($id) { - /* Call parent execute */ - plugin::execute(); + /* Get all cats depinding on current dir */ + $cats = $this->FAIclasses; + $this->FAIclasses =$this->ArrayDown($id,$cats); + } + function execute() + { + /* Call parent execute */ + plugin::execute(); /* Fill templating stuff */ $smarty= get_smarty(); $display= ""; @@ -87,6 +179,7 @@ class faiProfile extends plugin $s_action = ""; /* Remove class name From list */ + $sort_once = false; foreach($_POST as $name => $post){ if(preg_match("/DEL_/i",$name)){ $s_action = "delete"; @@ -100,6 +193,23 @@ class faiProfile extends plugin }elseif(preg_match("/AddClass/i",$name)){ $s_action = "add"; } + + if((preg_match("/sortup_/",$name))&&(!$sort_once)){ + $sort_once = true; + $val = preg_replace("/sortup_/","",$name); + $val = preg_replace("/_.*$/","",$val); + $val = base64_decode($val); + $this->catUp($val); + } + + if((preg_match("/sortdown_/",$name))&&(!$sort_once)){ + $sort_once = true; + $val = preg_replace("/sortdown_/","",$name); + $val = preg_replace("/_.*$/","",$val); + $val = base64_decode($val); + $this->catDown($val); + } + } if($s_action == "delete"){ @@ -110,7 +220,7 @@ class faiProfile extends plugin $this->dialog = new faiProfileEntry($this->config,$this->dn,$this->FAIclasses); $this->is_dialog =true; } - + /* Save Dialog */ if(isset($_POST['SaveSubObject'])){ $this->dialog->save_object(); @@ -135,52 +245,49 @@ class faiProfile extends plugin unset($this->dialog); $this->dialog=NULL; } - + if(isset($this->dialog)){ $this->dialog->save_object(); return($this->dialog->execute()); } - $divlist =new divlist("Profile"); + $divlist =new divSelectBox("Profile"); $divlist->SetSummary(_("This list displays all assigned class names for this profile.")); - $divlist->SetEntriesPerPage(0); - - $divlist->SetHeader(array(array("string"=>"Class name"), - array("string"=>"Objects","attach"=>"style='width:120px;'"), - array("string"=>"Options","attach"=>"style='border-right:none;width:60px;'"))); - $listhead = - "
". - " ". - "
"; - - $objTypes['FAIhook'] = ""; - $objTypes['FAItemplate'] = ""; - $objTypes['FAIscript'] = ""; - $objTypes['FAIvariable'] = ""; - $objTypes['FAIpackages'] = ""; - $objTypes['FAIpartitionTable'] = ""; + + $objTypes['FAIhook'] = ""; + $objTypes['FAItemplate'] = ""; + $objTypes['FAIscript'] = ""; + $objTypes['FAIvariable'] = ""; + $objTypes['FAIpackages'] = ""; + $objTypes['FAIpartitionTable'] = ""; $actions = ""; + $linkupdown = " "; + $linkupdown.= ""; + foreach($this->FAIclasses as $usedClass){ - $str = ""; + $str = " "; + + if(isset($this->FAIAllclasses[$usedClass])){ foreach($this->FAIAllclasses[$usedClass] as $class => $obj){ $str.= $objTypes[$class]; } } + + $field1 = array("string"=> $usedClass,"attach"=>""); $field2 = array("string"=> $str,"attach"=>""); - $field3 = array("string"=> preg_replace("/%KEY%/",$usedClass,$actions),"attach"=>"style='border-right:none;'"); + $field3 = array("string"=> preg_replace("/%KEY%/",$usedClass,$actions).preg_replace("/%s/",base64_encode($usedClass),$linkupdown),"attach"=>"style='border-right:none;'"); $divlist->AddEntry(array($field1,$field2,$field3)); } - + $smarty->assign("FAIclasses" ,$this->FAIclasses); - $smarty->assign("divlisthead" ,$listhead); $smarty->assign("divlist" ,$divlist->DrawList()); - /* Magic quotes GPC, escapes every ' " \, to solve some security risks + /* Magic quotes GPC, escapes every ' " \, to solve some security risks * If we post the escaped strings they will be escaped again */ foreach($this->attributes as $attrs){ @@ -195,7 +302,7 @@ class faiProfile extends plugin $display.= $smarty->fetch(get_template_path('faiProfile.tpl', TRUE)); return($display); } - + function remove_from_parent() { $ldap = $this->config->get_ldap_link(); @@ -221,11 +328,11 @@ class faiProfile extends plugin function check() { $message= array(); - + if(count($this->FAIclasses) == 0){ $message[]=_("Please assign at least one class to this profile."); } - + if(empty($this->cn)){ $message[]=_("Please enter a valid name."); } @@ -233,7 +340,7 @@ class faiProfile extends plugin $ldap = $this->config->get_ldap_link(); $ldap->cd($_SESSION['faifilter']['base']); $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",array("*")); - + if($ldap->count()){ $message[]=_("There is already a profile with this class name defined."); } @@ -246,12 +353,14 @@ class faiProfile extends plugin function save() { plugin::save(); - + $ldap = $this->config->get_ldap_link(); $this->FAIclass = ""; + $i = 0 ; foreach($this->FAIclasses as $class){ - $this->FAIclass.=$class." "; + $i ++ ; + $this->FAIclass.=$class."|".$i." "; } $this->attrs['FAIclass']=trim($this->FAIclass); diff --git a/plugins/admin/fai/faiProfile.tpl b/plugins/admin/fai/faiProfile.tpl index 5bbfa3c5e..54dd63ffe 100644 --- a/plugins/admin/fai/faiProfile.tpl +++ b/plugins/admin/fai/faiProfile.tpl @@ -30,9 +30,10 @@

 {t}FAI classes{/t}

-