From: hickert Date: Thu, 6 Oct 2005 10:03:37 +0000 (+0000) Subject: Some changes X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0fd77fbc3189b2acfe1f78961d6bd98c663ea4f1;p=gosa.git Some changes This line, and those below, will be ignored-- M fai/class_faiPackageEntry.inc M fai/class_faiPackage.inc git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1505 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc index eb27521f5..1688637e1 100644 --- a/plugins/admin/fai/class_faiPackage.inc +++ b/plugins/admin/fai/class_faiPackage.inc @@ -44,6 +44,7 @@ class faiPackage extends plugin var $mirrors = array(); // The combination of server/section/release var $confDir = ""; + var $usedPackages = array(); function faiPackage ($config, $dn= NULL) { @@ -58,6 +59,10 @@ class faiPackage extends plugin $this->dn =$dn; } + unset($this->attrs['FAIpackage']['count']); + foreach($this->attrs['FAIpackage'] as $pkg){ + $this->usedPackages[] = $pkg; + } $this->confDir = CONFIG_DIR."/fai/"; $this->FAIpackage = "test"; } @@ -73,10 +78,56 @@ class faiPackage extends plugin $smarty->assign($attrs,$this->$attrs); } - /* Second try */ + $this->genMirror(); + + $availableServer = array(); + foreach($this->mirrors as $mir){ + if(($mir['section'] == $this->section)&&($mir['release']==$this->release)){ + $availableServer[$mir['mirror']]=$mir['mirror']; + } + } + + if(isset($_POST['Addpkg'])){ + $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->confDir.$this->mirror."/".$this->section."/".$this->release,$this->usedPackages); + $this->is_dialog =true; + } + + if(isset($_POST['CancelSubObject'])){ + $this->dialog = false; + $this->is_dialog=false; + } + + if(isset($_POST['SaveSubObject'])) { + $this->dialog->save_object(); + if(count($this->dialog->check())){ + foreach($this->dialog->check() as $msgs){ + print_red($msgs); + } + }else{ + $use = $this->dialog->save(); + $this->usedPackages = $use; + $this->dialog = false; + $this->is_dialog=false; + } + } + + if($this->is_dialog){ + return $this->dialog->execute(); + } - /* Check available server entries in CONFIG_DIR/fai - */ + + $smarty->assign("mirrors" ,$availableServer); + $smarty->assign("mirror" ,$this->mirror); + $smarty->assign("sections",$this->sections); + $smarty->assign("section" ,$this->section); + $smarty->assign("releases",$this->releases); + $smarty->assign("release" ,$this->release); + $smarty->assign("usedPackages",$this->printUsedPackages()); + $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE)); + return($display); + } + + function genMirror(){ $confDir = $this->confDir; if(!is_readable($confDir)){ print_red(sprintf(_("Can't read configuration folder '%s'."),$confDir)); @@ -133,32 +184,7 @@ class faiPackage extends plugin fclose($fd); } - $availableServer = array(); - foreach($this->mirrors as $mir){ - if(($mir['section'] == $this->section)&&($mir['release']==$this->release)){ - $availableServer[$mir['mirror']]=$mir['mirror']; - } - } - - if(isset($_POST['Addpkg'])){ - $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->confDir.$this->mirror."/".$this->section."/".$this->release); - $this->is_dialog =true; - } - - if($this->is_dialog){ - return $this->dialog->execute(); - } - - $smarty->assign("mirrors" ,$availableServer); - $smarty->assign("mirror" ,$this->mirror); - $smarty->assign("sections",$this->sections); - $smarty->assign("section" ,$this->section); - $smarty->assign("releases",$this->releases); - $smarty->assign("release" ,$this->release); - $smarty->assign("usedPackages",$this->usedPackages); - $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE)); - return($display); } /* Delete me, and all my subtrees @@ -196,6 +222,15 @@ class faiPackage extends plugin return ($message); } + function printUsedPackages(){ + $a_ret=array(); + if(is_array($this->usedPackages)) { + foreach($this->usedPackages as $usedName){ + $a_ret[$usedName] = $usedName; + } + } + return($a_ret); + } /* Save to LDAP */ function save() @@ -203,7 +238,16 @@ class faiPackage extends plugin plugin::save(); $ldap = $this->config->get_ldap_link(); - + + $this->attrs['FAIpackage'] = array(); + foreach($this->usedPackages as $pkg => $obj){ + $this->attrs['FAIpackage'][] = $pkg; + } + + unset($this->attrs['section']); + unset($this->attrs['mirror']); + unset($this->attrs['release']); + $ldap->cat($this->dn); if($ldap->count()!=0){ /* Write FAIscript to ldap*/ diff --git a/plugins/admin/fai/class_faiPackageEntry.inc b/plugins/admin/fai/class_faiPackageEntry.inc index 954cbd77b..006462389 100644 --- a/plugins/admin/fai/class_faiPackageEntry.inc +++ b/plugins/admin/fai/class_faiPackageEntry.inc @@ -16,15 +16,17 @@ class faiPackageEntry extends plugin var $buffer = array(); var $categories = array(); var $searchStr = "*"; + var $selected = array(); /* Array with available class names */ var $FAIAllclasses = array(); - function faiPackageEntry ($config, $dn= NULL,$strID=false) + function faiPackageEntry ($config, $dn= NULL,$strID=false,$selected=array()) { plugin::plugin ($config, $dn); $this->strID = $strID; + $this->selected=$selected; } function execute() @@ -39,7 +41,7 @@ class faiPackageEntry extends plugin $divlist->SetHeader(array(array("string"=>" "), array("string"=>"Name"), array("string"=>"Version"), - array("string"=>"Description"))); + array("string"=>"Description","attach"=>"style='border-right:0px;'"))); if(isset($_GET['search'])){ $this->searchStr= $_GET['search']."*"; @@ -64,9 +66,9 @@ class faiPackageEntry extends plugin $CHKS = "
"; foreach($this->categories as $cat => $selected){ if($selected){ - $CHKS .=" ".$cat." "; + $CHKS .=" ".$cat." "; }else{ - $CHKS .=" ".$cat." "; + $CHKS .=" ".$cat." "; } } $CHKS .= "
"; @@ -77,26 +79,35 @@ class faiPackageEntry extends plugin $packages = array_merge($packages,$pkgs[$cat]); } } -/* + foreach($_POST as $name => $value){ if(preg_match("/^wasonpage_/i",$name)){ $name = preg_replace("/^wasonpage_/","",$name); + $n =base64_decode($name); if(isset($_POST['use_'.$name])){ - print "was checked"; + $this->selected[$n] = $n; + }else{ + if(isset($this->selected[$n])){ + unset($this->selected[$n]); + } } + } - } -*/ foreach($packages as $pkg){ if(preg_match("/^".str_replace("*",".*",$this->searchStr)."/i",$pkg[0])){ - $chkbox = " + if(in_array($pkg[0],$this->selected)){ + $check = " checked "; + }else{ + $check = ""; + } + $chkbox = " "; $divlist->AddEntry(array(array("string"=>$chkbox), array("string"=>$pkg[0]), array("string"=>$pkg[1]), - array("string"=>$pkg[3]))); + array("string"=>$pkg[3],"attach"=>"style='border-right:0px'"))); } } @@ -117,6 +128,21 @@ class faiPackageEntry extends plugin /* Save data to object */ function save_object() { + foreach($_POST as $name => $value){ + if(preg_match("/^wasonpage_/i",$name)){ + $name = preg_replace("/^wasonpage_/","",$name); + $n =base64_decode($name); + if(isset($_POST['use_'.$name])){ + $this->selected[$n] = $n; + }else{ + if(isset($this->selected[$n])){ + unset($this->selected[$n]); + } + } + + } + } + } /* Check supplied data */ @@ -128,13 +154,22 @@ class faiPackageEntry extends plugin function save() { - $tmp = array(); - foreach($this->FAIAllclasses as $class => $obj){ - if($obj['status']==true){ - $tmp[$class]=$class; +/* + $a_ret= array(); + $pkgs = $this->genPkgs(); + foreach($this->selected as $pkg){ + foreach($pkgs as $cat => $obj){ + foreach($obj as $package){ + if($package[0] == $pkg){ + $a_ret[$package[0]]=$package; + } + } } } - return($tmp); + return($a_ret); +*/ + + return($this->selected); } /* Generate listbox friendly SubObject list