X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Ffai%2Fclass_faiScript.inc;h=08859d81615720686d424ca00568ba3bcabd378e;hb=5182088544d8de60ae3200b23e1c0eb785c32663;hp=9885b5cfacca92570aeb4b3cb632263736543a25;hpb=9257a76b419aca878f2ebea8315455339b5a57e2;p=gosa.git diff --git a/plugins/admin/fai/class_faiScript.inc b/plugins/admin/fai/class_faiScript.inc index 9885b5cfa..08859d816 100644 --- a/plugins/admin/fai/class_faiScript.inc +++ b/plugins/admin/fai/class_faiScript.inc @@ -71,7 +71,7 @@ class faiScript extends plugin $this->SubObjects[$object['cn'][0]][$attrs]=addslashes($this->SubObjects[$object['cn'][0]][$attrs]); } - $this->SubObjects[$object['cn'][0]]['FAIscript'] = $this->readBinary("FAIscript",$object['dn']); + $this->SubObjects[$object['cn'][0]]['FAIscript'] = addslashes ($this->readBinary("FAIscript",$object['dn'])); $this->SubObjects[$object['cn'][0]]['status'] = "edited"; $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; @@ -81,6 +81,9 @@ class faiScript extends plugin function execute() { + /* Call parent execute */ + plugin::execute(); + /* Fill templating stuff */ $smarty= get_smarty(); $display= ""; @@ -91,20 +94,55 @@ class faiScript extends plugin $this->is_dialog=true; } - $_SESSION['objectinfo'] = $this->dn; + if($this->dn != "new"){ + $_SESSION['objectinfo']= $this->dn; + } + + + /* New Listhandling + */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^editscript_/",$name)&&($once)){ + $once = false; + $entry = preg_replace("/^editscript_/","",$name); + $entry = base64_decode(preg_replace("/_.*/","",$entry)); + $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$entry]); + $_SESSION['objectinfo'] = $this->SubObjects[$entry]['dn']; + $this->is_dialog=true; + } + if(preg_match("/^deletescript_/",$name)&&($once)){ + $once = false; + $entry = preg_replace("/^deletescript_/","",$name); + $entry = base64_decode(preg_replace("/_.*/","",$entry)); + if($this->SubObjects[$entry]['status'] == "edited"){ + $this->SubObjects[$entry]['status']= "delete"; + }else{ + unset($this->SubObjects[$entry]); + } + } + } + ///// Ende new list handling + + /* Edit selected Sub Object */ if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ - $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]); - $_SESSION['objectinfo'] = $this->SubObjects[$_POST['SubObject']]['dn']; + $script = $_POST['SubObject'][0]; + + $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$script]); + $_SESSION['objectinfo'] = $this->SubObjects[$script]['dn']; $this->is_dialog=true; } /* Remove Sub object */ if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ - if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){ - $this->SubObjects[$_POST['SubObject']]['status']= "delete"; - }else{ - unset($this->SubObjects[$_POST['SubObject']]); + + foreach($_POST['SubObject'] as $script){ + if($this->SubObjects[$script]['status'] == "edited"){ + $this->SubObjects[$script]['status']= "delete"; + }else{ + unset($this->SubObjects[$script]); + } } } @@ -136,6 +174,17 @@ class faiScript extends plugin } } + /* Sort entries */ + $tmp = $keys = array(); + foreach($this->SubObjects as $key => $entry){ + $keys[$key]=$key; + } + natcasesort($keys); + foreach($keys as $key){ + $tmp[$key]=$this->SubObjects[$key]; + } + $this->SubObjects = $tmp; + /* Cancel Dialog */ if(isset($_POST['CancelSubObject'])){ $this->is_dialog=false; @@ -150,6 +199,32 @@ class faiScript extends plugin return($display); } + /* Divlist added 23.02.2006 + Containing FAIscripts + */ + $divlist = new divSelectBox("FAIscripts"); + $img_edit = ""; + $img_remo = ""; + + foreach($this->getList(true) as $key => $name){ + + if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new")){ + $down = ""; + }else{ + $down = " + "._("Download")." + "; + } + + $divlist->AddEntry(array( array("string"=>$name['name']), + array("string"=>$down , "attach" => "style='width:20px;'"), + array("string"=>str_replace("%s",base64_encode($key),$img_edit.$img_remo), + "attach"=>"style='border-right: 0px;width:50px;text-align:right;'"))); + } + $smarty->assign("Entry_divlist",$divlist->DrawList()); + /* Divlist creation complete + */ + $smarty->assign("SubObjects",$this->getList()); $smarty->assign("SubObjectKeys",array_flip($this->getList())); @@ -170,14 +245,23 @@ class faiScript extends plugin /* Generate listbox friendly SubObject list */ - function getList(){ + function getList($use_dns=false){ $a_return=array(); foreach($this->SubObjects as $obj){ if($obj['status'] != "delete"){ - if((isset($obj['description']))&&(!empty($obj['description']))){ - $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; + if($use_dns){ + if((isset($obj['description']))&&(!empty($obj['description']))){ + $a_return[$obj['cn']]['name']= $obj['cn']." [".$obj['description']."]"; + }else{ + $a_return[$obj['cn']]['name']= $obj['cn']; + } + $a_return[$obj['cn']]['dn']= $obj['dn']; }else{ - $a_return[$obj['cn']]= $obj['cn']; + if((isset($obj['description']))&&(!empty($obj['description']))){ + $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; + }else{ + $a_return[$obj['cn']]= $obj['cn']; + } } } } @@ -229,7 +313,9 @@ class faiScript extends plugin if($ldap->count()!=0){ /* Write FAIscript to ldap*/ $ldap->cd($this->dn); - $ldap->modify($this->attrs); + $this->cleanup(); +$ldap->modify ($this->attrs); + }else{ /* Write FAIscript to ldap*/ $ldap->cd($this->config->current['BASE']); @@ -295,7 +381,9 @@ class faiScript extends plugin $this->handle_post_events("remove"); }elseif($obj['status'] == "edited"){ $ldap->cd($sub_dn); - $ldap->modify($tmp); + $this->cleanup(); +$ldap->modify ($tmp); + $this->handle_post_events("modify"); }elseif($obj['status']=="new"){ if($tmp['description']==array()){